You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by Tony Dean <To...@sas.com> on 2006/07/15 03:05:02 UTC
Help with xmlbeans 2.2.0
Hi,
Could someone answer a couple of questions that I can not resolve.
1. xpath works for the most part with simple expressions, but when I introduce a predicate xmlbeans differs to saxon (I have saxonb8.6.1 on my classpath). saxon always returns an empty node list for the following expression:
Sring ns = "declare namespace ns='http://tempuri.org/myService';";
String xpath = ns + "$this/ns:copyintoout/ns:parameters[@myname='Tony']";
XmlObject[] selections = soapBody.selectPath(xpath);
soapBody points to the start of the soap body (ns:copyintoout) in the following instance document:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mys="http://tempuri.org/myService">
<soapenv:Body>
<mys:copyintoout>
<mys:parameters myname="Tony">
<mys:parm1/>
<mys:parm2/>
<mys:parm3/>
<mys:parm4/>
<mys:parm5/>
<mys:parm6/>
</mys:parameters>
<mys:streams>
<mys:instream/>
</mys:streams>
</mys:copyintoout>
</soapenv:Body>
</soapenv:Envelope>
selections always comes back empty.
Should this work? Am I doing something wrong? I noticed that you are using particular saxon classes instead of using JAXP and letting it decide what saxon xpath factory to use via saxon8-xpath.jar?
2. when not using a predicate, I get expected selections and everything looks good... for instance suppose my xpath expression is the following:
Sring ns = "declare namespace ns='http://tempuri.org/myService';";
String xpath = ns + "$this/ns:copyintoout/ns:parameters";
XmlObject[] selections = soapBody.selectPath(xpath);
XmlObject selection = selections[0];
XmlCursor cursor = selection.newCursor();
cursor.setTextValue("Added Text");
I would expect the instance data to now look like the following:
<mys:copyintoout>
<mys:parameters myname="Tony">Added Text
<mys:parm1/>
<mys:parm2/>
<mys:parm3/>
<mys:parm4/>
<mys:parm5/>
<mys:parm6/>
</mys:parameters>
<mys:streams>
<mys:instream/>
</mys:streams>
</mys:copyintoout>
Instead I get the following:
<mys:copyintoout>
<mys:parameters myname="Tony">Added Text
</mys:copyintoout>
All children of the node that text was added to were deleted. This seems like a bug. Do you agree otherwise, please explain.
Thank you very much for helping.
-Tony
Tony Dean
SAS Institute Inc.
919.531.6704
tony.dean@sas.com
SAS... The Power to Know
http://www.sas.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org