XML Schema Full Touch

Source: Internet
Author: User
Tags touch xml parser

Content Summary: XML schemas, like DTDs, are responsible for defining and describing the structure and content patterns of XML documents. It can define the relationships between elements and elements in an XML document, and you can define the data types of elements and attributes.

What is an XML Schema

XML schemas, like DTDs, are responsible for defining and describing the structure and content patterns of XML documents. It can define the relationships between elements and elements in an XML document, and you can define the data types of elements and attributes.

The XML schema itself is an XML document that conforms to the XML syntax structure. It can be parsed using a generic XML parser.

Why to use Schema

Why do we have schemas when we have previously used DTDs to define the structure and data types of an XML?

Because DTDs have a number of drawbacks:

1 The DTD is based on regular expressions, and the descriptive ability is limited;

2 DTD is not supported by data type, and has insufficient capability in most application environments;

3 the constraint definition of DTD is not enough to make the semantic restriction of XML instance documents more detailed;

4 The structure of the DTD is not enough, the cost of reuse is relatively high;

5 The DTD does not use XML as a descriptive tool, and the DTD is built and accessed without a standard programming interface and cannot be maintained in a standard programming manner.

XML Schemas are designed for the shortcomings of these DTDs, and the benefits of XML Schemas are:

1 XML Schema based on XML, no specialized 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 an extensible data model.

5 XML schema supports integrated namespaces

6 XML Schema supports attribute groups.

A simple XML Schema document

In this schema, an element is defined: quantity, its type is nonNegativeInteger (nonnegative integer), and xmlns is the namespace of the schema, which is described in the 3rd part above.

The following XML fragment is legal:

<quantity>5</quantity>

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.