1. SCHEMA mechanism:
a) Simple Type and Complex Type
Since the XML document is organized into a tree structure, we can distinguish them into leaves nodes and internal nodes in accordance with the location where the node is located. SIMPLE TYPE is the introduction of Schema to indicate the leaf node type, and Complex Type is used to represent internal node types. Therefore, for Simple Type, we care about the value she allows, which is the Lexical Space, Value Space, and Facet, which is said in DataType. For Complex Type, she reflects the structure of the document, so for the Complex Type, we care about how she defines the relationship between nodes.
b) Content Models
Content ModelMixedComplexSIMpleemptyChild Elementsyesyesnonochild Textyesnoyesno
Note: Since Complex Type is used to define internal nodes, Content Model is used to indicate the type of sub-node included in the node.
Empty Content Complex Type: The Node does not contain any text and child node type.
Simple Content Complex Type: Indicates that the node contains only the COMPLEX Type type of the text.
Complex Content Complex Type: Indicates that the node contains only the COMPLEX Type type of the child node.
Mixed Content Complex Type: The child node indicating the node contains both the COMPLEX Type type that contains the child node.
c) Define the syntax of Complex Type:
Abstract = Boolean: False Block = (#All | list of (extension | restriction)) Final = (#All | list of (extension | restriction)) ID = ID Mixed = Boolean: false Name = ncname > Content: (ANNOTATION? (SimpleContent | ComplexContent | ((Group | All | Choice | SEQUENCE)? ((Attribute | AttributeGroup *, Anyattribute?)))))))))))))) complextype> 2. Simple Content Complex Type a) Description: We cannot directly define the Simple Content Complex Type type, but must be extended or constrained by existing Simple Type or Simple Content. b) SIMPLE Content extension (Extension) i. Description: Extension of the base type and define additional properties. Ii. Syntax: Base = Qname ID = ID > Content: (ANNOTATION | ((Attribute | AttributeGroup) *, Anyattribute?)))) extension> Iii. Example: Schema: xs: extension> xs: simplecontent> xs: complexType> xs: element> XML: c) SIMPLE Content constraint (Restriction) i. Description: You can constrain the contents and properties of the base type. By modifying the USE properties of the property, the appearance of this property can be prohibited. The type of constraint is a subset of the base type. Ii. Syntax: Base = Qname ID = ID > Content: (Annotation? (SimpleType ?, (MINEXCLUSIVE | MININCLUSIVE | MAXEXCLUSIVE | MaxinClusive | Totaldigits | FRACTIONDIGITS | Length | MINLENGTH | MAXLENGTH | Enumeration | Whitespace | Pattern *)? (attribute | attributegroup) *, Anyattribute?)))) Iii. Example: Schema: xs: restriction> xs: simplecontent> xs: complexType> xs: element> XML: d) Comparison of two methods: The extension can only increase the new attribute without any constraints and modifications to the text and attributes in the base type. In contrast, the constraint is more flexible, and she can increase the constraints of text and attributes in the base type. 3. Complex Content Complex Type a) Description: We can directly define the COMPLEX Content Complex Type type through the compositor and partical way, and can also extend the existing Complex Content Complex Type type by extension and constraints. b) Define Complex Content Complex Type via Compositor and Partical Compositor and Partical are used to define the relationship between the child node and it. Where Compositor is used to illustrate the order between subtitches, Partical is used to explain which child nodes are included. SCHEMA defined Compositor includes: Sequence, Choice, All; Partical includes: Element, Sequence, Choice, Any, and Group. i. Sequence 1. Description: Partical in sequence must appear in order. 2. Syntax: ID = ID Maxoccurs = (NonnegativeInteger | Unbounded): 1 Minoccurs = NonnegativeInteger: 1 > Content: (Annotation? (Element | Group | Choice | Sequence | Any) *) sequence> 3. Example: Schema: xs: sequence> xs: complexType> xs: element> XML: author> Ii. choice 1. Description: Partical in Choice can only appear one. 2. Syntax: ID = ID Maxoccurs = (NonnegativeInteger | Unbounded): 1 Minoccurs = NonnegativeInteger: 1 > Content: (Annotation? (Element | Group | Choice | Sequence | Any) *) kice> 3. Example: Schema: xs: kice> xs: element> XML: author> III. all 1. Description: Partical in ALL can appear in any order, but Partical maxoccurs properties in ALL can only be less than or equal to 1. 2. Syntax: ID = ID Maxoccurs = 1: 1 Minoccurs = (0 | 1): 1 > Content: (Annotation ?, element *) all> 3. Example: Schema: xs: all> xs: complexType> xs: element> XML: author> c) Exprandation of Complex Content (Extention) i. Description: Extension the base type to define additional elements and properties. Ii. Syntax: Base = Qname ID = ID > Content: (ANNOTATION? (Group | All | Choice | SEQUENCE)? ((((Attribute | AttributeGroup) *, Anyattribute?)))))))))))))))))))))) extension> Iii. Example: Schema: Parent type: xs: kice> xs: complexType> Subtype: xs: sequence> xs: extension> xs: complextence> xs: complexType> xs: element> XML: persons> Note: The definition of subtypes is equivalent to: xs: kice> xs: sequence> xs: sequence> xs: complextence> xs: complexType> d) constraints of Complex Content (Restriction) i. Description: You can constrain the contents and properties of the base type. By modifying the maxoccurs property of the element, the appearance of the element can be restricted, and the appearance of the attribute can be restricted by modifying the USE property of the property. The type of constraint is a subset of the base type. Ii. Syntax: Base = Qname ID = ID > Content: (ANNOTATION? (Group | All | Choice | Sequence) ?, ((attribute | AttributeGroup) *, Anyattribute?)))) restriction> Iii. Example: Schema: Parent type: xs: sequence> Subtype: xs: sequence> xs: restriction> xs: complextence> xs: complexType> xs: element> XML: author> Note: When you get a new type through constraints, for the element part, we need to write the contents of what we need; For the attribute part, we only need to write some parts we want to change. If you don't need to change, you can write it. e) Comparison of two methods Similar to both methods of extending Simple Content, the extension method can only add new nodes or properties at the end of the parent type, and cannot modify the nodes or properties of the parent node. RESTRICTION can redefine the part of the subtypes by re-writing Content and Attribute. In addition, these two methods are non-symmetrical, that is, passing Extension and Restriction cannot return to the original type. For the use of extended methods, the XML file content of the expansion class is not necessarily in line with the base class. For constraint methods, the XML content of the expansion class must also be in line with the base class. 4. Mixed Content Complex Type a) Description: We can define the Mixed Content Complex Type type by the Mixed property in the ComplexType statement. Mixed Content Complex Type can also be extended by extending and constraints. b) Definition Mixed Content Complex Type via Mixed Attributes I. Example: Schema: xs: kice> xs: complexType> xs: element> XML:
... title> c) Mixed Content extensions I. Example: Schema: xs: kice> xs: extension> xs: complextence> xs: complexType> xs: element> d) constraints of Mixed Content (Restriction) I. Example: Schema: xs: kice> xs: restriction> xs: complextence> xs: complexType> xs: element> e) Mutual extension between Complex Content Complex Type and Mixed Content Complex Type Complex -> Mixed (e) forbidden Mixed -> Complex (e) forbidden Complex -> Mixed (R) Forbidden Mixed -> Complex (R) OK 5. EMPTY Content Complex Type a) Description: We can define the EMPTY Content by prohibiting the text content in Simple Content Complex Type, and the other is to appear by prohibiting the elements in Complex Content Complex Type. b) Define EMPTY Content by Simple Content I. Example: Schema: xs: simplecontent> xs: complexType> xs: element> c) Define EMPTY Content by Complex Content I. Example: Schema: xs: element> d) Extend and restrain the EMPTY Content based on Simple Content Since it is scheduled based on Simple Content, we can increase the extra properties when expanding, and the content of the text can be constrained during constraints. e) Extend and restrain the Empty Content based on Complex Content Since it is based on Complex Content, we can add additional properties and elements when expanding. Constraints can constrain the contents and elements. 6. XML document structure abstraction: Note: The structure of the XML document is from abstraction, which is a combination relationship between E (element node), a (attribute node), T (text node). According to the characteristics of these nodes, their relationship can only be characterized by the following: attribute definition (a); empty element node (E ()); element node contains attribute nodes (e (a)); element node contains text Node (e (t)); element node contains element nodes (e)); element nodes contain elements nodes and text nodes (e (a, t)); element nodes contain elements nodes and attribute nodes (E (E, A)); element node contains element nodes and text nodes (e (e, t)); element nodes contain element nodes, attribute nodes, and text nodes (E (E, A, T)). The role of DTD and Schema is to define the rules of the combination relationship in this 9. 7. Attribute definition (a) a) Syntax: Default = String Fixed = String Form = (Qualified | Uqualified) ID = ID Name = ncname Ref = QNAME TYPE = QNAME Use = (optional | prohibited | required): Optional > Content: (Annotation ?, simpleType?) attribute> b) example: 8. Empty element node (e ()) a) Syntax: Using EMPTY Content Complex Type b) example: xs: element> 9. Element nodes contain attribute nodes (e (a)) a) Syntax: Using EMPTY Content Complex Type b) example: xs: complexType> xs: element> 10. Element node contains text nodes (e (t)) a) Syntax: Use Simple Content Complex Type b) example: xs: simplecontent> xs: complexType> xs: element> 11. Element node contains element nodes (e (e)) a) Syntax: Using Complex Content Complex Type b) example: xs: kice> xs: sequence> xs: complextence> xs: complexType> 12. Element nodes contain elements nodes and text nodes (e (a, t)) a) Syntax: Use Simple Content Complex Type b) example: xs: extension> xs: simplecontent> xs: complexType> xs: element> 13. Element nodes contain elements nodes and attribute nodes (e (e, a)) a) Syntax: Using Complex Content Complex Type b) example: xs: sequence> xs: complexType> xs: element> 14. Element nodes contain elements nodes and text nodes (e (e, t)) a) Syntax: Using Mixed Content Complex Type b) example: xs: kice> xs: complexType> xs: element> 15. Element nodes contain elements nodes, attribute nodes, and text nodes (e (e, a, t)) a) Syntax: Using Mixed Content Complex Type b) example: xs: kice> xs: complexType> xs: element>