[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] function-available() problem while using Saxon


Subject: RE: [xsl] function-available() problem while using Saxon
From: Arian Hojat <arianhojat2000@xxxxxxxxx>
Date: Wed, 22 Jun 2005 06:46:54 -0700 (PDT)

Good morning everyone,

Hmmm interesting. I set up the same stylesheet xsl:if
test for the function and get Michael's true result.
So I know that extension functions for Saxon are there
butttt...

The xsl:when test still returns the same results which
makes me think maybe my logic is screwed up? It's
simple test logic so not sure why it is behaving the
way it is...
Logic in <ans3> below:
When saxon:evaluate-node available, use it.
When dyn:evaluate available, use it.
Otherwise output error.
(
I guess the logic could be better like below so if
both fucntions are available, it does things better,
but still original should work...
When saxon:evaluate-node available, use it.
Otherwise 
  When dyn:evaluate available, use it.
  Otherwise output error.
)

###Results###

<answers 
xmlns:dyn="http://exslt.org/dynamic"
xmlns:saxon="http://saxon.sf.net/">
  <ans1>true</ans1> 
  <ans2>false</ans2> 
  <ans3>EXSLT: or SAXON: functions NOT FOUND???</ans3>

</answers>

###Stylesheet###
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
version="2.0"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:saxon="http://saxon.sf.net/"
>

<xsl:template match="/">     
<answers>

<ans1>
<xsl:value-of
select="function-available('saxon:evaluate-node')"/>
</ans1>

<ans2>
<xsl:value-of
select="function-available('dyn:evaluate')"/>
</ans2>

<ans3>
  <xsl:choose>
    <xsl:when
test="function-available('saxon:evaluate-node')">
Saxon </xsl:when>
    <xsl:when
test="function-available('dyn:evaluate')"> EXSLT
</xsl:when>
    <xsl:otherwise> EXSLT: or SAXON: functions NOT
FOUND??? </xsl:otherwise>
  </xsl:choose>
</ans3>

</answers>

</xsl:template>

</xsl:stylesheet>


















--- Michael Kay <mike@xxxxxxxxxxxx> wrote:

