xml - XSLT: Wrapping a node and following text node with another tag -


i've got below xml document i'd transform using xslt.

input:

<abs>   <b>heading 1</b>    text   <b>heading 2</b>    text   <b>heading 3</b>    text   <b>heading 4</b>    text </abs> 

i need write transformation each heading , it's following text wrapped in <sec> tag below example shows.

desired output:

<abs>   <sec>     <b>heading 1</b>      text   </sec>   <sec>     <b>heading 2</b>      text   </sec>   <sec>     <b>heading 3</b>      text   </sec>   <sec>     <b>heading 4</b>      text   </sec>     </abs> 

does know how using xslt stylesheet?

thanks

please find xslt below:

<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="abs"> <xsl:copy>     <xsl:for-each select="b">     <sec><xsl:copy-of select="."/><xsl:value-of select="following-sibling::text()[1]"/></sec>        </xsl:for-each> </xsl:copy> </xsl:template>     </xsl:stylesheet> 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -