M
Mario
Hi,
I want to use a unique ID attribute, which should be an integer value.
I tried the solution below with xpath, but the xml seems to be valid,
even if there are two equal ids. Any idea why?
My XSD
---------------------------------------------------------------------
<xs:element name="sample">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="one" maxOccurs="10">
<xs:complexType>
<xs:attribute name="anothertxt" type="xs:string"/>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="two" maxOccurs="10">
<xs:complexType>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="three" maxOccurs="10">
<xs:complexType>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="seqid">
<xs:selector xpath=".//sample"/>
<xs:field xpath="@sequenceid"/>
</xs:key>
</xs:element>
---------------------------------------------------------------------
My XML
---------------------------------------------------------------------
<sample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sample.xsd">
<one sequenceid="1"/>
<one sequenceid="2"/>
<two sequenceid="3"/>
<two sequenceid="3"/>
</sample>
---------------------------------------------------------------------
I want to use a unique ID attribute, which should be an integer value.
I tried the solution below with xpath, but the xml seems to be valid,
even if there are two equal ids. Any idea why?
My XSD
---------------------------------------------------------------------
<xs:element name="sample">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="one" maxOccurs="10">
<xs:complexType>
<xs:attribute name="anothertxt" type="xs:string"/>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="two" maxOccurs="10">
<xs:complexType>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="three" maxOccurs="10">
<xs:complexType>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="seqid">
<xs:selector xpath=".//sample"/>
<xs:field xpath="@sequenceid"/>
</xs:key>
</xs:element>
---------------------------------------------------------------------
My XML
---------------------------------------------------------------------
<sample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sample.xsd">
<one sequenceid="1"/>
<one sequenceid="2"/>
<two sequenceid="3"/>
<two sequenceid="3"/>
</sample>
---------------------------------------------------------------------