Hi all,
I'm having trouble coming up with the correct XSLT code and was wondering if anyone could point me in the right direction. This is what I need to do...
I've got an xml tree with pages like so:
<page>
<title>A<title>
<subtitle>I</subtitle>
<item>1</item>
</page>
<page>
<title>D<title>
<subtitle>V</subtitle>
<item>7</item>
</page>
<page>
<title>A<title>
<subtitle>II</subtitle>
<item>5</item>
</page>
<page>
<title>A<title>
<subtitle>I</subtitle>
<item>9</item>
</page>
I want to be able to write some XSL code to display the data in a nested format like so:
-A
-I
-1
-9
-II
-5
-D
-V
-7
So far I'm able to select a <title> and print the <subtitle>s of all <page>s that have said <title>. However, I can't figure out how to do the two-level iteration.
Here is a snippet of my code.
<xsl:template match="/">
<xsl:apply-templates select="//page[./title[not(.=preceding::title)]]"/>
</xsl:template>
<xsl:template match="page">
<xsl:variable name="fac"><xsl:value-of select=".//title"/></xsl:variable>
<ul>
<xsl:for-each select="//page[title = $fac]">
<li>..print out sub-title...</li>
</xsl:for-each>
</ul>
</xsl:template>