Application of XML to custom controls under. NET Platform (2)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.