I have an element named "vendingMachine". This may appear in one of two
places
<customerSite>
<vendingMachines>
or
<plannedVisit>
<installationTask>
Because of this I made an element named vendingMachine and simply referred
to it when needed <xs:element ref="vendingMachine"/>. Various other parts
of my XML need to refer to a vending machine by its serial number. My
questions are
1) How do I define a key on vendingMachine @serialNumber so that it is
unique within the whole document no matter where it appears
2) How do I define a reference to a vending machine which could be in either
place?
Within <xs:schemaI have the following
<xs:key name="vendingMachineSerialNumberKey">
<xs:selector xpath="vendingMachine"/>
<xs:field xpath="@serialNumber"/>
</xs:key>
and using the key:
<xs:keyref name="visitActionVendingMachineSerialNumber"
refer="vendingMachineSerialNumberKey">
<xs:selector
xpath="roundData/visitDay/plannedVisits/plannedVisit/tasks/*"/>
<xs:field xpath="@vendingMachineSerialNumber"/>
</xs:keyref>
but when I validate my XML in XmlSpy I get the following error:
Identity constraint visitActionVendingMachineSerialNumber did not match
within the scope of element <data>. The referenced identity constraint
"vendingMachineSerialNumberKey" is out of scope
Can anyone help?
Thanks!
Pete