Loriot Posted June 2, 2009 Share Posted June 2, 2009 Hi,I have a source xml that looks like that <tabell navn="A"> <liste> <data navn="kode">A</data> <tabell navn="same"> <liste> <data navn="Navn">Jens</data> <data navn="Navn">Inge</data> </liste> </tabell> </liste> <liste> <data navn="kode">B</data> <tabell navn="same"> <liste> <data navn="Navn">Anna</data> <data navn="Navn">Peter</data> </liste> </tabell> </liste> </tabell>I want a result that shows only the names of the list following the kode A. Like that<result><navn>Jens</navn><navn>Inge</navn></result>My stylesheet looks like that<result><xsl:for-each select="tabell/liste"><xsl:if test="data[@navn=kode]='A'"><xsl:for-each select="following::tabell/liste"><navn><xsl:value-of select="data[@navn=navn]"/></navn></xsl:for-each></xsl:if></xsl:for-each></result>I tried a couple of different variations with this name followers but do not manage to figure it out how this should belong together and the result is always empty. Hope anyone can help. Link to comment Share on other sites More sharing options...
aalbetski Posted June 2, 2009 Share Posted June 2, 2009 there are several ways to do this. heres one: <xsl:template match="/"> <result> <xsl:for-each select="//data[@navn='Navn'][ancestor::liste/data[@navn='kode']='A']"> <navn><xsl:value-of select="."/></navn> </xsl:for-each> </result> </xsl:template> Link to comment Share on other sites More sharing options...
Loriot Posted June 2, 2009 Author Share Posted June 2, 2009 Thanx. That helped! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.