xml-d~ix.htm

来自「这是一本关于XML的学习的书」· HTM 代码 · 共 811 行 · 第 1/5 页

HTM
811
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>XML-Data Schema指南 </TITLE>
<META content="text/html; charset=gb_2312-80" http-equiv=Content-Type>
<META content="MSHTML 5.00.2014.210" name=GENERATOR><link rel="stylesheet" href="../../Global.css" tppabs="http://www.xml.org.cn:8188/Global.css"></HEAD>
<BODY bgColor=#ffffff>
<TABLE border=0 cellPadding=5 cellSpacing=3 width="90%">
  <TBODY>
  <TR>
    <TD height="12916"> </TD>
    <TD vAlign=top height="12916"> 
      <table width="31%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="64%" height="23"><a href="../resource.htm" tppabs="http://www.xml.org.cn:8188/resource/resource.htm" target="_parent"><font size="-1" class="normal9">返回学习&amp;研究</font> 
            </a></td>
          <td width="36%" height="23"><a href="../../../icdserver/default.htm" tppabs="http://icdserver:8080/default.htm" target="_parent"><font size="-1"><span class="normal9">返回首页</span></font></a> 
          </td>
        </tr>
      </table>
      <br>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="62">
        <tr align="center" valign="middle"> 
          <td> <font color=#009900 face=ARIAL,VERDANA,HELVETICA 
      size=5><b> <font color="#000000">XML-Data </font></b></font><font color="#000000" size="5"><b>Schema指南 
            </b></font><font color=#009900 
      size=5><b><br>
            </b></font>
            <table width="50%" border="0" cellspacing="0" cellpadding="0">
              <tr align="center" valign="middle"> 
                <td><span class="normal105">翻译:<a href="mailto:onecenter@yahoo.com">孙一中</a></span><font face="宋体" lang="ZH-CN" size=5></font></td>
              </tr>
            </table>
            
          </td>
        </tr>
      </table>
      <P align=center><FONT color=#009900 
      size=5><B> </B></FONT></P>
      <P><FONT face=黑体 size=2><I class="normal105">状态: 初稿,Andrew,1999年5月25日, 未经核实和测试</I></FONT></P>
      <P><FONT face=黑体 size=2><I class="normal105">Andrew Layman, Microsoft.</I></FONT></P>
      <P><FONT size=2><span class="normal105"><span class="normal105">本文描述了微软IE5.0的MSXML解析器已经实现的XML-Data 
        大纲(Schema)语言的特点.XML-Data是描述XML文荡和部件类的词库,即定义 XML元素类型,属性类型以及将其组合成文档(或部分文档).本文是其特点的指南和向导;<span class="normal105">在<span class="normal105"> 
        </span></span></span></span></FONT><span class="normal105"><span class="normal105"><span class="normal105"><A 
      href="../../../msdn.microsoft.com/xml/XMLGuide/schema-overview.asp" tppabs="http://msdn.microsoft.com/xml/XMLGuide/schema-overview.asp"><FONT 
      size=2>http://msdn.microsoft.com/xml/XMLGuide/schema-overview.asp</FONT></A><FONT 
      size=2> </FONT></span><FONT 
      size=2><span class="normal105">有更详细的资料以及明确规范.</span></FONT></span><FONT 
      size=2> </FONT></span></P>
      <P><FONT 
      size=2 class="normal105">大纲的目的是定义一套XML元素、属性和组合规则集.因此,大纲都包括元素和/或属性的定义,通常还有一些限制,即规定在何种情况下、怎样的元素和属性能以何种方式结合使用.</FONT></P>
      <P><FONT 
      size=2 class="normal105">XML-Data本身只是一套元素和属性.我们将进行说明,并演示如何使用它们.首先从一个XML文档开始.</FONT></P>
      <DIR>
        <LI><span class="normal105"><FONT face="Courier New" size=1><span class="normal105">&lt;PurchaseOrder&gt;</span></FONT> 
          </span> 
          <P><span class="normal105"><FONT face="Courier New" size=1><span class="normal105">&lt;shipTo&gt;</span></FONT></span></P>
          <P><span class="normal105"><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;name&gt;Alice 
            Smith&lt;/name&gt;</FONT></span></span></P>
          <P><span class="normal105"><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;street&gt;123 
            Maple Street&lt;/street&gt;</FONT></span></span></P>
          <P><span class="normal105"><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;city&gt;Mill 
            Valley&lt;/city&gt;</FONT></span></span></P>
          <P><span class="normal105"><span class="normal105"><FONT face="Courier New" 
