Enforcing attribute value uniqueness within a given tag, not necessarily across the whole file

42 Views Asked by At

I'd like to validate an XML file against XSD 1.0 and require the values of one attribute to be unique within that one element, but allowing duplicates in different tags.

For exemple, I'd like the attribute (det) not to contain repetitions within each <Client> tag, but I'd like to allow the attribute to have duplicates in different clients.

So, I'd like to have the snipped below to be valid...

<Client id="1">
  <RiscSoc det="01" av="01"/>
  <RiscSoc det="02" av="02"/>
  <RiscSoc det="99" av="02"/>
</Client>

<Client id="2">
  <RiscSoc det="01" av="01"/>
  <RiscSoc det="02" av="02"/>
  <RiscSoc det="99" av="02"/>
</Client>

... but not this one below:

<Client id="1">
  <RiscSoc det="01" av="01"/>
  <RiscSoc det="01" av="02"/>
</Client>

Can that be done with XSD 1.0 (which is the version used in the software I have available)? How?

I've done considerable searching but I can only find examples of unique and primary keys to enforce uniqueness across the whole XML file.

Thanks!!

0

There are 0 best solutions below