The second step is to add XML features
Note that any XML document is best validated before it is processed, and there are generally two important ways to provide validation. The first is to provide a DTD (document type definition), in fact, let the user provide the instruction set, and then in the XML document when loading the validity analysis, to see whether there are invalid instructions, simply to create a compilation environment; the other is to provide a so-called schema. It works exactly like a DTD. , it is better than a DTD in its presentation, because it is an XML document itself. Here I take the form of a schema, and of course, the reader can replace it with interest by asking the appropriate DTD version. The following lists the schema's code for controls and Topmenu objects, and if you want to see the detailed code for that document, see Code. doc.
MENU.XDR:
<?xml version= "1.0" encoding= "UTF-8"?
<schema name= "Menus" xmlns= "Urn:schemas-microsoft-com:xml-data" xmlns:dt= "Urn:schemas-microsoft-com:datatypes"
<description>
Menus schema used to validate Menu.xml
</description>
<elementtype name= "menu" model= "closed" content= "empty"
<attributetype name= "id" dt:type= "string" required= "Yes"/>
<atttibute type= "id"/>
<element name= "Topmenu" model= "closed" minoccurs= "0" maxoccurs= "*" content= "empty"/>
</ElementType>
<elementtype name= "Topmenu" model= "closed" content= "empty"
<attributetype name= "id" dt:type= "string" required= "Yes"/>
<attributetype name= "Text" dt:type= "string" required= "Yes"/>
<attributetype name= "Linkurl" dt:type= "string" required= "Yes"/>
<attributetype name= "Isparent" dt:type= "string" required= "Yes"/>
<atttibute type= "id"/>
<atttibute type= "text"/>
<atttibute type= "Linkurl"/>
<atttibute type= "Isparent"/>
<element name= "submenu" model= "closed" minoccurs= "0" maxoccurs= "*" content= "empty"/>
</ElementType>
<elementtype name= "submenu" model= "closed" content= "empty"
<attributetype name= "id" dt:type= "string" required= "Yes"/>
<attributetype name= "Text" dt:type= "string" required= "Yes"/>
<attributetype name= "Linkurl" dt:type= "string" required= "Yes"/>
<attributetype name= "Isparent" dt:type= "string" required= "Yes"/>
<atttibute type= "id"/>
<atttibute type= "text"/>
<atttibute type= "Linkurl"/>
<atttibute type= "Isparent"/>
<element name= "Childrenmenu" model= "closed" minoccurs= "0" maxoccurs= "*" content= "empty"/>
</ElementType>
<elementtype name= "Childrenmenu" model= "closed" content= "empty"
<attributetype name= "id" dt:type= "string" required= "Yes"/>
<attributetype name= "Text" dt:type= "string" required= "Yes"/>
<attributetype name= "Linkurl" dt:type= "string" required= "Yes"/>
<attributetype name= "Isparent" dt:type= "string" required= "Yes"/>
<atttibute type= "id"/>
<atttibute type= "text"/>
<atttibute type= "Linkurl"/>
<atttibute type= "Isparent"/>
<element name= "MenuItem" model= "closed" minoccurs= "0" maxoccurs= "*" content= "empty"/>
</ElementType>
<elementtype name= "MenuItem" model= "closed" content= "empty"
<attributetype name= "id" dt:type= "string" required= "Yes"/>
<attributetype name= "Text" dt:type= "string" required= "Yes"/>
<atttibute type= "id"/>
<atttibute type= "text"/>
</ElementType>
</Schema>
If you are familiar with HTML, it should be clear that the above code, even if it has not been contacted before, in. XDR, there are two objects, one of which is the element, defined by the prefix ElementType, and the other is the corresponding attribute of the element, prefixed with a atttibutetpye, After the two objects are defined, they are instantiated, with the corresponding prefixes of element and atttibute, and then you can use both of the objects that have already been instantiated, as in HTML , , , , and so on.