xml traduce IDREFS in xml schema

33 Views Asked by At

I need to know if there is a way to create in a XML schema something similar but more strong then IDREFS without using the IDREFS type. I need an attribute that is a list of keyref.

  1. I define a key
  2. I define a keyref
  3. How to proceed now? I need to define an attribute that is a sort of list of keyref

Example:

 myAttribute = "keyref1 keyref2 keyref3 ..." and so on

Remember: With IDREFS I cannot create a list of referenced items.

1

There are 1 best solutions below

0
Michael Kay On

No, unfortunately keyrefs can only select nodes, not tokens within the values of a node.

To implement this kind of constraint you can use XSD 1.1 assertions:

<xs:element name="employees">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="employee" maxOccurs="unbounded"/>
    </xs:sequence>

    <xs:assert test="every $id in employee/direct-reports/tokenize(., ' ') 
                     satisfies exists(employee[id=$id])"/>
  </xs:complexType>
</xs:element>