How do i modify the XSL to change the xml format.
Posted
by user323719
on Stack Overflow
See other posts from Stack Overflow
or by user323719
Published on 2010-04-23T17:57:06Z
Indexed on
2010/04/23
18:13 UTC
Read the original article
Hit count: 622
In the below XSL.
<xsl:param name="insert-file" as="document-node()" />
<xsl:template match="*">
<xsl:variable name="input">My text</xsl:variable>
<xsl:variable name="Myxml" as="element()*">
<xsl:call-template name="populateTag">
<xsl:with-param name="nodeValue" select="$input"/>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="$Myxml"></xsl:copy-of>
</xsl:template>
<xsl:template name="populateTag">
<xsl:param name="nodeValue"/>
<xsl:for-each select="$insert-file/insert-data/data">
<xsl:choose>
<xsl:when test="@index = 1">
<a><xsl:value-of select="$nodeValue"></xsl:value-of></a>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
I am getting the output as:
<?xml version="1.0" encoding="UTF-8"?
>
<a
>My text</a
>
<a
>My text</a
>
<a
>My text</a
>
<a
>My text</a
>
I want template "populateTag" to retun me the xml in the below format. How do i modify the template "populateTag" to achive the same.
Expected output from template "populateTag":
<?xml version="1.0" encoding="UTF-8"?
>
<a
><a
><a
><a
>My text</a
></a
></a
></a
>
Please give your ideas.
© Stack Overflow or respective owner