I have this tree structured XML (toc.xml):
<?xml version="1.0" encoding="utf-8"?>
<toc>
<item name="top" key="4294967296" subkey="1">
<item name="child1" key="4294967611" subkey="">
<item name="child2-1" key="4294961611" subkey="">
<item name="child3-1" key="4294967613" subkey=""/>
<item name="child3-2" key="4294967612" subkey=""/>
</item>
<item name="child2-2" key="4294962611" subkey="">
<item name="d" key="4294974806" subkey=""/>
</item>
<item name="child2-3" key="4294963611" subkey="">
<item name="d" key="4294967661" subkey=""/>
<item name="PI" key="4294967659" subkey=""/>
<item name="q" key="4294967660" subkey=""/>
</item>
<item name="child2-4" key="4294964611" subkey=""/>
<item name="child2-5" key="4294965611" subkey="">
<item name="bb" key="4294967616" subkey=""/>
<item name="bb" key="4294967620" subkey=""/>
<item name="f" key="4294967615" subkey=""/>
</item>
</item>
</item>
</toc>
Each key will be unique in the document.
I have an XSLT that imports the toc XML and tries to output the navigation:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no" />
<xsl:variable name="id" select="/member/@id" />
<xsl:template match="/member">
<html>
<head>
<title><xsl:value-of select="/member/name"/></title>
</head>
<body>
<div class="navigation">
<xsl:apply-templates select="document('toc.xml')" />
</div>
<div class="content">
<xsl:apply-templates />
</div>
</body>
</html>
</xsl:template>
</xsl>
And would like to find a node and output the following HTML inside the HTML file:
...html...
<div class="navigation">
<ul>
<li><a href="#">top</a><ul>
<li><a href="#">child1</li><ul>
<li><a href="#">child2</li><ul>
<li><a href="#">child3-1</a></li>
<li><a href="#">child3-2</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</div>
...more html...
Basically I want to search for a node: item[@key='4294967611'] and output all of the parent nodes and the direct children.
I feel this should be really easy but I'm struggling to find information about how to do this. My XSLT knowledge isn't great.