H
Hoi Wong
With the XSLT 1.0 engine that I was forced to use, I have to parse old XML
scripts where the number (to be parsed and saved into $EPISODE_NUMBER_RAW)
that I want to parse is written with a comma seperator if it goes beyond 3
digits. i.e. the variable might be parsed as a string '1,324' or a number
56, depending on which XML file I have.
I was trying to get rid of the comma seperator by breaking the string into
two parts (that number will never go beyond 5 digits), like this:
<xsl:choose>
<xsl:when test="contains($EPISODE_NUMBER_RAW, ',')">
<xsl:variable name="EPISODE_NUMBER"
select="concat(substring-before($EPISODE_NUMBER_RAW,','),
substring-after($EPISODE_NUMBER_RAW, ',') )"/>
</xsl:when>
<xsltherwise>
<xsl:variable name="EPISODE_NUMBER" select="$EPISODE_NUMBER_RAW"/>
</xsltherwise>
</xsl:choose>
<xsl:value-of select="$EPISODE_NUMBER"/>
However, the XSLT throws an error saying that $EPISODE_NUMBER is not found.
Does <xsl:choose> has its own variable scope? If so, can anybody give me a
pointer on how to solve the problem?
Thanks a lot in advance.
Cheers,
Hoi
scripts where the number (to be parsed and saved into $EPISODE_NUMBER_RAW)
that I want to parse is written with a comma seperator if it goes beyond 3
digits. i.e. the variable might be parsed as a string '1,324' or a number
56, depending on which XML file I have.
I was trying to get rid of the comma seperator by breaking the string into
two parts (that number will never go beyond 5 digits), like this:
<xsl:choose>
<xsl:when test="contains($EPISODE_NUMBER_RAW, ',')">
<xsl:variable name="EPISODE_NUMBER"
select="concat(substring-before($EPISODE_NUMBER_RAW,','),
substring-after($EPISODE_NUMBER_RAW, ',') )"/>
</xsl:when>
<xsltherwise>
<xsl:variable name="EPISODE_NUMBER" select="$EPISODE_NUMBER_RAW"/>
</xsltherwise>
</xsl:choose>
<xsl:value-of select="$EPISODE_NUMBER"/>
However, the XSLT throws an error saying that $EPISODE_NUMBER is not found.
Does <xsl:choose> has its own variable scope? If so, can anybody give me a
pointer on how to solve the problem?
Thanks a lot in advance.
Cheers,
Hoi