GomuGomuNoRocket
GomuGomuNoRocket

Reputation: 819

Call custom function inside xslt 2

I want to call a function written inside xslt

this way i call it

  <xsl:value-of select='foo:compareCI()'/>  

this way is defined

   <xsl:function name='foo:compareCI'>                                              
             <xsl:value-of select='jkhjkhjk'/>
   </xsl:function>  

and now i have to add it to header but i what is properly way to do it?

     <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'  
       version='2.0'  
       xmlns:foo='http://whatever'>  

Can someone help with this?

Upvotes: 0

Views: 1912

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167516

Make sure you use an XSLT 2.0 processor if you want to use xsl:function, a minimal example for a function returning a string constant is

   <xsl:function name='foo:compareCI'>                                              
             <xsl:sequence select="'jkhjkhjk'"/>
   </xsl:function> 

with a namespace declared with e.g.

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:foo="http://example.com/foo">

you can then call the function with e.g.

<xsl:value-of select="foo:compareCI()"/>

Upvotes: 1

Related Questions