I know that if I have an XML file like this:
<persons>
<class name="English">
<person name="Tarzan" id="050676"/>
<person name="Donald" id="070754"/>
<person name="Dolly" id="231256"/>
</class>
<class name="Math">
<person name="Winston" id="050677"/>
<person name="Donald" id="070754"/>
<person name="Fred" id="231257"/>
</class>
</persons>
I can define a key in an XSL file like this:
<xsl:key name="preg" match="person" use="@id"/>
where I'm using id as the key. However, Donald is listed twice, but is only in one place in preg.
Suppose I want him listed twice in preg. That is, I want to make the class name be part of the identifier. Basically, I want preg to have keys that are equivalent to ordered pairs: (class-name, id). How do I do that (using XSLT 1.0)?
Concatenate the keys? How about
This would serve to keep them separate in the index. You'd of course have to use the same key to retrieve them. To avoid any ambiguity I'd also include a delimiter that won't occur in either subkey, as in
This is the recommended approach in Michael Kay's XSLT2 reference.