• 您的位置我爱Aspx >> XML/XLST >> XML在.net平台下的自定义控件的应用(2)
  • XML在.net平台下的自定义控件的应用(2)

  • 作者:aspxer  来源:internet  日期:2007-5-6 11:38:45  关键字:.net,xml
  • 第二步,就是加入XML特性

    注意,任何xml文档在其被处理之前最好先进行有效性验证,提供验证一般有两种重要的途径。其一就是提供DTD(文档类型定义),实际上就是让用户提供指令集,然后在xml文档加载的时候对其进行有效性分析,看是否有无效指令,简单说就是创建一个编译环境;另外一个就是提供一个所谓的schema。.其作用跟DTD完全一样,只是在表现形式上好于DTD,因为它本身也是一个XML文档。这里我采用了schema的形式,当然了,读者用兴趣也可以将其替换问相应的DTD版本。下面列出该schema的关于控件和topmenu对象的代码,如果要看该文档的详细代码,请看 “代码.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"/>

    我对这篇文章有话说?
  • 广告位招租,广告代号:content_468_15
  • 上一篇:使用DOM创建XML
    下一篇:XML在.net平台下的自定义控件的应用(1)