[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XPath selecting chain of following siblings of the
I wonder, why this XSLT 1.0 solution doesn't work:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*" /> </xsl:copy> </xsl:template> <xsl:template match="a[not(preceding-sibling::*[1][self::a])]"> <a-block> <xsl:copy-of select="." /> <xsl:apply-templates select="following-sibling::*[1][self::a]" /> </a-block> </xsl:template> </xsl:stylesheet> I have tried to code the sibling-recursion technique for "positional grouping" suggested by Michael Kay long time ago. I'll be grateful if anyone let me know what's wrong with the above code. On 3/9/07, Kolacm Toma <kolaci@xxxxxxx> wrote: Hi! sibling groups of 'a' elements into 'a-block' elements, so the output would look like: template matching first group element? http://www.biglist.com/lists/xsl-list/archives/200208/msg01182.html idea): each group --> <xsl:element name="a-block"> <xsl:copy-of select="."/> <xsl:copy-of select="following-sibling::a [preceding-sibling::*[1][self::a]] [generate-id(preceding-sibling::a[not(preceding-sibling::*[1][self::a])][1]) = generate-id(current())]"/> current one --><!-- first condition selects only 2nd+ nodes of each group --> <!-- second condition checks if the 1st node of the group is the be something simpler..?</xsl:element> </xsl:if> </xsl:template> matter in this case): each group --> <xsl:element name="a-block"> <xsl:copy-of select="."/> <xsl:copy-of select="following-sibling::a [preceding-sibling::*[1][self::a]] [generate-id(preceding-sibling::a[not(preceding-sibling::*[1][self::a])][1]) = generate-id(current())]"/> current one --><!-- first condition selects only 2nd+ nodes of each group --> <!-- second condition checks if the 1st node of the group is the </xsl:element> </xsl:if> </xsl:template> -- Regards, Mukul Gandhi
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|