Hi all,
I'm using xmlbeans-2.2.0 and saxonb8-6-1 and I'm trying to
run the
provided SelectPath example from XQueryXPath samples
(I'm interested mainly on XmlObject.selectPath usage).
>From the XQueryXPath class I've commented out all calls
to the ExecQuery
class and I've left only the below calls:
// Execute the XPath samples.
SelectPath xpathSample = new SelectPath();
System.out.println("Running
SelectPath.updateWorkPhone n");
boolean xpWorkPhoneSuccessful =
xpathSample.updateWorkPhone(xml);
System.out.println("Running
SelectPath.collectNames n");
boolean xpCollectNames =
xpathSample.collectNames(xml);
I put in the classpath the below jars:
- jsr173_1.0_api.jar
- saxon8.jar
- schemas.jar
- xbean.jar
- xbean_xpath.jar
but when I run XQueryXPathTest the result is empty ... I
don't see the
part related to
System.out.println("nXML as updated by
updateWorkPhone
method (each work n" +
"phone number has been changed to
the same number):
nn"
+ empDoc.toString() + "n");
so I think that empDoc.selectPath fails on the given
pathExpression.
String pathExpression =
"$this/xq:employees/xq:employee/xq:phone[ location='work']";
A second question, why the '$this' part is needed ?
If I try to remove it, I got the error:
Running SelectPath.updateWorkPhone
java.lang.RuntimeException: net.sf.saxon.trans.DynamicError:
Finding
root of tree: the context item is undefined
If I run XQueryXPathTest with the original XQueryXPath class
(that is
with all the original calls to the ExecQuery class) the
error is:
Running ExecQuery.selectEmpsByStateCursor
java.lang.NullPointerException
at
net.sf.saxon.query.StaticQueryContext.buildDocument(Ljavax/x
ml/transform
/Source;)Lnet/sf/saxon/om/DocumentInfo;(StaticQueryContext.j
ava:412)
at
org.apache.xmlbeans.impl.xquery.saxon.XBeansXQuery.execQuery
(Ljava/lang/
Object;Ljava/util/Map;)Ljava/util/List;(XBeansXQuery.java:74
)
at
org.apache.xmlbeans.impl.store.Query$SaxonQueryImpl$SaxonQue
ryEngine.cur
sorExecute()Lorg/apache/xmlbeans/XmlCursor;(Query.java:345)
at
org.apache.xmlbeans.impl.store.Query$SaxonQueryImpl.cursorEx
ecute(Lorg/a
pache/xmlbeans/impl/store/Cur;Lorg/apache/xmlbeans/XmlOption
s;)Lorg/apac
he/xmlbeans/XmlCursor;(Query.java:243)
at
org.apache.xmlbeans.impl.store.Query.cursorExecQuery(Lorg/ap
ache/xmlbean
s/impl/store/Cur;Ljava/lang/String;Lorg/apache/xmlbeans/XmlO
ptions;)Lorg
/apache/xmlbeans/XmlCursor;(Query.java:48)
at
org.apache.xmlbeans.impl.store.Cursor._execQuery(Ljava/lang/
String;Lorg/
apache/xmlbeans/XmlOptions;)Lorg/apache/xmlbeans/XmlCursor;(
Cursor.java:
1336)
at
org.apache.xmlbeans.impl.store.Cursor._execQuery(Ljava/lang/
String;)Lorg
/apache/xmlbeans/XmlCursor;(Cursor.java:1331)
at
org.apache.xmlbeans.impl.store.Cursor.execQuery(Ljava/lang/S
tring;)Lorg/
apache/xmlbeans/XmlCursor;(Cursor.java:3839)
at
org.apache.xmlbeans.samples.xquery.ExecQuery.updateWorkPhone
(Lorg/apache
/xmlbeans/XmlObject;)Z(ExecQuery.java:74)
at
org.apache.xmlbeans.samples.xquery.XQueryXPath.executeQuerie
s([Ljava/lan
g/String;)Z(XQueryXPath.java:75)
at
org.apache.xmlbeans.samples.xquery.XQueryXPathTest.main([Lja
va/lang/Stri
ng;)V(XQueryXPathTest.java:29)
Could you help me to understand where is the problem ?
Regards
Patrizio
IMPORTANT:
This e-mail transmission is intended for the named
addressee(s)only.
Its contents are private, confidential and protected
from disclosure and should not be read, copied or
disclosed by any other person.
If you are not the intended recipient, we kindly ask
you to notify the sender immediately by telephone
(+41 (0)58 806 50 00), to redirect the message to the
account "info b-source.ch" and to delete this
e-mail.
E-mail transmissions may be intercepted, altered or
read by unauthorized persons and may contain viruses.
Therefore, it is recommended that you use regular mail
or courier services for any information intended to be
confidential. However, by sending us messages through
e-mail, you authorize and instruct us to correspond by
e-mail in the relevant matter.
Thank you.
------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
For additional commands, e-mail: user-help xmlbeans.apache.org
|