I have a xml document in which i have used IDs and IDREFs in the hope that they could be connected in xlst using xpath, but I haven't been able to find a solution as to how. My xml goes like this:
<root>
<list>
<item id="c1"> <description> Class 1 </description> </item>
<item id="gc1"> <description> Gym-class 1 </description> </item>
<item id="c2"> <description> Class 2 </description> </item>
</list>
<school name="abc">
<schedule>
<class idref="c1">
<day>monday</day>
<day>friday</day>
</class>
</schedule>
</school>
<school name="def">
<schedule>
<class idref="gc1">
<day>tuesday</day>
<day>thurday</day>
</class>
</schedule>
</school>
</root>
And I wanted to make a connection in a way that on the output (which is html) when I reference the value in idref, what shows up would be the description in the list, in the beggining. Is this even possible?
Yes. It is easily possible. But the output depends on your XPath-version.
The following XPath-expression
returns the first item in XPath-1.0 and a set of nodes in XPath-2.0 and above.
So the output is either (without any special concatenation applied)
Class 1(1.0)Class 1 Gym-class 1which returns all items fulfilling the requirements (2.0+).If you want to get a certain
<item>'s description, you should replace the/root/school/schedule/class/@idrefin the expression above with the idref value you want to retrieve from the<item>list..