search
HomeBackend DevelopmentXML/RSS TutorialDetailed explanation of XML Schema full-touch graphic and text code

Content summary: XML Schema, like DTD, is responsible for defining and describing the structure and content schema of XML documents. It can define which elements and relationships between elements exist in the XML document, and can define the data types of elements and attributes .

What is XML Schema

XML Schema, like DTD, is responsible for defining and describing the structure and content schema of XML documents. It can define which elements and relationships between elements exist in the XML document, and can define the data types of elements and attributes.

XML Schema itself is an XML document, which conforms to the XML syntax structure. It can be parsed with a common XML parser.

Why use Schema

We have already used DTD to define an XML structure and data type, so why do we need Schema?

Because DTD has many defects :

1) DTD is based on regular expressions and has limited description capabilities;

2) DTD does not have data type support and is insufficient in most application environments ;

3) DTD's constraintsdefinition capabilities are insufficient to make more detailed semantic restrictions on XML instance documents;

4) The structure of DTD is not structured enough and cannot be reused The cost is relatively high;

5) DTD does not use XML as a description method, and there is no standardprogramminginterface for the construction and access of DTD, and standards cannot be used Programmatically perform DTD maintenance.

XML Schema is designed to address the shortcomings of these DTDs. The advantages of XML Schema are:

1) XML Schema is based on XML and has no special syntax

2) XML can be parsed and processed like other XML files

3) XML Schema supports a series of data types (int, float, Boolean, date, etc.)

4) XML Schema provides extensible Data model.

5) XML Schema supports comprehensive namespace

6) XML Schema supports attribute groups.

A simple XML Schema document

Detailed explanation of XML Schema full-touch graphic and text code

#An element is defined in this Schema: quantity, its type is nonNegativeInteger (non-negative integer), xmlns It is the namespace of Schema, which has been described in Part 3 above.

The following XML fragment is legal:

<quantity>5</quantity>

The following XML fragment is illegal:

<quantity>-4</quantiy>

Types in Schema

Schema mainly includes Three components: element, attribute, and notation.

These three basic components can also be combined into the following components:

a) Type definition components: simple types and composite types

b) Assembly components

c) Attribute component

Simple type

Detailed explanation of XML Schema full-touch graphic and text code

XML Schema defines some built-in data types that can be used to describe elements content and attribute values.

If an element only contains numbers, strings or other data, but does not include sub-elements, this is called a simple type.

As shown in the figure, the element quantity is a simple type. Its element content must be a non-negative integer, excluding any attributes and sub-elements.

<quantity>some</quantity>

All built-in simple types

Primitive types

string,boolean,decimal,float,double,duration
datetime,time,date,gYearMonth,gYear,gMonthDay,
dDay,gMonth,hexBinary,base64Binary,any URI,QName
NOTATION

Derived types (base types in brackets)

normalizedString(string),language(tonken),token(normalizedString)
NMTOKEN(token),Name(token),NCName(Name),ID(NCName),IDREF(NCName)
IDREFS(list of IDREF),ENTITY(NCName),ENTITIES(list of ENTITY)
integer(decimal),nonPositiveInteger(integer),
negativeInteger(noPositiveInteger),long(integer),int(long),
short(int),byte(short),nonNegativeInteger(integer)
unsignedLong(nonNegativeInteger),unsignedInt(unsignedLong),
unsignedShort(unsignedInt),unsignedByte(unsignedShort),
positiveInteger(nonNegativeInteger)

Creating simple types

Detailed explanation of XML Schema full-touch graphic and text code

In the figure, we first create a simple type: quantityType, which inherits from integer. minInclusive and maxInclusive define its minimum value 2 and maximum Value 5. Finally, we define the type of element quantity as quantityType.

正确:  <quantity>3</quantity>
错误:  <quantity>10</quantity>
<qauntity>aaa</quantity>

Using restriction, we can limit the acceptance of certain values ​​​​or only certain text,

基本方面:equal,ordered,bounded,cardinality,numeric
限制方面:length,minLength,maxLength
pattern,enumeration
whiteSpace
maxInclusive,maxExclusive,minInclusive,minExclusive
totalDigits,fractionDigits

