|
Subject: [xsl] group-starting-with and ending with From: "Byomokesh Sahoo sahoo.byomokesh@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 6 Mar 2020 06:47:20 -0000 |
Hi,
Is it any possibility to <st> start and end tag in <bb>Test1</bb>,
<bb>Test2</bb>.
Here is my XML
<a><x>To</x> Test, <bb>Test1</bb>, <bb>Test2</bb>, <cc>Test3</cc>,
<dd>USA</dd></a>
Desired Output
<a><x>To</x> Test, <st><bb>Test1</bb>, <bb>Test2</bb></st>, <cc>Test3</cc>,
<dd>USA</dd></a>
XSLT
<xsl:template match="a">
<xsl:element name="{local-name()}">
<xsl:for-each-group select="node()" group-adjacent="self::text() or self::x
or self::dd or self::cc">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<xsl:copy-of select="current-group()"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each-group select="*" group-starting-with="self::bb">
<st>
<xsl:for-each select="current-group()">
<xsl:copy-of select="current-group()"/>
</xsl:for-each>
<xsl:copy-of select="current-group()"/>
</st>
</xsl:for-each-group>
<xsl:copy-of select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:element>
</xsl:template>
Thanks
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] modify output document el, Christophe Marchand | Thread | Re: [xsl] group-starting-with and e, Imsieke, Gerrit, le- |
| Re: [xsl] modify output document el, Christophe Marchand | Date | Re: [xsl] group-starting-with and e, Imsieke, Gerrit, le- |
| Month |