Recently, I have worked hard to read the WMFC-defined interface 1 standard document. XML Schema is used for the definition of XML format. XML Schema plays a major role in many aspects, there is a tendency to replace DTD, so I wrote some study notes here. Please correct me if you have any omissions!
Other aspects of XML Schema may not be here, so they will go directly to the topic, concerning the basic syntax of XML Schema.
XSDL (XML Schema Definition Language) is composed of elements, attributes, namespaces, and other nodes of the XML document type.
I. Elements in XSD
The XSD document must include at least the schema root element, the XML schema namespace definition, and the element definition.
Only one schema root element must be defined in XSD. The root element includes schema constraints, XML schema namespaces, definitions of other namespaces, version information, language information, and other attributes.
2. Elements
Syntax:
<Xsd: element name = "user" type = "xsd: string"/>
Elements in XSD are declared using element identifiers. Here, the name attribute is the name of the element, and the type attribute is the type of the element value. Here it can be the built-in data type in XML Schema or other types.
Example:
<Xsd: schema xmlns: xsd = "http://www.w3.org/2001/xmlschema">
<Xsd: element name = "user" type = "xsd: string"/>
</Xsd: schema>
The valid XML documents corresponding to the above documents are as follows:
<? Xml version = "1.0"?>
<User> string </user>
The element definition has two attributes: minOccurs and maxOccurs. MinOccurs defines the minimum number of times this element appears in the parent element (1 by default, and the value is an integer greater than or equal to 0 ), maxOccurs defines the maximum number of times this element appears in the parent element (1 by default, and an integer greater than or equal to 0 ). In maxOccurs, you can set the value to unbounded, indicating that there is no limit on the maximum number of times an element appears.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.