Simple type example 1

Detailed explanation of XML Schema full-touch graphic and text code

The value of this SKU type: 3 numbers followed by a hyphen followed by two uppercase English letters.

pattern is followed by a regular expression. See other books for regular expression syntax.

正确:  <ourSKU>123-AB</ourSKU>
错误:  <ourSKU>abc-AB</ourSKU>
<ourSKU>123-ab</ourSKU>

Simple type example 2

Detailed explanation of XML Schema full-touch graphic and text code

#This is a type USState used to describe the names of American states. All state names are listed through enumeration. Take When the value is entered, only the state names listed in it can be taken.

The above is the detailed content of Detailed explanation of XML Schema full-touch graphic and text code. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Anatomy of an RSS Document: Structure and ElementsThe Anatomy of an RSS Document: Structure and ElementsMay 10, 2025 am 12:23 AM

The structure of an RSS document includes three main elements: 1.: root element, defining the RSS version; 2.: Containing channel information, such as title, link, and description; 3.: Representing specific content entries, including title, link, description, etc.

Understanding RSS Documents: A Comprehensive GuideUnderstanding RSS Documents: A Comprehensive GuideMay 09, 2025 am 12:15 AM

RSS documents are a simple subscription mechanism to publish content updates through XML files. 1. The RSS document structure consists of and elements and contains multiple elements. 2. Use RSS readers to subscribe to the channel and extract information by parsing XML. 3. Advanced usage includes filtering and sorting using the feedparser library. 4. Common errors include XML parsing and encoding issues. XML format and encoding need to be verified during debugging. 5. Performance optimization suggestions include cache RSS documents and asynchronous parsing.

RSS, XML and the Modern Web: A Content Syndication Deep DiveRSS, XML and the Modern Web: A Content Syndication Deep DiveMay 08, 2025 am 12:14 AM

RSS and XML are still important in the modern web. 1.RSS is used to publish and distribute content, and users can subscribe and get updates through the RSS reader. 2. XML is a markup language and supports data storage and exchange, and RSS files are based on XML.

Beyond Basics: Advanced RSS Features Enabled by XMLBeyond Basics: Advanced RSS Features Enabled by XMLMay 07, 2025 am 12:12 AM

RSS enables multimedia content embedding, conditional subscription, and performance and security optimization. 1) Embed multimedia content such as audio and video through tags. 2) Use XML namespace to implement conditional subscriptions, allowing subscribers to filter content based on specific conditions. 3) Optimize the performance and security of RSSFeed through CDATA section and XMLSchema to ensure stability and compliance with standards.

Decoding RSS: An XML Primer for Web DevelopersDecoding RSS: An XML Primer for Web DevelopersMay 06, 2025 am 12:05 AM

RSS is an XML-based format used to publish frequently updated data. As a web developer, understanding RSS can improve content aggregation and automation update capabilities. By learning RSS structure, parsing and generation methods, you will be able to handle RSSfeeds confidently and optimize your web development skills.

JSON vs. XML: Why RSS Chose XMLJSON vs. XML: Why RSS Chose XMLMay 05, 2025 am 12:01 AM

RSS chose XML instead of JSON because: 1) XML's structure and verification capabilities are better than JSON, which is suitable for the needs of RSS complex data structures; 2) XML was supported extensively at that time; 3) Early versions of RSS were based on XML and have become a standard.

RSS: The XML-Based Format ExplainedRSS: The XML-Based Format ExplainedMay 04, 2025 am 12:05 AM

RSS is an XML-based format used to subscribe and read frequently updated content. Its working principle includes two parts: generation and consumption, and using an RSS reader can efficiently obtain information.

Inside the RSS Document: Essential XML Tags and AttributesInside the RSS Document: Essential XML Tags and AttributesMay 03, 2025 am 12:12 AM

The core structure of RSS documents includes XML tags and attributes. The specific parsing and generation steps are as follows: 1. Read XML files, process and tags. 2. Extract,,, etc. tag information. 3. Handle custom tags and attributes to ensure version compatibility. 4. Use cache and asynchronous processing to optimize performance to ensure code readability.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.