You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Didier Villevalois <dv...@techmetrix.net> on 2000/10/13 18:34:43 UTC

[XalanJ-1.2D02] NodeSet extension... Null Pointer Exception

Hello,

I'm trying to use the NodeSet extension of the XalanJ 1.2D02 bu i
can't succeed.

The fact is when i use it with the xalan/xslt/java namespace, xalan
is looking for a static nodeset() method.

I tried to recompile it with a static modifier for this method and
xalan claims a NullPointerException...

What can i do ? Can anyone give me a working example?

Thanks. Didier.



Re: Requirements suggestion for Gary: (Was: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception)

Posted by Gary L Peskin <ga...@firstech.com>.
Didier Villevalois wrote:
> 
> Hello Gary,
> Ok, I used nodeset all this saturday and sunday and goes to the
> following conclusions:
> 
> So if you want to anticipate the use of XSLT 1.1, you should return:
> 
> - a node-list if the rtf contains more than one node (as now)
> - a single node if the rtf contains only one node

Nodeset currently returns a node-list consisting of a single node.  This
is in conformance with XSLT 1.0, section 11.1 which states "A result
tree fragment is treated equivalently to a node-set that contains just a
single root node."

So, if the RTF contains only one node, it seems like under this
definition, we should return a node-set containing a root node that is
the parent of the RTF node.

It doesn't seem consistent that, if there is only one node in the RTF,
then that node should be directly accessible in the node-set.  So, in
your example

<xsl:variable name="toto">
              <myNode />
</xsl:variable>

It seems like $toto in XSLT 1.1 should be a root node whose child node
is the element myNode.

> 
> 2) It seems that nodeset() lose namespace declarations. So when i
> nodeset-ize an rtf that contains namespace-qualified element names i
> can't make any matching on the resulting nodeset as the mapping
> between my prefixes and my namespace-uris does not exist for this
> nodeset.
> 
> This is very strange and i didn't succeed in understanding what was
> wrong in the nodeset code. (in fact i didn't took too much time for
> this...)
> 

I didn't take namespace handling into account when first writing
nodeset.  In addition, I think the namespace handling has maybe changed
somewhat although I'm easily confused these days between XalanJ1 and
XalanJ2.

I'll look into it in the next day or two after I get some other stuff
finished and post any changes.

Thanks for your input.

Gary

Requirements suggestion for Gary: (Was: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception)

Posted by Didier Villevalois <dv...@sqli.com>.
Hello Gary,

Friday, October 13, 2000, 8:57:25 PM, you wrote:

GLP> Didier Villevalois wrote:
>> I now try to understand all of the nodeset() semantics.

GLP> Didier --

GLP> I'm hoping to significantly upgrade the flexibility of nodeset() in
GLP> XalanJ2.  Please let me know if you have any other questions or
GLP> requirements.

GLP> Gary

Ok, I used nodeset all this saturday and sunday and goes to the
following conclusions:

1) Is your goal to provide an extension that may enable Xalan users to
anticipate the release of XSLT 1.1 ?

The behavior of your nodeset extension when you give it a rtf with a
single node is to produce an xslt NodeSet containing one node.
I expect (personal opinion) the XSLT 1.1 semantics to enable some
things like that:

**** XSLT 1.0 non-comformant code... Don't use it!!! ****
<xsl:variable name="toto">
              <myNode />
</xsl:variable>

<xsl:apply-templates select="$toto"/>

Where selected node of the apply-templates construct is the
"<myNode />" node.

But the following will (again, i think) be also possible:

**** XSLT 1.0 non-comformant code... Don't use it!!! ****
<xsl:variable name="toto">
              <myNode />
              <myNode />
</xsl:variable>

<xsl:apply-templates select="$toto/*"/>

So if you want to anticipate the use of XSLT 1.1, you should return:

- a node-list if the rtf contains more than one node (as now)
- a single node if the rtf contains only one node

2) It seems that nodeset() lose namespace declarations. So when i
nodeset-ize an rtf that contains namespace-qualified element names i
can't make any matching on the resulting nodeset as the mapping
between my prefixes and my namespace-uris does not exist for this
nodeset.

This is very strange and i didn't succeed in understanding what was
wrong in the nodeset code. (in fact i didn't took too much time for
this...)


Again thanks Gary and the Apache folks for your great job!!!
Didier.

...
<rdf:RDF xmlns:rdf="http://www.w3.org/TR/1999/RDF/Model"
         xmlns:rdfl="http://www.infoReuse.org/RDF/Logic"
         xmlns:oss="http://www.infoReuse.org/OSS">

<rdf:Description rdfl:about="$project">
    <isFrom rdf:resource="http://www.apache.org/">

    <rdfl:ifExists>
        <oss:Project rdfl:about="$project"/>
    </rdfl:ifExists>
    <rdfl:ifExists rdf:parseType="Resource">
        <rdfl:modifier rdf:resource="rdfl:Not">
        <rdf:value>
            <oss:Project rdfl:about="$otherProject != $project"/>
        </rdf:value>
    </rdfl:ifExists>
