Reputation: 32926
I'm pretty sure the answer to this is no but it never hurts to ask. Is there a way to do a join in an XML schema?
Here's what I mean. You can have employees/employee/@office_id
and elsewhere in the xml have /offices/region/office/@office_id
. Is there a way in the schema to tell it that these two attributes map to each other?
I ask because then we can automatically for an employee get their office info without requiring the user to specify this relationship.
Upvotes: 0
Views: 798
Reputation: 1
External references and connections between XML entities can be specified with XLINK.
Upvotes: -2
Reputation: 65
Are you asking if you can set up a schema such that every employee/@office_id has a corresponding office/@office_id?
If you know the possible office ids you could create a type like so:
<xsd:simpleType name="OfficeIDType">
<xsd:restriction base="xsd:integer"> <!-- or whatever type an office id is -->
<xsd:enumeration value="1"/>
<xsd:enumeration value="2"/>
<xsd:enumeration value="3"/>
</xsd:restriction>
</xsd:simpleType>
And then when declaring your attributes, make them this type and required, like so:
<xsd:attribute name="office_id" type="OfficeIDType" use="required"/>
Upvotes: 0
Reputation: 308763
JOIN is a relational concept. You'd have to code the equivalent in XPATH. I don't believe there's any mechanism to help you with it. You'll have to get the office instances and loop over them for a given individual's office, all in your code or XSLT.
Upvotes: 4