xsl-list
[Top] [All Lists]

[xsl] group-starting-with and ending with

2020-03-06 00:47:27
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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>