</rdf:Description>

</rdf:RDF>



Re: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception

Posted by Gary L Peskin <ga...@firstech.com>.
Didier Villevalois wrote:
> I now try to understand all of the nodeset() semantics.

Didier --

I'm hoping to significantly upgrade the flexibility of nodeset() in
XalanJ2.  Please let me know if you have any other questions or
requirements.

Gary

Re[2]: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception

Posted by Didier Villevalois <dv...@sqli.com>.
Gary,

GLP> Didier --

GLP> I haven't had a chance to check out your stylesheet and I have to run. 
GLP> But from looking at the error message, the problem may be that you're
GLP> passing a node-set to the nodeset function.  The current implementation
GLP> will only accept a result tree fragment.

You were right...
I found the ones that were added by error.
I now try to understand all of the nodeset() semantics.

Thanks for this help...
Didier.



Re: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception

Posted by Gary L Peskin <ga...@firstech.com>.
Benoit Cerrina wrote:
> 
> Hi,
> this interests me to since I have the same problem with a custom function
> meant to tokenize a string into a nodeset.
> I modified the code to print out the exception stack and here is what I get:
> 
> java.lang.NullPointerException
>         at
> com.ibm.cs.util.ReflectionUtils.entryGetModifiers(ReflectionUtils.java:524)
>         at
> com.ibm.cs.util.ReflectionUtils.getEntryPoint(ReflectionUtils.java:237)
>         at
> com.ibm.cs.util.ReflectionUtils.getMethod(ReflectionUtils.java:590)
>         at
> com.ibm.cs.util.ReflectionUtils.getMethod(ReflectionUtils.java:570)
>         at
> org.apache.xalan.xpath.XSLTJavaClassEngine.call(XSLTJavaClassEngine.java:266
> )
>         at
> org.apache.xalan.xpath.ExtensionFunctionHandler.callFunction(ExtensionFuncti
> onHandler.jav
> a:555)
>         at
> org.apache.xalan.xpath.xml.XMLParserLiaisonDefault.extFunction(XMLParserLiai
> sonDefault.ja
> va:1913)
>         at org.apache.xalan.xpath.XPath.extfunction(XPath.java:1015)
>         at org.apache.xalan.xpath.XPath.executeExtension(XPath.java:1254)
>         at org.apache.xalan.xpath.XPath.execute(XPath.java:1379)
>         at org.apache.xalan.xpath.XPath.execute(XPath.java:1354)
>         at org.apache.xalan.xpath.XPath.execute(XPath.java:311)
>         at
> org.apache.xalan.xslt.ElemTemplateElement.transformSelectedChildren(ElemTemp
> lateElement.j
> ava:896)
>         at org.apache.xalan.xslt.ElemForEach.execute(ElemForEach.java:127)
>         at
> org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElemen
> t.java:661)
>         at
> org.apache.xalan.xslt.ElemLiteralResult.execute(ElemLiteralResult.java:254)
>         at
> org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElemen
> t.java:661)
>         at
> org.apache.xalan.xslt.ElemLiteralResult.execute(ElemLiteralResult.java:254)
>         at
> org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElemen
> t.java:661)
>         at org.apache.xalan.xslt.ElemTemplate.execute(ElemTemplate.java:145)
>         at
> org.apache.xalan.xslt.StylesheetRoot.process(StylesheetRoot.java:443)
>         at org.apache.xalan.xslt.Process.main(Process.java:555)

It looks like XSLTJavaClassEngine cannot find a method of the correct
name with appropriate argument types.  Check the types of the arguments
in your stylesheet against those in the method declaration and read the
extension docs which explain the correspondence between XSLT types and
java types.

If that doesn't solve it, send up the stylesheet and the java code and
we'll have a look.

Gary

Re: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception

Posted by Benoit Cerrina <be...@writeme.com>.
Hi,
this interests me to since I have the same problem with a custom function
meant to tokenize a string into a nodeset.
I modified the code to print out the exception stack and here is what I get:

java.lang.NullPointerException
        at
com.ibm.cs.util.ReflectionUtils.entryGetModifiers(ReflectionUtils.java:524)
        at
com.ibm.cs.util.ReflectionUtils.getEntryPoint(ReflectionUtils.java:237)
        at
com.ibm.cs.util.ReflectionUtils.getMethod(ReflectionUtils.java:590)
        at
com.ibm.cs.util.ReflectionUtils.getMethod(ReflectionUtils.java:570)
        at
org.apache.xalan.xpath.XSLTJavaClassEngine.call(XSLTJavaClassEngine.java:266
)
        at
org.apache.xalan.xpath.ExtensionFunctionHandler.callFunction(ExtensionFuncti
onHandler.jav
a:555)
        at
org.apache.xalan.xpath.xml.XMLParserLiaisonDefault.extFunction(XMLParserLiai
sonDefault.ja
va:1913)
        at org.apache.xalan.xpath.XPath.extfunction(XPath.java:1015)
        at org.apache.xalan.xpath.XPath.executeExtension(XPath.java:1254)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:1379)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:1354)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:311)
        at
