xml - XSLT transforming data using choose -
i have xml document, want use xslt change formatting of data.
xml values
<uniquename>xxx</uniquename> <parent>xyz</parent> <name>abc</name>
anytime there xxx in uniquename want change uniquename value 123
i tried below seems add column xml rather transforming xxx 123
<th style="text-align:left">uniquename</th> <th style="text-align:left">parent</th> <th style="text-align:left">name</th> </tr> <xsl:for-each select="units/row"> <tr> <review> <td><xsl:value-of select="uniquename"/></td> <xsl:if test="uniquename= 'xxx'"><text>123</text> </xsl:if> </review>
what need change values want
as title says, need use xsl:choose
, rather xsl:if
. try way:
<xsl:for-each select="units/row"> <tr> <td> <xsl:choose> <xsl:when test="uniquename='xxx'"> <xsl:text>123</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="uniquename"/> </xsl:otherwise> </xsl:choose> </td> <!-- more cells ... --> </tr> </xsl:for-each>
note difference between <text>
, <xsl:text>
. , not sure why need <review>
element in middle of table.
Comments
Post a Comment