Subject: Re: [xsl] Join elements by name, with spaces in between From: Yves Forkl <Y.Forkl@xxxxxx> Date: Tue, 13 Feb 2007 10:50:43 +0100 |
Try group-adjacent using a grouping key of
group-adjacent="if (. instance of element()) then name(.) else name(following-sibling::*[1])"
This groups text nodes with the following element, which may not be what you want. If you only want to retain text nodes if they fall between to element nodes that are in the same group, you could try to expand the conditional above.
<xsl:template match="entry"> <xsl:copy> <xsl:for-each-group select="node()" group-adjacent="if (. instance of element()) then name(.) else name(preceding-sibling::*[1])"> <xsl:element name="{name(current-group()[1])}"> <xsl:apply-templates select="current-group()/text()"/> </xsl:element> </xsl:for-each-group> </xsl:copy> </xsl:template>
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Choosing based on current, Abel Braaksma | Thread | Re: [xsl] Join elements by name, wi, Yves Forkl |
Re: [xsl] XSLT-related Links/News o, M. David Peterson | Date | Re: [xsl] Join elements by name, wi, Yves Forkl |
Month |