中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > Web开发 > XML
XML在.net平台下的自定义控件的应用(2)
作者:未知 时间:2005-04-19 12:12 出处:ChinaZ.com 责编:chinaitpower
              摘要:暂无
第二步,就是加入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>等标记一样。
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有