以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  [已解决]子节点内容不确定时,如何写schema  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=45887)


--  作者:wanghaiyang
--  发布时间:4/24/2007 9:01:00 AM

--  [已解决]子节点内容不确定时,如何写schema
<?xml version="1.0" encoding="UTF-8"?>
<item name="love" parentitem="">
<att datatype="title" name="lovetitle">Love</att>
<att datatype="dropdown" name="art" size="5" multiple="multiple">
  <att datatype="option" name="book" value="book">
   <ctrldata>
    <poem value="poem">
     <jone value="jone"/>
    </poem>
   </ctrldata>
  </att>
  <att datatype="option" name="painting" value="painting" selected="selected"/>
</att>
</item>
其中ctrldata下面的内容不确定,我不知道如何写对应的schema,请高手帮帮忙!


[此贴子已经被作者于2007-4-27 20:56:05编辑过]

--  作者:gemingke
--  发布时间:4/24/2007 2:08:00 PM

--  
ctrldata下面,使用any的安anyattribute来替代
--  作者:wanghaiyang
--  发布时间:4/24/2007 5:15:00 PM

--  
非常感谢gemingke !!问题已解决.
相关参考连接:
http://bbs.xml.org.cn/dispbbs.asp?boardID=23&ID=24712
http://www.frontfree.net/view/article_751.html

test03.xml
<?xml version="1.0" encoding="UTF-8"?>
<item name="love" parentitem="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test03.xsd">
 <att datatype="title" name="lovetitle">Love</att>
 <att datatype="dropdown" name="art" size="5" multiple="multiple">
  <att datatype="option" name="book" value="book">
   <ctrldata>
    <poem value="poem">
     <jone value="jone"/>
    </poem>
    <poem value="poem">
     <jone value="jone"/>
    </poem>
   </ctrldata>
  </att>
  <att datatype="option" name="painting" value="painting" selected="selected"/>
 </att>
</item>

test03.xsd
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--W3C Schema 由 XMLSpy v2006 U 创建 (http://www.altova.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
 <xs:element name="att">
  <xs:complexType mixed="true">
   <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="att"/>
    <xs:element ref="ctrldata"/>
   </xs:choice>
   <xs:attribute name="datatype" type="xs:string" use="required"/>
   <xs:attribute name="name" type="xs:string" use="required"/>
   <xs:attribute name="size" type="xs:byte"/>
   <xs:attribute name="multiple" type="xs:string"/>
   <xs:attribute name="value" type="xs:string"/>
   <xs:attribute name="selected" type="xs:string"/>
  </xs:complexType>
 </xs:element>
 <xs:element name="ctrldata">
  <xs:complexType>
   <xs:sequence>
    <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:element name="item">
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="att" maxOccurs="unbounded"/>
   </xs:sequence>
   <xs:attribute type="xs:string" name="name" use="required"/>
   <xs:attribute name="parentitem" type="xs:string" use="required"/>
  </xs:complexType>
 </xs:element>
</xs:schema>


注意:<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>中的 processContents="skip"不能少


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
78.125ms