RE: [xsl] xsl:function

Subject: RE: [xsl] xsl:function
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 12 Sep 2007 09:14:12 +0100
Firstly, please don't use text shorthand on this list. It saves you a few
seconds in typing time, and it costs hundreds of people reading your post a
few seconds in reading time. That's not a good trade-off, and it makes you
look unprofessional.

I think it has already been explained to you that if you need to use XSLT in
a browser (any browser) you will have to stick to XSLT 1.0 at the moment,
which means you cannot use constructs like xsl:function. If you do want to
use XSLT 2.0 constructs, then you will need to install a processor such as
Saxon and run in a different environment. 

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Karanam.Chowdary@xxxxxxxxxxxxxxxxxx 
> [mailto:Karanam.Chowdary@xxxxxxxxxxxxxxxxxx] 
> Sent: 12 September 2007 08:09
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] xsl:function
> 
> What shud I do I m not using saxon and I m not running in cmd 
> prompt. I hv just written XSL code in text file and saved it 
> as .xsl and directly opening XML in browser. I really donno 
> wat processor it is. Shud I install sum processor(s/w). 
> SAXON? I m just cing the results in IE not cmd prompt. If I 
> download saxon as u suggested can I get the results in 
> browser? And how shud I run that?
> 
> -----Original Message-----
> From: Abel Braaksma [mailto:abel.online@xxxxxxxxx]
> Sent: Wednesday, September 12, 2007 12:30 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] xsl:function
> 
> I just completed your code bit and changed the obvious 
> xsl:result error into xsl:value-of. But that was not the 
> error you got. I ran it, and it put out "2".
> 
> <?xml version='1.0' encoding='utf-8' ?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>     version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema";
>     xmlns:my="http://whatever"; exclude-result-prefixes="my">
>    
>    
>     <xsl:function name="my:one">
>         <xsl:param name="a"/>
>         <xsl:param name="b"/>
>         <xsl:value-of select="$a+$b"/>
>     </xsl:function>
>    
>     <xsl:template match="/">
>         <xsl:value-of select="my:one(1,1)"/>
>     </xsl:template>
> </xsl:stylesheet>
> 
> What I think is that you accidentally ran an XSLT 2.0 
> stylesheet with an
> 
> XSLT 1.0 processor (which should already complain about the 
> xsl:function
> 
> instruction, but perhaps first throws an error about the 
> extension functions not being known. Saxon for instance says 
> there's no known java
> 
> function).
> 
> Cheers,
> -- Abel Braaksma
> 
> Karanam.Chowdary@xxxxxxxxxxxxxxxxxx wrote:
> > The error is "Namespace http://whatever doesn't contain any 
> functions"
> >
> > -----Original Message-----
> > From: Abel Braaksma [mailto:abel.online@xxxxxxxxx]
> > Sent: Wednesday, September 12, 2007 12:14 PM
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re: [xsl] xsl:function
> >
> > Karanam.Chowdary@xxxxxxxxxxxxxxxxxx wrote:
> >   
> >> Hello,
> >> I m very new to XSL and XML just strtd working 10 days back.
> >> I hv a problem in using <xsl:function>. What's the name 
> space to be 
> >> given? Shud I give a valid name space which contains the functions?
> >>
> >> <?xml version='1.0' encoding='utf-8' ?> <xsl:stylesheet 
> >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> >> version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema";
> >> 	xmlns:my="http://whatever"; exclude-result-prefixes="my"> 
> >> <xsl:function name="my:one">
> >> 		<xsl:param name="a"/>
> >> 		<xsl:param name="b"/>
> >> 		<xsl:result select="$a+$b"/>
> >> </xsl:function>
> >> 	
> >> <xsl:template match="/">
> >> <xsl:value-of select="my:one(1,1)"/>
> >> .......
> >> What is the mistake here? Am I missing sumthing?
> 
> 
> 
> DISCLAIMER:
> This message contains privileged and confidential information 
> and is intended only for an individual named. If you are not 
> the intended recipient, you should not disseminate, 
> distribute, store, print, copy or deliver this message. 
> Please notify the sender immediately by e-mail if you have 
> received this e-mail by mistake and delete this e-mail from 
> your system. E-mail transmission cannot be guaranteed to be 
> secure or error-free as information could be intercepted, 
> corrupted, lost, destroyed, arrive late or incomplete or 
> contain viruses. The sender, therefore,  does not accept 
> liability for any errors or omissions in the contents of this 
> message which arise as a result of e-mail transmission. If 
> verification is required, please request a hard-copy version.

Current Thread