org.apache.xalan.xslt.ElemTemplateElement.transformSelectedChildren(ElemTemp
lateElement.j
ava:896)
        at org.apache.xalan.xslt.ElemForEach.execute(ElemForEach.java:127)
        at
org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElemen
t.java:661)
        at
org.apache.xalan.xslt.ElemLiteralResult.execute(ElemLiteralResult.java:254)
        at
org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElemen
t.java:661)
        at
org.apache.xalan.xslt.ElemLiteralResult.execute(ElemLiteralResult.java:254)
        at
org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElemen
t.java:661)
        at org.apache.xalan.xslt.ElemTemplate.execute(ElemTemplate.java:145)
        at
org.apache.xalan.xslt.StylesheetRoot.process(StylesheetRoot.java:443)
        at org.apache.xalan.xslt.Process.main(Process.java:555)


----- Original Message -----
From: "Gary L Peskin" <ga...@firstech.com>
To: <xa...@xml.apache.org>
Sent: Friday, October 13, 2000 7:20 PM
Subject: Re: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception


> Didier Villevalois wrote:
> >
> > Hello back,
> >
> > I tried your solution Gary and here is the first error i was talking
> > about in my previous mail!!!
> >
> > Call to extension function failed: method call/new failed:
java.lang.NoSuchMetho
> > dException: org.apache.xalan.xslt.extensions.Nodeset.nodeset(class
org.apache.xa
> > lan.xpath.MutableNodeListImpl) -- no signature match
> >
> > Here is my conf:
> > Win2K-Tomcat4.0M2-Cocoon1.8 (containing XJ1.2 D02)
> >
>
> Didier --
>
> I haven't had a chance to check out your stylesheet and I have to run.
> But from looking at the error message, the problem may be that you're
> passing a node-set to the nodeset function.  The current implementation
> will only accept a result tree fragment.
>
> I'm not sure which of the nodeset calls is causing this problem.  But,
> if you can't find it, I'll have a look when I return.
>
> Gary


Re: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception

Posted by Gary L Peskin <ga...@firstech.com>.
Didier Villevalois wrote:
> 
> Hello back,
> 
> I tried your solution Gary and here is the first error i was talking
> about in my previous mail!!!
> 
> Call to extension function failed: method call/new failed: java.lang.NoSuchMetho
> dException: org.apache.xalan.xslt.extensions.Nodeset.nodeset(class org.apache.xa
> lan.xpath.MutableNodeListImpl) -- no signature match
> 
> Here is my conf:
> Win2K-Tomcat4.0M2-Cocoon1.8 (containing XJ1.2 D02)
> 

Didier --

I haven't had a chance to check out your stylesheet and I have to run. 
But from looking at the error message, the problem may be that you're
passing a node-set to the nodeset function.  The current implementation
will only accept a result tree fragment.

I'm not sure which of the nodeset calls is causing this problem.  But,
if you can't find it, I'll have a look when I return.

Gary

Re[2]: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception

Posted by Didier Villevalois <dv...@sqli.com>.
Hello back,

I tried your solution Gary and here is the first error i was talking
about in my previous mail!!!

Call to extension function failed: method call/new failed: java.lang.NoSuchMetho
dException: org.apache.xalan.xslt.extensions.Nodeset.nodeset(class org.apache.xa
lan.xpath.MutableNodeListImpl) -- no signature match

Here is my conf:
Win2K-Tomcat4.0M2-Cocoon1.8 (containing XJ1.2 D02)

I put my transform attached... Plz don't take attention about the
algorithm which is dirty and surely uncorrect (for now)...
Put these in an cocoon-enabled directory and run the panel.html file
in the samples directory.

But this worked with my own FunctionTree which is quite the same as
NodeSet.nodeset()... (but i hardcoded it in the xalan libs)

Thanks. Didier.

Re: [XalanJ-1.2D02] NodeSet extension... Null Pointer Exception

Posted by Gary L Peskin <ga...@firstech.com>.
Didier Villevalois wrote:
> 
> Hello,
> 
> I'm trying to use the NodeSet extension of the XalanJ 1.2D02 bu i
> can't succeed.
> 
> The fact is when i use it with the xalan/xslt/java namespace, xalan
> is looking for a static nodeset() method.
> 
> I tried to recompile it with a static modifier for this method and
> xalan claims a NullPointerException...
> 
> What can i do ? Can anyone give me a working example?
> 
> Thanks. Didier.

Didier --

Can you send us a copy of your stylesheet.  You should be able to just
do something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"       
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:myjava="http://xml.apache.org/xslt/java"
       xmlns:mynodeset="org.apache.xalan.xslt.extensions.Nodeset">

<xsl:template ...>
  <xsl:for-each
select="myjava:org.apache.xalan.xslt.extensions.Nodeset.nodeset($greeting)">*<xsl:copy-of
select="."/>*</xsl:for-each>
  <xsl:for-each select="mynodeset:nodeset($greeting)">*<xsl:copy-of
select="."/>*</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I've shown it above with two types of namespaces.

HTH,
Gary