I extracted the code for this function, which is the following:

------------
  public boolean functionAvailable(String ns, String funcName)
          throws javax.xml.transform.TransformerException
  {
    return getExtensionsTable().functionAvailable(ns, funcName); // 448
  }
------------

The "getExtensionTable()" method is just an accessor.  This means that
the "m_extensionsTable" is null, which is only set in the
"setExtensionsTable()" method, which is only called from the
"transformNode()" function.  It seems plausible to guess that
"transformNode()" is never called (or perhaps "sroot.getExtensions()" is
null).  Is there something about my stylesheet that is making it not
call "transformNode()" before it gets to "functionAvailable()"?

> -----Original Message-----
> From: Karr, David 
> 
> I wrote a small stylesheet that just calls 
> "function-available" on values parsed from an XML file.  I 
> tested it in Stylus Studio, using both Xalan-j 2.5.2 and 
> Saxon 8.4.  I then ran it from the command line using JDK 
> 1.4.2 (which uses Xalan-j 2.4.1.  This time I get a "Unknown 
> error in Xpath" exception, with the following stack trace (truncated):
> 
> ---------------
> ; SystemID: 
> file:///C:/cygwin/home/u166705/work/mfxslt/etc/functionAvailable.xsl;
> Line#: 20; Column#: 47
> javax.xml.transform.TransformerException: Unknown error in XPath.
>       at org.apache.xpath.XPath.bool(XPath.java:412)
>       at
> org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:170)
>       at 
> org.apache.xalan.templates.ElemApplyTemplates.transformSelecte
> dNodes(Ele
> mApplyTemplates.java:425)
>       at 
> org.apache.xalan.templates.ElemApplyTemplates.execute(ElemAppl
> yTemplates
> .java:216)
>       at 
> org.apache.xalan.templates.ElemApplyTemplates.transformSelecte
> dNodes(Ele
> mApplyTemplates.java:425)
>       at 
> org.apache.xalan.templates.ElemApplyTemplates.execute(ElemAppl
> yTemplates
> .java:216)
> [deleted]
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.xalan.transformer.TransformerImpl.functionAvailable
> (Transform
> erImpl.java:448)
>       at 
> org.apache.xpath.functions.FuncExtFunctionAvailable.execute(Fu
> ncExtFunct
> ionAvailable.java:130)
>       at org.apache.xpath.Expression.bool(Expression.java:230)
>       at org.apache.xpath.XPath.bool(XPath.java:383)
>       ... 14 more
> ---------------
> 
> The stylesheet is just:
> ---------------
> <?xml version='1.0'?>
> <xsl:stylesheet version="1.0"
>                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                               xmlns:exsl="http://exslt.org/common";
>       
> xmlns:date="http://exslt.org/dates-and-times";
>                               xmlns:dyn="http://exslt.org/dynamic";
>                               xmlns:func="http://exslt.org/functions";
>                               xmlns:math="http://exslt.org/math";
>                               xmlns:random="http://exslt.org/random";
>       
> xmlns:regexp="http://exslt.org/regular-expressions";
>                               xmlns:set="http://exslt.org/sets";
>                               xmlns:str="http://exslt.org/strings";
>                               extension-element-prefixes="exsl str
> date dyn func math random regexp set str"
>                               exclude-result-prefixes="exsl str date
> dyn func math random regexp set str"
> >
> <xsl:output method="xml"/>
> 
> <xsl:template match="function">
>       <xsl:choose>
>        <xsl:when test="function-available(text())">
>         <xsl:value-of select="text()"/> present
>        </xsl:when>
>        <xsl:otherwise>
>         <xsl:value-of select="text()"/> not present
>        </xsl:otherwise>
>       </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>
> ---------------
> 
> The data looks like:
> ---------------
> <?xml version="1.0"?>
> <functions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:noNamespaceSchemaLocation="file:///c:/cygwin/home/u166705/
> work/mfxsl
> t/etc/Functions.xsd">
> <function>date:add</function> <function>date:add-duration</function>
> <function>date:date</function>
> [deleted]
> </functions>
> ---------------
> 

Reply via email to