动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Xml → 阅读文章

 XML在.net平台下的自定义控件的应用(2)

作者:郁郁小蝎 来源:中国站长学院 
阅读 2488 人次 , 2006-2-15 14:33:00 

第二步,就是加入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"/>

<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>

如果您对html比较熟悉的话,相信上面的代码即使是以前没有接触过也应该清楚了,在.xdr中,有两个对象,其一是元素,用前缀 ElementType 来定义,另外一个是该元素所对应的属性,用前缀atttibuteTpye,定义完这两个对象后,就是要将它们实例化,对应的前缀分别是Element 和atttibute,然后您就可以使用这两种已经实例化了的对象,就象使用html中<a>,<l>,<body>,<head>等标记一样。
  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:XML在.net平台下的自定义控件的应用(1)
· 下一篇:XML在.net平台下的自定义控件的应用(3)
· XML的严格格式
· XML简明教程第5课:使用XML名域
· 了解WEB页面工具语言XML(四)应用分类
· XML加ASP实现网页“本地化”
· XML数据库中几个容易混淆的概念


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077