size=1 class="normal105">&lt;state&gt;CA&lt;/state&gt;</FONT></span></span></P>
          <P><span class="normal105"><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;zip&gt;90952&lt;/zip&gt;</FONT></span></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;/shipTo&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" 
      size=1 class="normal105">&lt;orderDate&gt;1999-05-20&lt;/orderDate&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" 
      size=1 class="normal105">&lt;shipDate&gt;1999-05-25&lt;/shipDate&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;comments&gt;Get 
            these things to me in a hurry, my lawn is going wild!&lt;/comments&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;Items&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;Item&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;productName&gt;Lawnmower, 
            model BUZZ-1&lt;/productName&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" 
      size=1 class="normal105">&lt;quantity&gt;1&lt;/quantity&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" 
      size=1 class="normal105">&lt;price&gt;148.95&lt;/price&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;/Item&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;Item&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;productName&gt;Baby 
            Monitor, model SNOOZE-2&lt;/productName&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" 
      size=1 class="normal105">&lt;quantity&gt;1&lt;/quantity&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" 
      size=1 class="normal105">&lt;price&gt;39.98&lt;/price&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;/Item&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;/Items&gt;</FONT></span></P>
          <P><span class="normal105"><FONT face="Courier New" size=1><span class="normal105">&lt;/PurchaseOrder&gt;</span></FONT><span class="normal105"><FONT 
      size=2> </FONT></span></span></P>
        </LI></DIR>
      <P><FONT size=2 class="normal105">就这个文档,让我们用它来看看XML-Data大纲中的一些特点.</FONT></P>
      <P><B><I><span class="normal105">大纲 </span> </I></B></P>
      <P><FONT 
      size=2 class="normal105">一个XML-Data大纲包括一<I>Schema</I>元素,其中是该特定大纲的具体定义.空的大纲是这样的:</FONT></P>
      <DIR> 
        <LI><span class="normal105"><span class="normal105"><span class="normal105"><FONT face="Courier New" size=1><span class="normal105">&lt;Schema 
          xmlns="urn:schema-microsoft-com:xml-data" xmlns:dt="urn:schema-microsoft-com:datatypes"&gt;</span></FONT></span></span></span><span class="normal105"><FONT face="Courier New" size=1><BR>
          <span class="normal105">&lt;/Schema&gt;</span></FONT><span class="normal105"><FONT 
      size=2> </FONT></span></span></LI>
      </DIR>
      <P><FONT 
      size=2><span class="normal105"><span class="normal105">大纲的元素名表明这是一个大纲</span>."<span class="normal105">xmlns</span>"<span class="normal105">是一个特殊的信息项,称为"名域声明".它标明大纲元素由称作"urn:schemas-microsoft-com:xml-data"的规范明确定义,因而有别于其它任何类似名称的元素 
        .(并不可能象"schema</span>"<span class="normal105">这样的特殊名字都需要该分类,但许多普通的名称需要.以后我们将更详尽地讨论名域声明的作用.)</span></span></FONT><span class="normal105"><span class="normal105"><FONT 
      face=Arial><B><I> </I></B></FONT></span></span></P>
      <P><B><I class="normal105">元素</I></B></P>
      <P><FONT size=2 class="normal105">订购单包括几种元素. <I>ElementType</I>是定义它们的机制.例如,我们能够定义一个简单元素类型:"street" 
        :</FONT></P>
      <DIR>
        <LI><FONT face="Courier New" size=1><span class="normal105">&lt;ElementType 
          name="street" /&gt;</span></FONT><span class="normal105"><FONT size=2> 
          </FONT></span></LI>
      </DIR>
      <P><FONT 
      size=2 class="normal105">更复杂的元素不仅仅包括文字;它们可能包括特定形式的文本或者包含其它元素的文本.在本例中,我们想规定"shipDate"元素为日期.我们可以这样写</FONT></P>
      <DIR>
        <LI><FONT face="Courier New" size=1 class="normal105">&lt;ElementType name="orderDate" 
          dt:type="date" /&gt;</FONT> </LI>
      </DIR>
      <P><FONT size=2><span class="normal105">你在</span></FONT><span class="normal105"><span class="normal105"><A 
      href="../../../msdn.microsoft.com/xml/xmlguide/schema-datatypes.asp" tppabs="http://msdn.microsoft.com/xml/xmlguide/schema-datatypes.asp" 
      target=new_window><FONT 
      size=2>http://msdn.microsoft.com/xml/xmlguide/schema-datatypes.asp</FONT></A></span><FONT 
      size=2 class="normal105">可以发现一系列的数据类型,如日期、时间、数字、二进制等格式. </FONT></span></P>
      <P><FONT size=2 class="normal105">我们在元素的定义中引用了其他的适当的元素类型,使"shipTo"元素包括其他元素.例如, 
        </FONT></P>
      <DIR>
        <LI><FONT face="Courier New" size=1 class="normal105">&lt;ElementType name="shipTo" 
          /&gt;</FONT> 
          <P><FONT face="Courier New" size=1><span class="normal105">&lt;element 
            type="name" /&gt;</span></FONT></P>
          <P><span class="normal105"><FONT face="Courier New" size=1 class="normal105">&lt;element 
            type="street" /&gt;</FONT></span></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="city" 
            /&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="state" 
            /&gt;</FONT></P>
          <P><FONT face="Courier New" size=1><span class="normal105">&lt;element type="zip" 
            /&gt;</span></FONT></P>
          <P><span class="normal105"><FONT face="Courier New" 
      size=1 class="normal105">&lt;/ElementType&gt;</FONT></span></P>
        </LI></DIR>
      <P><FONT size=2 class="normal105">这表示每当"shipTo"元素出现,其中必须有五个子元素,依次是name, 
        street, city, state and zip.当然, 我们需要在此之前就定义他们.我们这样做:</FONT></P>
      <DIR>
        <LI><FONT face="Courier New" size=1 class="normal105">&lt;schema xmlns="urn:schema-microsoft-com:xml-data"</FONT> 
          <P><FONT face="Courier New" 
      size=1 class="normal105">xmlns:dt="urn:schema-microsoft-com:datatypes"&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;ElementType name="PurchaseOrder"&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="shipTo"/&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="orderDate"/&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="shipDate"/&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="comments" 
            /&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="Items"/&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;/ElementType&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;ElementType 
            name="shipTo" /&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="name" 
            /&gt;</FONT></P>
          <P><FONT face="Courier New" size=1 class="normal105">&lt;element type="street" 
            /&gt;</FONT></P>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?