ycomp
ycomp

Reputation: 8573

Unique combination of attribute and element via XSD

This is from my XSD as it stands now:

<xs:element name="Pickers">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="Picker" minOccurs="1" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:unique name="unique-prefix">
    <xs:selector xpath="st:Picker"/>
    <xs:field xpath="@prefix"/>
  </xs:unique>
</xs:element>

It makes the Picker attribute prefix unique e.g. <Picker prefix="this is unique">

I would like to modify the XPath so that what is unique is the combination of prefix and the content of the <Picker> element e.g. <Picker>content</Picker>

So, this is what I mean... prefix+content should be unique.

Is this possible? How could I do it?

Upvotes: 1

Views: 668

Answers (1)

kjhughes
kjhughes

Reputation: 111621

xs:unique can take multiple xs:field children:

<xs:unique name="unique-prefix">
    <xs:selector xpath="st:Picker"/>
    <xs:field xpath="@prefix"/>
    <xs:field xpath="."/>
</xs:unique>

Upvotes: 2

Related Questions