xsd: choice groups of attributes



what i made wrong? xls:



<note>
<element action="SomeAction" id="1" />
</note>


xsd:



<xs:element name="note">
<xs:complexType>
<xs:choice minOccurs ="0">
<xs:group ref="with_attr" />
<xs:group ref ="without_attr" />
</xs:choice>
</xs:complexType>
</xs:element>
<xs:group name="with_attr">
<xs:sequence >
<xs:element name="element">
<xs:complexType>
<xs:attributeGroup ref="actionattrib" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:group name="without_attr">
<xs:sequence >
<xs:element name="element">
<xs:complexType>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:attributeGroup name ="actionattrib">
<xs:attribute name="action" type="action_value" use="required"/>
<xs:attribute name="parameter" type="id_value" use="required"/>
</xs:attributeGroup>
<xs:simpleType name="action_value" >
<xs:restriction base="xs:token">
<xs:enumeration value="SomeAction"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="id_value" >
<xs:restriction base="xs:token">"
<xs:enumeration value="1"/>
</xs:restriction>
</xs:simpleType>


i try to make rule that element note can contains element <element> with attributes action and id that will be have value from list, or element without any attributes will be correct too, but element cant contain other attributes or only one of attributes id or action. Error is : Attribute action is not allowed here


No comments:

Post a Comment