XML references to schema 123

Source: Internet
Author: User
ArticleDirectory
    • 1. xml references to the schema document 123
    • 2. schema document overview 123
    • 3. Simple elements, composite elements, and attributes of Schema
    • 4. schema Constraints
    • 5. schema indicator
    • 6. How to create an XMLSCHEMA and XML elements
Schema series articles

1. xml references to the schema document 123

2. schema document overview 123

3. Simple elements, composite elements, and attributes of Schema

4. schema Constraints

5. schema indicator

6. How to create an XMLSCHEMA and XML elements

 

Example of Schema:

 

<? XML version = "1.0" encoding = "UTF-8"?> <Xs: schema id = "uniondemo" elementformdefault = "qualified" xmlns = "http://tempuri.org/test. XSD "xmlns: mstns =" http://tempuri.org/test.xsd "xmlns: xs =" http://www.w3.org/2001/XMLSchema "> </Xs: schema>

Step by step analysis:

 
Xmlns: xs = "http://www.w3.org/2001/XMLSchema"

Specify the elements and data types used in the schema from http://www.w3.org/2001/xmlschemanamespace (namespace ). It also specifies that elements and data types from the http://www.w3.org/2001/XMLSchema namespace must have a prefix "XS :"

 

 
Targetnamespace = "http://tempuri.org/test.xsd"

It implies that the elements defined by this schema come from"Http://tempuri.org/unionDemo.xsd"Namespace,

 

 

Xmlns = "http://tempuri.org/test.xsd"

Specifies the default namespace

 

 

 
Elementformdefault = "qualified"

Specifies that any element used in the XML instance document declared by the schema must be a valid namespace;

 

XML case document:

 
<? XML version = "1.0" encoding = "UTF-8"?>

 

Indeed, the new XML file is so simple and simple. Let's improve it step by step !!

First, write the root element according to the corresponding schema document, and then specify the namespace of the XML schema instance;

 

 
Xmlns: NS = "http://www.w3.org/2001/XMLSchema-instance"

Once you have the namespace of the XML schema instance that can be used, you can use the schemalcation attribute,

 

 

 
NS: schemalocation = "http://tempuri.org/test.xsd test. XSD"

This property has two values. The first value is the namespace (It is generally considered as the targetnamespace value in the schema file.). The second value specifies the location of the XML schema to be used for the namespace (the previous parameter.

 

 

 
Xmlns = "http://tempuri.org/test.xsd"

Specifies the default namespace declaration. This statement tells Schema-validator that all elements used in this XML document areHttp://tempuri.org/test.xsdNamespace (That is, the targetnamespace value of the schema file.);

After the preceding steps, the XML file is associated with the schema. The result is as follows:


 
<? XML version = "1.0" encoding = "UTF-8"?> <Person xmlns: NS = "http://www.w3.org/2001/XMLSchema-instance"
 
NS: schemalocation = "http://tempuri.org/test.xsd test. XSD"
 
Xmlns = "http://tempuri.org/test.xsd"> </person>

 

 

The following input must follow the schema description to complete XML. Otherwise, an error is reported,

More references http://www.cnblogs.com/caoxch/archive/2006/11/17/563856.html

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.