Lets say I have an XML file containing:
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<location>USA;New York</location>
<year>1985</year>
</cd>
<cd>
<title>Empire Burlesque II</title>
<artist>Bob Dylan</artist>
<location>USA;Houston</location>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<location>UK;London</location>
<year>1988</year>
</cd>
.
.
.
My xml file is little bit like this
<bookmark xml-lang="en-US" branch="index" id="bm_id3">
<bookmark_value>bullet lists;creating while typing</bookmark_value>
<bookmark_value>lists;automatic numbering</bookmark_value>
.
.
.
Using this xml, I want to generate a list of locations like :
USA
New York
Houston
UK
London
But presently I am only able to get single level list as
USA;New York
USA;Houston
UK;London
How can this be done without doing any change in xml file ?
Regarding code, I am using XSLT 1.0 and the code to get list is (my xml file is different from above mentioned xml file, as it was just to introduce the problem)
<xsl:key name="b_parent" match="bookmark_value" use="substring-before(bookmark_value, ';')" />
<xsl:template match="/">
<xsl:for-each select="//bookmark[@branch='index']">
<xsl:for-each select="bookmark_value[count(. | key('b_parent', substring-before(bookmark_value, ';'))[1])=1 ]">
<xsl:sort select="substring-before(bookmark_value, ';')"/>
<xsl:variable name="href" select="concat($filename,'#',@id)"/>
<li><a href="{$href}" target="_top">
<xsl:value-of select="substring-before(., ';')"/>
</a></li>
<xsl:for-each select="key('b_parent', substring-before(bookmark_value, ';'))">
<xsl:sort select="substring-after(., ';')" />
<ul><li><xsl:value-of select="substring-after(., ';')" /></li></ul>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>