Detailed description of graphic code in full contact with XMLSchema

Source: Internet
Author: User
Content abstract: like DTD, XMLSchema defines and describes the structure and content patterns of XML documents. It defines the relationships between elements in an XML document and the data types of elements and attributes. Content abstract: XML Schema, like DTD, is used to define and describe the structure and content pattern of XML documents. It defines the relationships between elements in an XML document and the data types of elements and attributes.

What is XML Schema?

Like a DTD, XML Schema defines and describes the structure and content pattern of an XML document. It defines the relationships between elements in an XML document and the data types of elements and attributes.

XML Schema is an XML document, which conforms to the XML syntax structure. You can use a common XML parser to parse it.

Why use Schema?

We have already used DTD to define the structure and data type of an XML file. why do we need Schema?

DTD has many defects:

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

2) DTDs do not support data types and are insufficient in most application environments;

(3) insufficient limits on the definition of DTD constraints, making it impossible to make more detailed semantic restrictions on XML instance documents;

4) the structure of the DTD is not structured enough, and the reuse cost is relatively high;

5) DTD does not use XML as a description method, but does not have a standard programming interface for DTD construction and access. it cannot be maintained using standard programming methods.

XML Schema is designed to address the shortcomings of these DTD. the advantages of XML Schema:

1) XML Schema is based on XML and there is 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 an extensible data model.

5) XML Schema supports a comprehensive namespace

6) XML Schema supports attribute groups.

A simple XML Schema document

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

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

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

 
  some
 

All built-in simple types

Original type

string,boolean,decimal,float,double,durationdatetime,time,date,gYearMonth,gYear,gMonthDay,dDay,gMonth,hexBinary,base64Binary,any URI,QNameNOTATION

Derivative Type (base type in parentheses)

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)

Create simple type

In the figure, we first create a simple type: quantityType, which is inherited from integer. minequalsive and maxcompusive define its minimum value 2 and maximum value 5. Finally, we define the quantity type as quantityType.

Correct:
 
  
3
 Error:
 
  
10
 
 
  
Aaa
 

With restriction, we can limit that only a certain value or certain text can be accepted,

Basic Aspects: equal, ordered, bounded, cardinality, numeric restriction: length, minLength, maxLengthpattern, rule, maxExclusive, minexclusive, minExclusivetotalDigits, fractionDigits

Example 1 of a simple type

The value of this SKU type: the three numbers are followed by a font size and followed by two uppercase letters.

Pattern is followed by a regular expression. For more information about the regular expression syntax, see other books.

Correct:
 
  
123-AB
 Error:
 
  
Abc-AB
 
 
  
123-AB
 

Example 2 of a simple type

This is a USState used to describe the name of a U.S. state. enumeration is used to list all state names. when the value is set, only the state names listed in it can be used.

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.