PDA

View Full Version : replace characters in .xsl


sushestvo
09-06-2005, 07:19 PM
I have
<xsl:template match="/REPORTINFO/ITEM1">
<xsl:value-of select="$qualifier" />
<xsl:value-of select="." />
<xsl:value-of select="$qualifier" />
<xsl:if test="not(position() = last())">
<xsl:value-of select="$delimiter" />
</xsl:if>
</xsl:template>
How can I make sure that if any item has _w, _x or _z it needs to be replaced with comma,& or space.

KC-Luck
09-06-2005, 08:06 PM
what are _w, _x, _z?
elements or values of element|attribute?

sushestvo
09-06-2005, 08:23 PM
it's a value...
like Test_wTest

KC-Luck
09-06-2005, 10:27 PM
I have no clue what you actually want to change, blah, yet this may get you started on possible solutions.
<xsl:choose>
<xsl:when test="contains(.,'_w')">
<xsl:value-of select="translate(.,'.',',')"/>
</xsl:when>
<xsl:when test="contains(.,'_x')">
<xsl:value-of select="translate(.,':',';')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>

sushestvo
09-06-2005, 11:01 PM
i tried that - it does double replacement, not only _w, but comma for _ and w

KC-Luck
09-07-2005, 05:07 PM
your example is a bit lacking, so it will be hard for anyone to assist you.