XML Schema Learning Notes (1)

xiaoxiao2021-03-06  145

XML Schema learning notes

Zhang Xiaoot

1. The most fundamental difference between complex types and simple types is: Complicated types of contents can contain other elements, or attribute, but the simple type can neither contain child elements, nor without any properties.

2, ELEMENT presence constraint: Element can constrain the number of elements instances through its MinoCCURS and MaxocCurs, the default values ​​of these two attributes are 1, indicating that this element must appear in the XML instance document by default. once.

3, Attribute existence: Element properties can also be constrained once or not; the value of the USE attribute can be a 10 value of Required, Optional, Prohibited, and the default (default) value is Optional.

4, Element and Attribute have a default and fixed properties, for Element, only this default value is used when the Element instance is empty, and attribute is used when the instance does not provide this Attribute, so this default value is used. For example, only its USE value is Optional, the default value is meaningful, and two attributes for Element and Attribute cannot always exist at the same time, otherwise an error will occur.

5. Directly defined under the Schema element, the Element and Attribute of the top-level child elements of the Schema element are all globally, called global elements and global properties, you can directly reference them in other types of definitions.

6. There are two ways to derive the new type: the first is to extend directly from other types (inherit), and the other is by defining the existing type.

Such as: There are three new types defined by a definition of definition:

The value range is limited:

Using mode match Limit:

Use enumeration mode limited:

7, atomic type (indivisible type, type of String, Integer and other systems), list type, combined type together, uniformly referred to as simple types. There are three built-in types of NMTOKENS, IDREFS, and Entities in Schema, and you can also create a list type from existing simple types, but you cannot create a list from existing list and complex types ( List) type.

Such as:

The value of the list type in the XML instance document is separated by spaces. If a listofmyinttype element is declared, its value may be:

20003 15037 95977 95945

8, there are several elements can be applied to the list type to constrain, they are: Length, minlength, maxlength and enumeration, such as:

Note: For the list type, you should pay more attention to the String type because the splitter space in the String type is partially confused.

9. The definition of the element can be used to use an anonymous definition type by specifying its Type property, or an anonymous definition type, such as:

Type definition:

Using anonymous definition:

/>

10. UNION (United) type Indicates the element instance in the XML instance document that meets one of the member types defined by the UNION type (legal), which has similar concepts in this and C , such as:

11. Complex types can generally be divided into three categories: The first class is the character content and attribute but does not include sub-elements; the second class is the primary and sub-elements but does not contain character data (character data is included in sub-elements); The three categories are, that is, the content and character content, and the sub-elements are included; so how to define these three types? For the first class, you can be implemented via SimpleContent. The second class can be done by ComplexContent, and the third category only needs to set the property Mixed of ComplexType to true. Specific examples are as follows:

The first type (extension from a simple type, adding the property):

The second type (there is a Element and two Attribute):

Note: Since default, default is ComplexContent, a brief way here is:

Third type:

The third type of instance may be as follows:

Dear Mr. robert smith .

Your ORDER OF 1 Baby

Monitor shipped from ot warehouse on

1999-05-21

12. According to the description of 11, the element of an empty content is to be defined, that is, the element that only contains only attributes, as long as there is no child element in ComplexContent, it is, for example,:

13. Anytype is a base type of all Schema types, similar to Object in Java. Therefore, the following definition:

Can be written:

14, Schema uses Annotation, Document, AppInfo three elements for comments, where APPI and Document are processed as child elements of ANNOTATION. And Annotation is typically a top layer element of the top layer element of Schema, ELEMENT, and a top layer element defined.

Such as:

Element Declared with Anonymous Type

EMPTY Anonymous Type with 2 Attributes

15. Choice only allows one of the child elements to be used in the instance document; all elements in the ALL can appear or once, and in which the element instance is not constrained, and the ALL must be placed in any content model. The top floor, in order to illustrate this problem, let's list a legal, then list a illegal for comparison instructions:

Here is a illegal:

16. There are several types of types in many types, and the properties group can be used to reuse, the format of the property group defined is:

TYPE = "xsd: string" />

TYPE = "xsd: string" />

...

Use can be used:

TYPE = "xsd: string" />

转载请注明原文地址:https://www.9cbs.com/read-127992.html

New Post(0)