> Curious.
> 
> Stylesheet:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
> version="2.0">
> <xsl:template match="/">     
>       <ans><xsl:value-of
> select="function-available('saxon:evaluate-node')" 
>                    
> xmlns:saxon="http://saxon.sf.net/"/></ans>
> </xsl:template>
> </xsl:stylesheet>
> 
> Command:
> 
> java -jar c:\saxon-build\saxon8.3\saxon-b\saxon8.jar
> -t test.xsl test.xsl
> 
> Result:
> 
> Saxon 8.3 from Saxonica
> Java version 1.5.0
> Stylesheet compilation time: 641 milliseconds
> Processing file:/c:/temp/test.xsl
> Building tree for file:/c:/temp/test.xsl using class
> net.sf.saxon.tinytree.TinyBuilder
> Tree built in 0 milliseconds
> Tree size: 9 nodes, 21 characters, 3 attributes
> <?xml version="1.0"
> encoding="UTF-8"?><ans>true</ans>
> Execution time: 70 milliseconds
> 
> A possible explanation is that you are running with
> extension functions
> disabled: how is Saxon being invoked? Another
> possibility is that you aren't
> actually running Saxon at all - add a call on
> system-property('xsl:vendor')
> to the stylesheet to check.
> 
> Michael Kay
> http://www.saxonica.com/
> 
>  
> 
> > -----Original Message-----
> > From: Arian Hojat
> [mailto:arianhojat2000@xxxxxxxxx] 
> > Sent: 21 June 2005 21:18
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: RE: [xsl] function-available() problem
> while using Saxon
> > 
> > Hey,
> > 
> > > What namespace URI is bound to the prefix
> "saxon"
> > 
> > I bind http://saxon.sf.net/ to saxon
> > ...
> > <xsl:stylesheet version="2.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > xmlns:dyn="http://exslt.org/dynamic"
> > xmlns:saxon="http://saxon.sf.net/">
> > 
> > > Which version of
> > > Saxon are you using? 
> > "Saxon 8.3 from Saxonica"
> > 
> > Thanks,
> > Arian
> > 
> > 
> > 
> > 
> > --- Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > 
> > > What namespace URI is bound to the prefix
> "saxon",
> > > and which version of
> > > Saxon are you using? (You can find out using the
> -t
> > > option).
> > > 
> > > Michael Kay
> > > http://www.saxonica.com/ 
> > > 
> > > > -----Original Message-----
> > > > From: Arian Hojat
> > > [mailto:arianhojat2000@xxxxxxxxx] 
> > > > Sent: 21 June 2005 20:15
> > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > > Subject: [xsl] function-available() problem
> while
> > > using Saxon
> > > > 
> > > > Hello all,
> > > > One last question for the day hopefully.
> > > > 
> > > > I deciding since I might be using FOP(which
> uses
> > > > Xalan) and at some points be using Saxon to
> see
> > > whats
> > > > wrong in my .fo output, that I would see which
> > > > extension function is available and use it
> > > > accordingly.
> > > > Xalan checks to see if saxon:evaluate-node is
> > > > available 1st and fails. Then dyn:evaluate is
> > > > available and correctly used.
> > > > 
> > > > In Saxon, it checks to see if
> saxon:evaluate-node
> > > is
> > > > available and FAILS?, then I believe tries to
> USE
> > > > dyn:evaluate and errors? It shouldn't even get
> to
> > > the
> > > > point of using dyn:evaluate since it isn't
> > > available
> > > > right? (i am prob doing something very wrong).
> I
> > > > should mention I do put saxon: and dyn:
> namespaces
> > > in
> > > > the top of the xsl I am using, so thats not
> the
> > > > problem.
> > > > 
> > > > XP0003: XPath syntax error at char 18 on line
> 200
> > > in
> > > > {dyn:evaluate($exp)}:
> > > >   Cannot find a matching 1-argument function
> named
> > > > {http://exslt.org/dynamic}evaluate()
> > > > 
> > > > 
> > > > ###part that selects what function to use
> > > > <xsl:choose>
> > > >   <xsl:when
> > > >
> > >
> >
>
test="function-available('saxon:evaluate-node')"><xsl:for-each
> > > > select="document(@href)/Document">
> > > > <xsl:apply-templates
> > > > select="saxon:evaluate-node($exp)"/>
> > > > </xsl:for-each></xsl:when>
> > > >   <xsl:when
> > > >
> > >
> >
>
test="function-available('dyn:evaluate')"><xsl:for-each
> > > > select="document(@href)/Document">
> > > > <xsl:apply-templates
> select="dyn:evaluate($exp)"/>
> > > > </xsl:for-each></xsl:when>
> > > >   <xsl:otherwise><xsl:message>EXSLT:EVALUATE()
> OR
> > > > SAXON:EVALUATE-NODE() NOT FOUND IN YOUR XSL
> > > > PROCESSOR</xsl:message></xsl:otherwise>
> > > > </xsl:choose>
> > > > 
> > > > 
> > > > Thanx again to the xsl list and Michael Kay
> > > > 
> > > > 
> > > > Unrelated Note if someone notices I could use
> a
> > > > simpler template for Saxon: I dont use that
> simple
> > > > template like below because if Xalan is being
> > > used, it
> > > > will not like the 'function call as a step in
> the
> > > > xpath' as it parses beforehand, so i keep it
> as
> > > is.
> > > > <xsl:apply-templates
> > > >
> > >
> >
>
select="document(@href)/Document/saxon:evaluate-node(current()
> > > > /@nodes))"/>
> > > > 
> > > > 
> > > > 
> > > > 		
> > > > __________________________________ 
> > > > Discover Yahoo! 
> > > > Have fun online with music videos, cool games,
> IM
> > > and more. 
> > > > Check it out! 
> > > > http://discover.yahoo.com/online.html
> > > > 
> 
=== message truncated ===



		
____________________________________________________ 
Yahoo! Sports 
Rekindle the Rivalries. Sign up for Fantasy Football 
http://football.fantasysports.yahoo.com


Current Thread
Keywords