What is a valid XML document?
If an XML document specifies the DTD or schema of its document type and data structure and is associated with it, and the validation is correct.
Use DTD to define XML elements <! Element element name element content declaration>
Expression symbol and its definition:
() Is used to group elements | select a number of + 1-N times * 0-N times in the listed objects? 0-1, appears sequentially
Element content type:
Empty empty flag any element content # pcdata any character data other type
Use DTD to define attributes of XML elements <! ATTLIST element name attribute type default value>
Attribute type and its meaning:
CDATA can only contain the unique entity of character data IDs. Entities declared in the Entities document but not analyzed
Nmtoke and nmtokens are a subset of CDATA. They must contain letters, numbers, periods, passbooks, underscores, or colons.
Notation (enumerated) Notation (beauty | beast)
Enumerated enumeration (1 | 2 | 3 | 4 ...)
Four forms of default attribute values # required cannot be blank # mplied can be blank # fixed value must be the default value of defaultvalue in the value specified for listing
Association between TDT and XML
1. Internal DTD <! Doctype name [...]
2. External DTD <! Doctype root element name system "dtd_url"
3. Public dish DTD <! Doctype root element name public "DTD name" "dtd_url"]
Use DTD to define XML entities <! Entity write "Jan Egil">
External entity <! Entity Write System "http...">
Namespace: xmlns: [prefix] = "[namespace url]"
Limitations of DTD:
1. DTD does not comply with XML syntax 2. DTD cannot be expanded 3. DTD does not support namespace applications 4. DTD does not provide powerful data type support and can only represent simple data types
Schema
Features: 1. fully Based on XML syntax 2. it can be used to process XML. 3. greatly expanded the Data Type 4. support prototype, that is, inherit 5. support Attribute Group 6. multiple schemas can be used in an XML document.
Pre-defined type string Boolean decimal float double duration represents the duration datetime represents the specific time date hexbinary hexadecimal anyurl notation type
Schema elements are mainly divided into simple types and complex types, which can only contain characters of simple types, and other complex types.
The schema document uses <schema> as its root element.
Element tags in the schema document
Schema element attribute simpletype complextype group attributegroup simplecontent choice list Union unique squence Restriction
Define simple type elements <XSD: element name = "element name" type = "type"/>
Define complex type elements <XSD: element name = "element name"> <XSD: complextype> <XSD: sequence> ordered
Using the ref element, you can direct it to another module to make the document more readable.
Defines the number of identical child elements masoccurs = "unbounded" borderless minoccurs
Define an optional sub-element <XSD: Choice> A | B?
Custom type <XSD: Restriction base = "XD: string"> <XSD: Pattern value = "Regular Expression"/>
Enumeration type <XSD: Restriction base = "XD: string"> <XSD: enumeration value = ""/>
Define attributes:
<XSD: attribute name = "ID" type = "XSD: string"/>
Property optional use = "required" required is required value optional is optional value prohibited is no Attribute Value
Define default value default = "1"