Im making a small xsd/xml file for a restaurant based system.

Here is the code that i have for my XSD file:

<xs:element name="table_cat">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="category" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence maxOccurs="unbounded">
              <xs:element name="category_id" type="CatID" />
              <xs:element name="catdescription" type="Length50"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>

    <xs:unique name="unique-catid">
      <xs:selector xpath="category" />
      <xs:field xpath="category_id"/>

    </xs:unique>

  </xs:element>

but whenever i have more than 1 Category_ID field in the XML file i keep getting the following error:

The field 'category_id' is expecting at the most one value.

Ive tried different solutions to make it work but nothing seems to work.

Hope you can help Thanks!

Have you tried making it a key instead. Replace <xs:unique> with <xs:key>.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.