[WebServices two-step forward] element type of lower _ Schema

Source: Internet
Author: User
Element type of lower _ schema -- Shengsi Yuan Zhang Long Editor: Xuan Yu
Schema Group
Element Choice
Attribute Simpletype
Complextype Attributegroup

Element type of Schema
Schema, element, attribute, group, attributegroup, simpletype, simplecontent, complextype
Choice, list, union, unique, sequence, restriction, etc.
Supplement: You can use the <Any> and <anyattribute> elements in the schema to relax the restrictions on the content of the XML file.
That is, it allows us to use elements and attributes that are not defined in the schema in the XML file.
They can be used to create scalable documents that have the ability to include additional elements not declared in the schema

 

 

Schema Element
Purpose: Include the defined schema.
Usage: <Xs: schema>
Attribute: xmlsn: prefix followed by namespace
Targetnamespace: namespace that is subordinate to the element or attribute defined by the current Schema

 

 

Element
Purpose: declare an element.
Attribute: Name/type/Ref/minoccurs/maxoccurs/substitutiongroup/fixed (indicating a fixed value)/default (indicating the default value)
Example:

<! -- An element named cat with the string type is defined here --> <! -- This is written as "XS: string" because the string comes from the <Xs: schema> namespace, And the prefix of this namespace is Xs --> <! -- If it is directly written as "type = string", it will be searched under the current namespace, that is, in targetnamespace --> <! -- The defined cat is in the current namespace, so it is directly written as cat when referenced later. It will be found in the current namespace --> <! -- That is, when the schema attribute or element is used, you must add the namespace prefix. --> <Xs: element name = "cat" type = "XS: string "/> <Xs: element name =" dog "type =" XS: string "/> <Xs: element name =" Pets "> <Xs: complextype> <! -- Sequence element is used to give a group of elements a specific sequence, that is, cat must be before dog --> <! -- And the minimum number of occurrences is zero. The maximum number of occurrences is not bound, that is, there is no limit --> <! -- If the minoccurs and maxoccurs attributes are not specified, cat and dog must appear sequentially and only once --> <Xs: sequence minoccurs = "0" maxoccurs = "unbounded"> <Xs: Element ref = "cat"/> <Xs: Element ref = "dog"/> </Xs: sequence> <! -- All indicates that the sequence of sub-elements is not restricted, but each sub-element must appear only once. --> <! -- It is also the default value of the complextype element, that is, if the element is directly defined in complextype, it uses all --> <Xs: All> <Xs: element name = "pig" type = "XS: string"/> <Xs: element name = "horse" type = "XS: string"/> </Xs: all> </Xs: complextype> </Xs: Element>

 

 

Group element
Purpose: combine a group of element declarations so that they can be used together by composite types.
Attribute: Name/Ref
Example:

<! -- In fact, the XML corresponding to it is <mycomplextype myattribute = "2.2"> <thing11> AA </thing11> <thing22> BB </thing22> </mycomplextype> --> <Xs: element name = "thing11" type = "XS: string"/> <Xs: element name = "thing22" type = "XS: string"/> <Xs: attribute name = "myattribute" type = "XS: decimal"/> <Xs: group name = "mygroupofthings"> <Xs: sequence> <Xs: element ref = "thing11"/> <Xs: Element ref = "thing22"/> </Xs: sequence> </Xs: group> <Xs: complextype name = "mycomplextype"> <Xs: group ref = "mygroupofthings"/> <Xs: attribute ref = "myattribute"/> </Xs: complextype>

 

 

Attribute Element
Purpose: declare an attribute.
Attribute: Name/type/Ref/Use
Example:

<Xs: complextype name = "mycomplextype"> <! -- Use indicates the usage of an attribute. It has two values: optional and prohibited. The default value of use is optional --> <Xs: attribute name = "mybaseattribute" type = "XS: string "use =" required "/> </Xs: complextype>

 

 

Attributegroup Element
Purpose: combine a set of attribute declarations so that they can be applied to a composite type.
Attribute: Name/Ref
Example:

<xs:attributeGroup name="myAttributeGroup"><xs:attribute name="someAttribute11" type="xs:integer"/><xs:attribute name="someAttribute22" type="xs:string"/></xs:attributeGroup><xs:complexType name="myElementType"><xs:attributeGroup ref="myAttributeGroup"/></xs:complexType>

 

 

Simpletype Element
Purpose: define a simple type that determines the constraints and related information of elements and attribute values.
Property: Name
Content: There are three simple types of applications:
Restrict: specifies a range.
List: select from the list
Union: A combination of values.
Example:

<! -- Defines a mytype, whose value is based on an integer. The value can be 5, 6, or 7 --> <! -- That is, the value of the "hello" element can only be 5, 6, or 7, for example, <Hello> 6 </Hello> --> <Xs: simpletype name = "mytype"> <Xs: restriction base = "XS: integer"> <Xs: enumeration value = "5"/> <Xs: enumeration value = "6"/> <Xs: enumeration value = "7"/> </Xs: Restriction> </Xs: simpletype> <Xs: element name = "hello" type = "mytype"/> <! -- Defines an element named hello. Its value is of the date type and can have multiple values separated by spaces. --> <! -- For example, <Hello> 2013-03-15 2013-11-02 2013-12-12 </Hello> is allowed --> <! -- After testing, the month and day here must be two digits, and valid. For example, if the 32th digit is invalid, it will not be verified. --> <Xs: simpletype name = "mytype"> <Xs: List itemtype = "XS: Date"/> </Xs: simpletype> <Xs: element name = "hello" type = "mytype"/> <! -- Defines an element named Java with its child element of the string type. It has a version attribute --> <! -- Version has two optional values: Positive Integers of the number type, which can be, 22, 33 --> <! -- The other type is a size string, which can be small, medium, large --> <! -- The final XML document is like the following --> <! -- <Java version = "22"> <level/> </Java> --> <Xs: attribute name = "version"> <Xs: simpletype> <Xs: union membertypes = "number size"/> <! -- You can also write it as follows --> <! -- <Xs: Union> <Xs: simpletype> <Xs: Restriction base = "Number"/> </Xs: simpletype> <Xs: restriction base = "size"/> </Xs: simpletype> </Xs: Union> --> </Xs: simpletype> </Xs: attribute> <Xs: simpletype name = "Number"> <Xs: Restriction base = "XS: positiveinteger"> <Xs: enumeration value = "11"/> <Xs: enumeration value = "22"/> <Xs: enumeration value = "55"/> </Xs: Restriction> </Xs: simpletype> <Xs: simpletype name = "size"> <Xs: Restriction base = "XS: string"> <Xs: enumeration value = "small"/> <Xs: enumeration value = "medium"/> <Xs: enumeration value = "large"/> </Xs: Restriction> </Xs: simpletype> <Xs: element name = "Java"> <Xs: complextype> <Xs: sequence> <Xs: element name = "level" type = "XS: string"/> </Xs: sequence> <Xs: attribute ref = "version" use = "required"/> </Xs: complextype> </Xs: Element>

 

 

Complextype Element
Purpose: define a composite type that determines the constraints and related information of a group of elements and attributes.
Property: Name
Example:

<! -- Define a composite type named mycomtype. The content of elements of this type is based on decimal, that is, the content of decimal type --> <! -- Extension indicates the element type, and it also has an attribute named sizing whose type is string --> <! -- Finally, when defining the myshoesize element, we specify its type as mycomtype --> <! -- Note: If the mixed attribute is specified, that is, <complextype mixed = "true"> indicates that the compound type can contain both text content and child elements. --> <! -- Note: for example, <message> This message comes from <from> jadyer </from> </message> --> <Xs: complextype name = "mycomtype"> <! -- Simplecontent is usually used in complextype to restrict and expand the content of complextype. --> <! -- If the type of an element is represented by simplecontent, the element does not have child elements, but only content --> <Xs: simplecontent> <Xs: Extension base = "XS: decimal "> <Xs: attribute name =" Sizing "type =" XS: string "/> <! -- If you want to limit the value of the sizing attribute, you can use the following method --> <! -- <Xs: attribute name = "Sizing"> <Xs: simpletype> <Xs: Restriction base = "XS: string"> <Xs: enumeration value = "us"/> <Xs: enumeration value = "European"/> <Xs: enumeration value = "UK"/> </Xs: Restriction> </Xs: simpletype> </Xs: attribute> --> </Xs: Extension> </Xs: simplecontent> </Xs: complextype> <Xs: element name = "myshoesize" type = "mycomtype"/> <! -- Difference between simpletype and complextype --> <! -- Simpletype elements cannot contain elements or attributes --> <! -- When you need to declare a child element or attribute of an element, use complextype --> <! -- When you need to define a new data type based on the built-in basic data type, use simpletype -->

 

 

Choice Element
Purpose: Allow a unique element to be selected from a group
Attribute: minoccurs/maxoccurs
Example:

<Xs: complextype name = "chadstate"> <! -- That is, the following four elements appear at least once and at most once, that is, they must appear once, and the element that appears comes from one of the four elements --> <! -- The default values of minoccurs and maxoccurs are 1, which is directly written as <Xs: Choice> ...... </Xs: Choice> the effect is the same as the following --> <Xs: Choice minoccurs = "1" maxoccurs = "1"> <Xs: element ref = "selected"/> <Xs: Element ref = "unselected"/> <Xs: Element ref = "dimpled"/> <Xs: element ref = "already ated"/> </Xs: Choice> </Xs: complextype>

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.