首 页 ┆ 源码下载 ┆ IT学院 ┆ 字体下载 ┆ 模板下载 ┆ 源码发布 ┆ 广告合作 ┆ 网站地图 ┆ 虚拟主机 ┆ 中文域名
► 设为首页
► 加入收藏
► 联系我们
源码下载 >> ASP源码 | PHP源码 | ASP.net源码 | JSP源码 | CGI源码 | VC/C++源码 | VB源码 | Delphi源码 | Flash源码
文章学院 >> 网络编程 | 网页设计 | 图形图象 | 数据库 | 服务器 | 网络媒体 | 网络安全 | 操作系统 | 办公软件 | 软件开发 | 黑客知识
字体下载 >> 精制字体 | 非英字体 | 艺术字体 | 著名字体 | 哥特式 | 简单字体 | 手写体 | 节假日 | 图案字体 | 精度像素 | 中文字体
模板下载 >> 企业门户 | 数码网络 | 休闲娱乐 | 影视音乐 | 旅游名胜 | 文化艺术 | 电子商务 | 个性展示 | 登陆导航 | Flash模板
►►您当前的位置:源码园 → IT学院 → 网络编程 → XML专区 → 文章内容

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

作者:郁郁小蝎  来源:中国站长学院  发布时间:2007-2-6 16:46:51
第二步,就是加入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)

  • 相关文章:
  • 活用2003的“分区增容”功能
  • XML在.net平台下的自定义控件的应用(3)
  • XML在.net平台下的自定义控件的应用(2)
  • XML在.net平台下的自定义控件的应用(1)
  • XML在B/S架构开发中的应用
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 源码发布
Copyright © 2003-2009 Ymyasp.Com. All Rights Reserved .
备案序号:粤ICP备07029071号