Schema里会限制元素的出现顺序的.如下: a,b,c的出现个数可以是0到无限,但是b后面不能够出现a,c后面不能够出现a或者b,
而a的前面则不能光出现b或者c.推荐xmlspy,像我这样不懂的人都可以轻松写schema文件.<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="roote">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="a" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="b" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="c" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
解决方案 »
- s2sh整合时报500 Unable to instantiate Action, loginAction, defined for 'login' in n
- 推荐java几本书籍!
- 新手请教关于FileInputStream的问题
- java和asp 可以共享session么?
- 名字相同的checkbox问题
- 在BufferedInputStream和BufferedOutputStream读写文件的问题
- 关于hibernate中的cascade的含义疑惑
- 这段关于反射的代码为啥出错? 谢谢!
- 在Weblogic7+JBuilder7中怎么使用EJB QL?
- 关于事务的问题
- Mastering EJB 2E.中一个关于RMI-IIOP的问题
- 一个送分问题~
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="roote">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="root" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="a" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="b" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="c" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
sample xml:-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSPY v2004 rel. 4 U (http://www.xmlspy.com)-->
<roote xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="E:\jb\Untitled1.xsd">
<root>
<a>Text</a>
<a>Text</a>
<b>Text</b>
<c>Text</c>
<c>Text</c>
</root>
<root>
<a>Text</a>
<a>Text</a>
<b>Text</b>
<b>Text</b>
<c>Text</c>
<c>Text</c>
</root>
<root>
<b>Text</b>
<b>Text</b>
<c>Text</c>
</root>
</roote>
但是XML Schema规定,使用all后 元素不能重复了。这样也不合楼主的要求。
相比之下,还是用sequence吧。
因为你可以生成xml的地方可以用代码控制顺序后再输出
choice min=0 max=unbound