[Home] [By Thread] [By Date] [Recent Entries]
Hermann Stamm-Wilbrandt wrote:
I know that this is basic but I cannot get it done correctly. The following stylesheet outputs the above result: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:key name="k1" match="line[not(starts-with(., 'A')) and not(starts-with(. , 'B')) and node()]" use="generate-id(preceding-sibling::line[starts-with(., 'A')][1])"/> <xsl:template match="@* | node()" name="identity">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template> <xsl:template match="lines">
<xsl:apply-templates select="line[starts-with(., 'A')]"/>
</xsl:template> <xsl:template match="line[starts-with(., 'A')]">
<xsl:call-template name="identity"/>
<xsl:apply-templates select="key('k1', generate-id())"/>
</xsl:template></xsl:stylesheet> I am however not sure whether the condition used "and node()" is what you want. -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|

Cart



