Reputation: 88
I need to create an XSD that validates the value in a specific complex type with a parent node.
In this specific case the XML will look like this:
<ROOT>
<INFO>
<REGIONDESC>
<REGION VALUE="001" DESCRIPTION="Description 1" />
<REGION VALUE="002" DESCRIPTION="Description 2" />
<REGION VALUE="003" DESCRIPTION="Description 3" />
</REGIONDESC>
...Other Nodes..
</INFO>
<DETAILS>
<REGIONDETAILS>
<REGIONID VALUE="001"/>
...Other Nodes..
</REGIONDETAILS>
</DETAILS>
</ROOT>
I need validate that "REGIONID" value must be equal to some "REGIONDESC/REGION@VALUE". Is it possible?
Upvotes: 0
Views: 86
Reputation: 163322
In the definition of the ROOT element, define an xs:key with selection xpath="INFO/REGIONDESC/REGION", and field xpath="@VALUE"; and a corresponding xs:keyRef with selection xpath="DETAILS/REGIONDETAILS/REGIONID" and field xpath="@VALUE".
Upvotes: 2