Re: namespace extensions

Martin Honnen <[email protected]>
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Organization Liberty Development
Message-ID <[email protected]>

[email protected] wrote:


> i'm struggling with the following problem.
> I've created an xsl file to transform my xml but need javascript functions to display certain values in a specific way.
> 

> I use an extension in xsl to be able to run javascript (namespace extension) :
> namespace = xmlns:msxsl="ur:schemas-microsoft-com:xslt" ...
> 
> I was wondering ... is there an equivalent that I could use for the Mozilla/FireFox browser??

No, there is no script support inside of XSLT 1.0 transformations in 
Mozilla. But you can pass in parameters before the transformation if you 
run the whole transformation with script.

> Let me list an example as I'm using it now:
> 
> <xml><dvd title="TestTitle"></xml>
> 
> <xsl:stylesheet 
>      version="1.0" 
>      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>      xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>      xmlns:xslscript="myJavaScript">
> 
>   <msxsl:script language="javascript" implements-prefix="xslscript"> 
>     <![CDATA[
>       function toUpper(value) {
>         return value != null ? value.toUpperCase() : "";
>       }
>     ]]>
>   </msxsl:script>
> 
>   <xsl:template match="/">
>     <html>
>       <body>
>         <xsl:value-of select="xslsript:toUpper(string(dvd/@title))"/>
>       </body>
>     </html>
>   </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> IE: works fine
> FireFox: Error During XSLT transformation: An unknow XPath extension function was called. -> Leaving out the call to the xslscript:toUpper transforms the xml (without the desired functionality)

You can avoid an error if you use a proprietary extension function by 
checking
   <xsl:if test="function-available('xslsript:toUpper')">
     <xsl:value-of select="xslsript:toUpper(string(dvd/@title))" />
   </xsl:if>
That will avoid the error you get so far but of course if will not give 
you the script functionality you are looking for.


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.