tags:

views:

63

answers:

1

I don't really know XSL but I need to fix this code, I have reduced it to make it simpler.
I am getting this error

Invalid XSLT/XPath function

on this line

<xsl:variable name="text" select="replace($text,'a','b')"/>

This is the XSL

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:inm="http://www.inmagic.com/webpublisher/query" version='1.0'>
  <xsl:output method="text" encoding="UTF-8"/>

  <xsl:preserve-space elements="*"/>
  <xsl:template match="text()"></xsl:template>

  <xsl:template match="mos">
    <xsl:apply-templates/>

    <xsl:for-each select="mosObj">
      'Notes or subject' <xsl:call-template name="rem-html"><xsl:with-param name="text" select="SBS_ABSTRACT"/></xsl:call-template>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="rem-html">
    <xsl:param name="text"/>
    <xsl:variable name="text" select="replace($text,'a','b')"/>
  </xsl:template>
</xsl:stylesheet>

Can anyone tell me what's wrong with it? Thanks in advance.

+3  A: 

replace isn't available for XSLT 1.0. Instead you can use a function called translate which has the same signature.

Something like this should work fine:

<xsl:variable name="newtext" select="translate($text,'a','b')"/>

Also, note I changed the variable name to "newtext", in XSLT variables are immutable, so you can't do the equivalent of $foo = $foo like you had in your original code.

Mark E
Thanks Mark, but now I am getting this error:An unknown XPath extension function was called
@aximili, sorry, got XSLT 1.0 and 2.0 confused, edited...should be good to go now.
Mark E
I see thank you Mark!