As we can see in XML, the syntax of the DTD is quite complex, and it does not conform to the standard of the XML file and becomes a system. This means that the DTD document itself is not a well-formed XML document, and the above introduction to DTDs is simply an introduction to help you read the DTD file and create a simple DTD file if necessary, because many XML applications are now built on DTDs.
Another alternative to the DTD is the schema,schema of the definition of the consortium. Literally, it translates into patterns, outlines, plans, planning, and so on. Its basic meaning is to develop a schema for the XML document.
The obvious benefit of schema relative to DTDs is that the XML Schema document itself is also an XML document, rather than using self-contained syntax like a DTD. This facilitates both users and developers, because you can use the same tools to process XML schemas and other XML information without having to use special tools specifically for schemas. Schemas are straightforward, and people who know the syntax and rules of XML can immediately understand it. The concept of schema has been proposed for a long time, but the standards of the consortium have only recently come out, the corresponding application support has not been perfected, but the adoption of schema has become a trend of XML development.
First, let's start with the simplest examples to learn the syntactic structure of a schema:
For example, a simple XML document is as follows:
< Books >
< name > Tianya Moon Knife
< Author > Cologne
If you define the structure of the XML document in the form of a DTD, you can do the following:
So how do you define it in the form of a schema? See the following code:
£
It is important to note that in the schema, the definition of elements and the definition of element relationships are implemented to define the nature and content of the entire document. It is also important to note that in the schema, the element is determined by its name and the content model, and the name is the name of the element, which is understandable, and the content model is actually the type that represents the element. As in C + +, we can arbitrarily define a variable, but must define the type of the variable, the type of the variable may have many forms, it can be a simple variable (such as C + + internal specified type, Bool,int,double,char, etc.), It can also be a very complex type (for example, a struct or class), as is the case in a schema, where types (type) can be divided into two forms, a very simple type, called simplicity, a complex type called complex. A simple type cannot contain elements and attributes (note that, as in schemas and DTDs, there are element attributes, the boulevard is the same). Complex types can contain not only attributes, but other elements in them, or can be associated with properties in other elements.