You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Dave Brosius <db...@mebigfatguy.com> on 2008/02/09 00:42:13 UTC
RE: XPath in extension functions 'Could not resolve the node to a handle'
Some further snooping reveals, that i am using the
com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl
factory, even tho i have xalan.jar on my path. Further when i set this
System.setProperty("javax.xml.xpath.XPathFactory", "org.apache.xpath.jaxp.XPathFactoryImpl");
I still am getting the sun factory.
I am assuming this is the root of the problem. How do i get the apache one? I even set the property on the cmd line to no avail.
thanks.
dave
Re: XPath in extension functions 'Could not resolve the node to a handle'
Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Dave.
"Dave Brosius" <db...@mebigfatguy.com> wrote on 2008-02-09 09:14:28 AM:
> Thank you Henry, that worked. (i don't have it in endorsed, btw) But
> having done that it still results in a NullPtrException the same as
> when i used new XPatchFactoryImpl, here
>
[HZ: Snipped sample]
>
> AxesWalker.setRoot(int) line: 221
> WalkingIterator.setRoot(int, Object) line: 157
> XNodeSet(NodeSequence).setRoot(int, Object) line: 265
> WalkingIterator(LocPathIterator).execute(XPathContext) line: 212
> XPath.execute(XPathContext, int, PrefixResolver) line: 337
> XPath.execute(XPathContext, Node, PrefixResolver) line: 303
> XPathImpl.eval(String, Object) line: 216
> XPathImpl.evaluate(String, Object, QName) line: 281
> ExtensionsWithXPath.exfunc(ExpressionContext) line: 28
[HZ: Trimmed stack trace]
I think the root of the problem is that XPathImpl.eval(String,Object) is
creating a new XPathContext object in which to evaluate the path
expression. That would be OK if the processor were evaluating the
expression against some vanilla DOM Node, but in fact, the context node in
this case is an instance of DTMNodeProxy.
In XPath.execute(XPathContext,Node,PrefixResolver), the processor asks for
a DTM node handle (an int) for the Node. If this were an ordinary DOM
Node, a new instance of DOM2DTM might be created, but as the Node is
actually a DTMNodeProxy, it's simply asked for its node handle. However,
that node handle only makes sense in the original XPathContext that
existed for evaluating the stylesheet; it doesn't make sense for the
XPathContext created in XPathImpl.eval(String,Object), which will have its
own set of potentially overlapping DTM node handles.
An appropriate fix might be for XPathImpl.eval(String,Object) to check
whether Object is an instance of DTMNodeProxy, and then reuse the existing
XPathContext - but I'm not sure whether you can get from the DTMNodeProxy
to the containing XPathContext. I can't check into it today, but if you
have the inclination, that might give you something to go on.
Thanks,
Henry
------------------------------------------------------------------
Henry Zongaro
XML Transformation & Query Development
IBM Toronto Lab T/L 313-6044; Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com
Re: XPath in extension functions 'Could not resolve the node to a handle'
Posted by Dave Brosius <db...@mebigfatguy.com>.
Thank you Henry, that worked. (i don't have it in endorsed, btw) But having done that it still results in a NullPtrException the same as when i used new XPatchFactoryImpl, here
because the dtm is null, HERE
public void setRoot(int root)
{
// %OPT% Get this directly from the lpi.
XPathContext xctxt = wi().getXPathContext();
m_dtm = xctxt.getDTM(root);
m_traverser = m_dtm.getAxisTraverser(m_axis); /* HERE m_dtm is null */
m_isFresh = true;
m_foundLast = false;
m_root = root;
m_currentNode = root;
if (DTM.NULL == root)
{
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_SETTING_WALKER_ROOT_TO_NULL, null)); //"\n !!!! Error! Setting the root of a walker to null!!!");
}
resetProximityPositions();
}
AxesWalker.setRoot(int) line: 221
WalkingIterator.setRoot(int, Object) line: 157
XNodeSet(NodeSequence).setRoot(int, Object) line: 265
WalkingIterator(LocPathIterator).execute(XPathContext) line: 212
XPath.execute(XPathContext, int, PrefixResolver) line: 337
XPath.execute(XPathContext, Node, PrefixResolver) line: 303
XPathImpl.eval(String, Object) line: 216
XPathImpl.evaluate(String, Object, QName) line: 281
ExtensionsWithXPath.exfunc(ExpressionContext) line: 28
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
ExtensionHandlerJavaClass.callFunction(String, Vector, Object, ExpressionContext) line: 401
ExtensionHandlerJavaClass.callFunction(FuncExtFunction, Vector, ExpressionContext) line: 440
ExtensionsTable.extFunction(FuncExtFunction, Vector, ExpressionContext) line: 222
TransformerImpl.extFunction(FuncExtFunction, Vector) line: 473
FuncExtFunction.execute(XPathContext) line: 208
FuncExtFunction(Expression).executeCharsToContentHandler(XPathContext, ContentHandler) line: 313
ElemValueOf.execute(TransformerImpl) line: 274
ElemApplyTemplates.transformSelectedNodes(TransformerImpl) line: 395
ElemApplyTemplates.execute(TransformerImpl) line: 178
TransformerImpl.executeChildTemplates(ElemTemplateElement, boolean) line: 2400
TransformerImpl.applyTemplateToNode(ElemTemplateElement, ElemTemplate, int) line: 2270
TransformerImpl.transformNode(int) line: 1356
TransformerImpl.transform(Source, boolean) line: 709
TransformerImpl.transform(Source, Result, boolean) line: 1273
TransformerImpl.transform(Source, Result) line: 1251
ExtensionsWithXPath.main(String[]) line: 21
----- Original Message -----
From: Henry Zongaro
To: dbrosius@mebigfatguy.com
Cc: xalan-j-users@xml.apache.org
Sent: Saturday, February 09, 2008 7:25 AM
Subject: RE: XPath in extension functions 'Could not resolve the node to a handle'
Hi, Dave.
"Dave Brosius" <db...@mebigfatguy.com> wrote on 2008-02-08 06:42:13 PM:
> Some further snooping reveals, that i am using the
> com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl
>
> factory, even tho i have xalan.jar on my path. Further when i set this
>
> System.setProperty("javax.xml.xpath.XPathFactory", "org.
> apache.xpath.jaxp.XPathFactoryImpl");
>
> I still am getting the sun factory.
>
> I am assuming this is the root of the problem. How do i get the
> apache one? I even set the property on the cmd line to no avail.
XPathFactory allows for different factories based on the input data model. I believe the actual system property you set should be:
System.setProperty("javax.xml.xpath.XPathFactory:"
+XPathConstants.DOM_OBJECT_MODEL,
"org.apache.xpath.jaxp.XPathFactoryImpl");
Also, is xalan.jar merely on your class path or have you used the Java endorsed standards override mechanism? See [1] for more information.
Thanks,
Henry
[1] http://xml.apache.org/xalan-j/faq.html#faq-N100EF
------------------------------------------------------------------
Henry Zongaro XSLT Processors Development
IBM SWS Toronto Lab T/L 313-6044; Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com
RE: XPath in extension functions 'Could not resolve the node to a handle'
Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Dave.
"Dave Brosius" <db...@mebigfatguy.com> wrote on 2008-02-08 06:42:13 PM:
> Some further snooping reveals, that i am using the
> com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl
>
> factory, even tho i have xalan.jar on my path. Further when i set this
>
> System.setProperty("javax.xml.xpath.XPathFactory", "org.
> apache.xpath.jaxp.XPathFactoryImpl");
>
> I still am getting the sun factory.
>
> I am assuming this is the root of the problem. How do i get the
> apache one? I even set the property on the cmd line to no avail.
XPathFactory allows for different factories based on the input data model.
I believe the actual system property you set should be:
System.setProperty("javax.xml.xpath.XPathFactory:"
+XPathConstants.DOM_OBJECT_MODEL,
"org.apache.xpath.jaxp.XPathFactoryImpl");
Also, is xalan.jar merely on your class path or have you used the Java
endorsed standards override mechanism? See [1] for more information.
Thanks,
Henry
[1] http://xml.apache.org/xalan-j/faq.html#faq-N100EF
------------------------------------------------------------------
Henry Zongaro XSLT Processors Development
IBM SWS Toronto Lab T/L 313-6044; Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com