This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Newbie: using translate


> I am using the following template:
> 
>  <xsl:template name="number-1-block">
>   <xsl:param name="field"/>
>   <xsl:if test="not(string($field))">NULL</xsl:if>
>   <xsl:if test="string($field)"><xsl:value-of 
> select="$field"/></xsl:if>
>  </xsl:template>
> 
> The $field" variable is a float that uses the "," as a 
> decimal seperator.
> Can anyone give me an example of how I can use "translate()" to change
> the "," to a "." The examples I have found use the 
> "translate" function
> in the following manner:
> 
> <xsl:value-of select="translate(.,',.','')"/>
> 
> But I don't want the current node's value (".") but need the 
> "$field"'s
> value
> to be altered.

You can't alter the value of $field.

<xsl:template name="number-1-block">
  <xsl:param name="field" />
  <xsl:choose>
    <xsl:when test="string($field)">
      <xsl:value-of select="translate($field, ',', '.')" />
    </xsl:when>
    <xsl:otherwise>NULL</xsl:otherwise>
  </xsl:choose>
</xsl:template>

santtu

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]