以文本方式查看主题 - 计算机科学论坛 (http://bbs.xml.org.cn/index.asp) -- 『 DTD/XML Schema 』 (http://bbs.xml.org.cn/list.asp?boardid=23) ---- XML Schema嵌套问题 (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=69099) |
-- 作者:icegreatgood -- 发布时间:11/4/2008 6:00:00 PM -- XML Schema嵌套问题 我有这样一相需求,不知能否实现? 这个xsd生成的对应xml如下 <?xml version="1.0" encoding="utf-8"?> <configuration name='第一层'> <token name="token1" value="1" /> <configuration name='第二层'> <token name="token1" value="2" /> <configuration name='第三层'> <token name="token1" value="3" /> <configuration name='第四层'> <token name="token1" value="3" /> 第五层,六层.......依次类推,层次会有终点,但不确定是多少层. </configuration> </configuration> </configuration> </configuration> 请问根据这样一个xml,能实现出一个这样具有嵌套层次xsd文件吗?不想写成有几层就写几层xsd的那种,希望写成向编程里循环类似的xsd ? |
-- 作者:icegreatgood -- 发布时间:11/5/2008 10:10:00 AM -- 自己解决了, <xs:element name="configuration"> <xs:complexType> <xs:sequence> <xs:element name="token" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="name" type="xs:string"/> <xs:attribute name="value" type="xs:string"/> </xs:complexType> </xs:element> <xs:element minOccurs="0" maxOccurs="unbounded" ref="configuration" /> </xs:sequence> <xs:attribute name="name" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema> |
-- 作者:goukili -- 发布时间:12/1/2008 6:57:00 PM -- <xs:element minOccurs="0" maxOccurs="unbounded" ref="configuration" /> 指向自身父元素的定义,实现递归,不错,学了一招。 |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
46.875ms |