XML concise tutorial lesson 6th apply XMLSchema

Source: Internet
Author: User
Tags xml parser
What is XMLSchema? XMLSchema is an XML-based syntax or schema specification used to define the markup method of XML documents. XMLSchema is a schema specification recommended by Microsoft. it has a higher advantage than Document Type Definition (DTD). What is DTD?
XML Schema is an XML-based syntax or schema specification used to define the markup method of XML documents. XML SC
Hema is a schema specification recommended by Microsoft. it has a lot of advantages over Document Type Definition (DTD ).
The upper hand, while the DTD is the schema specification originally used to define the XML model. DTD has many problems, including non-XML applications.
Syntax, does not support data type definition, and does not have extensibility. For example, DTD does not agree to define the element content as another
An element or string. For more information about DTD, see W3C XML proposal. XML Sch
Ema has improved the DTD in several aspects, including the application XML syntax, supporting data type definition and domain name. For example, XML S
Chema promises to clarify an element as an integer, float, Boolean, URL, and other types.
The XML parser in Internet Explorer 5 can parse XML documents that use DTD or XML Schema.
How to create an XML Schema?
Find the schema declaration for each node in the XML document below.


Jane Smith  
3.8  
 
 
You will note that the default domain name in the above document is "x-schema: classSchema. xml ". This tells the parser
Parse all documents based on the schema (x-schema) on the URL ("classSchema. xml.
The complete schema of the above document is as follows. Pay attention to the name field declaration in the root element of the schema. First (xml
Ns = "urn: schemas-microsoft-com: xml-data") indicates that this XML document is an XML Schema. The
The two (xmlns: dt = "urn: schemas-microsoft-com: datatypes") promise the schema processor
The type attribute in the entType and AttributeType declarations is prefixed with dt to clarify the features of the element type and content.
.
Crosoft-com: datatypes '>


 


 
 
 

 
 
 
The declared elements used to define elements and attributes are as follows:
Yuansu
Description
ElementType assigns the type and condition to an element, which can contain child elements.
AttributeType assigns the type and condition to an attribute.
Attribute declares that attribute types previously defined can be displayed in the scope of an element named ElementType.
Element declaration previously defined element types can be displayed in the scope of an element named ElementType.

The Schema content starts with the "AttributeType" and "ElementType" declarations of the deepest elements.
 

 
After ElementType is declared, it is followed by its attributes and sub-elements. If an element has attributes or sub-elements
This method is included in its ElementType declaration, or must be included in their own ElementType or
In the ttributeType declaration.


 
 
 
Different from DTDs, XML Schema promises an open content mode. you can define data types and applications.
The default value and so on.
In the following schema, The element type is defined and has a default value. Element
No other nodes are declared.
Rosoft-com: datatypes '>



 

'>

 
 
 
The schema above promises that you only verify the region you are concerned with, which gives you more control over the verification level of the document,
And promise you to apply some features provided by the schema without strict validation.
Try it!
Try to process the schema of the XML document in the example.


Fidelma McGinn  
425-655-3393  
 

5523918  
Shovel  
39.99
 
1998-10-23  
1998-11-03  
 
If you have processed the schema, run it in XML Validator.
Download the MSDN Online region to provide a set of XML sample files, including a XM with a coherent schema
L document. Download these sample programs and run them together with the XML document and schema. Assume that you want
Ma to test the XML validity. you can download the document from XML Validator or view
XML file.
Some clarification:
The ElementType and AttributeType declarations must be placed before the attribute and element content declarations. For example
In the preceding schema, Element ElementType declaration must be placed in Element

Before Type declaration.
The default value of the order attribute is based on the value of the content attribute. When the content value is "eltOnly", or

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.