开发者

XSD any element

I'm trying to create a list that some of the elements are defined and some are not, without priority to order. I tried it this way, with an any element:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:complexType name="object" mixed="true">
  <xs:choice>
    <xs:element name="value" minOccurs="1" maxOccurs="1">
    <xs:simpleType>
     <xs:restriction base="xs:integer">
      <xs:enumeration value="1"/开发者_StackOverflow中文版>
     </xs:restriction>
    </xs:simpleType>
 </xs:element>    
 <xs:any namespace="##any" processContents="skip"/>  
  </xs:choice>
</xs:complexType>

<xs:element name="object" type="object"/>

</xs:schema> 

And it tells me this error:

:0:0: error: complex type 'object' violates the unique particle attribution rule in its components 'value' and '##any'

Can someone help me out solve the problem?


You cannot define your schema like that, it violates the unique particle attribution rule: the parser cannot tell whether a "value" element it finds in the document should be validated against "value" or against "any".

Here is a good overview.

Consider using two namespaces and using xsd:any with a namespace, this will remove the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