Altova Mailing List Archives


Re: [xsl] Unable to use the functions

From: James Fuller <jim.fuller@-------------->
To:
Date: 7/5/2005 10:07:00 AM
Lakshmi narayana wrote:

>Hi,
>I am trying to execute one function in XSLT. But I am getting the
>exceptions. Below are the code in XSL file and exceptions.
>Please suggest me the changes i had to make in XSLT to execute the reverse
>function properly.
>
>XSL Code.
>
><xsl:transform
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  xmlns:str="http://user.com/namespace"
>  version="1.0"
>  exclude-result-prefixes="str">
>
><xsl:function name="str:reverse">
>  <xsl:param name="sentence"/>
>  <xsl:result
>     select="if (contains($sentence, ' '))
>             then concat(str:reverse(substring-after($sentence, ' ')),
>                         ' ',
>                         substring-before($sentence, ' '))
>             else $sentence"/>
></xsl:function>
>
><xsl:template match="/">
><output>
>  <xsl:value-of select="str:reverse('DOG BITES MAN')"/>
></output>
></xsl:template>
>
></xsl:transform>
>
>
>Exceptions :
>
>
>javax.xml.transform.TransformerConfigurationException:
>javax.xml.transform.TransformerConfigurationException:
>javax.xml.transform.TransformerException:
>javax.xml.transform.TransformerException: xsl:function is not allowed in
>this position in the stylesheet!
>	at
>org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Transformer
>FactoryImpl.java:805)
>	at MyTest.test(MyTest.java:31)
>	at MyTest.main(MyTest.java:49)
>Caused by: javax.xml.transform.TransformerConfigurationException:
>javax.xml.transform.TransformerException:
>javax.xml.transform.TransformerException: xsl:function is not allowed in
>this position in the stylesheet!
>	at
>org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFa
>ctoryImpl.java:984)
>	at
>org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Transformer
>FactoryImpl.java:788)
>	... 2 more
>Caused by: javax.xml.transform.TransformerException:
>javax.xml.transform.TransformerException: xsl:function is not allowed in
>this position in the stylesheet!
>	at
>org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFa
>ctoryImpl.java:980)
>	... 3 more
>Caused by: javax.xml.transform.TransformerException: xsl:function is not
>allowed in this position in the stylesheet!
>	at
>org.apache.xalan.processor.StylesheetHandler.error(StylesheetHandler.java:96
>6)
>	at
>org.apache.xalan.processor.StylesheetHandler.getProcessorFor(StylesheetHandl
>er.java:428)
>	at
>org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.
>java:662)
>	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1672)
>	at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
>	at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
>	at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
>	at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
>	at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
>	at
>org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFa
>ctoryImpl.java:972)
>	... 3 more
>
>  
>

u are trying to execute an EXSLT function

http://xml.apache.org/xalan-j/extensions_xsltc.html#exslt_ext


the namespace should be

    xmlns:str="http://exslt.org/strings"

otherwise you could use the pure XSLT 1.0 template for this at www.exslt.org

gl, jim fuller

>Thanks,
>Laxmi Narayana Babu.
>OSI Technologies.

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.