|
From: Jimmy Z. <cra...@co...> - 2007-03-27 21:33:59
|
Can you try to compile and run the code attached in this email to see
if there is any issue?=20
/*
* Created on Mar 27, 2007
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import com.ximpleware.*;
public class NSTest {
public static void main(String s[]) {
AutoPilot ap =3D new AutoPilot();
ap.declareXPathNameSpace("ns1","ns1");
ap.declareXPathNameSpace("ns2","ns2");
ap.declareXPathNameSpace("ns3","ns3");
String XML =3D "<ns1:good xmlns:ns1=3D'ns1'>\n"
+"<ns2:bad xmlns:ns2=3D'ns2'>\n"
+"<ns3:ugly xmlns:ns3=3D'ns3'/>\n"
+"</ns2:bad>\n"
; +"</ns1:good>";
try{
ap.selectXPath("/ns1:good/ns2:bad/ns3:ugly");
System.out.println(" expr =3D=3D=3D> " + =
ap.getExprString());
VTDGen vg =3D new VTDGen();
vg.setDoc(XML.getBytes());
vg.parse(true);
VTDNav vn =3D vg.getNav();
ap.bind(vn);
int i;
while((i=3Dap. evalXPath())!=3D-1){
System.out.println(" token name =
=3D=3D>"+vn.toString(i));
}
}catch(Exception e){
System.out.println("exception =3D=3D>"+e);
}
}
}
----- Original Message -----=20
From: Jimmy Zhang=20
To: Fernando Gonzalez ; vtd...@li...=20
Sent: Tuesday, March 27, 2007 11:14 AM
Subject: [Norton AntiSpam] Re: [Vtd-xml-users] XPath doubt
Will investigate and get back to you
----- Original Message -----=20
From: Fernando Gonzalez=20
To: vtd...@li...=20
Sent: Tuesday, March 27, 2007 1:55 AM
Subject: [Vtd-xml-users] XPath doubt
Hi again,
I'm having some problems using XPath expressions...=20
When I use the "/wfs:FeatureCollection/gml:featureMember" expression =
it works fine.=20
But if I add one more element: =
"/wfs:FeatureCollection/gml:featureMember/cite:Streams" it matches =
nothing...=20
The most surprising (to me) is that if I use this =
"/wfs:FeatureCollection/gml:featureMember/*" it matches the =
"cite:Streams" elements in the XML.
Am I missing something??
By the way, I don't know what's the point of the " =
AutoPilot.selectElementNS" and "AutoPilot.declareXPathNameSpace" methods =
so maybe the problem is there. Where can I find some documentation about =
them. I looked in the javadoc but it's not clear to me.
Thanks in advance,
This is the code and the file:
AutoPilot ap =3D new AutoPilot(vn);
ap.selectElementNS("www.opengeospatial.net/cite ", "*");
ap.declareXPathNameSpace("cite", =
"www.opengeospatial.net/cite");
ap.selectElementNS(" http://www.opengis.net/gml", "*");
ap.declareXPathNameSpace("gml", =
"http://www.opengis.net/gml");
ap.selectElementNS(" http://www.opengis.net/wfs", "*");
ap.declareXPathNameSpace("wfs", =
"http://www.opengis.net/wfs");=20
=
ap.selectXPath("/wfs:FeatureCollection/gml:featureMember/cite:Streams");
int result =3D -1;
while ((result =3D ap.evalXPath()) !=3D -1) {
long l =3D vn.getElementFragment ();
int tokenOffset =3D (int) (0x0000FFFF & l);
int tokenLength =3D (int) ((0xFFFF0000 & l) >> 32);
System.out.println(new String(b, tokenOffset, =
tokenLength));
}
I have the following XML file:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<wfs:FeatureCollection xmlns:wfs=3D"http://www.opengis.net/wfs " =
xmlns:gml=3D"http://www.opengis.net/gml" =
xmlns:cite=3D"http://www.opengeospatial.net/cite" xmlns:xsi=3D" =
http://www.w3.org/2001/XMLSchema-instance" =
xsi:schemaLocation=3D"http://www.opengeospatial.net/cite =
http://www.refractions.net:8082/geoserver1.3.1/wfs/DescribeFeatureType?ty=
peName=3Dcite:Streams http://www.opengis.net/wfs =
http://www.refractions.net:8082/geoserver1.3.1/schemas/wfs/1.0.0/WFS-basi=
c.xsd">
<gml:boundedBy>
<gml:Box>
<gml:coordinates decimal=3D"." cs=3D"," ts=3D" ">- =
0.0004,-0.0024 0.0036,0.0024</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<cite:Streams fid=3D"Streams.1">
<cite:the_geom>
<gml:MultiLineString>
...
-------------------------------------------------------------------------=
---
=
-------------------------------------------------------------------------=
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to =
share your
opinions on IT & business topics through brief surveys-and earn cash
=
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=
DEVDEV=20
-------------------------------------------------------------------------=
---
_______________________________________________
Vtd-xml-users mailing list
Vtd...@li...
https://lists.sourceforge.net/lists/listinfo/vtd-xml-users
-------------------------------------------------------------------------=
-----
=
-------------------------------------------------------------------------=
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to =
share your
opinions on IT & business topics through brief surveys-and earn cash
=
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=
DEVDEV
-------------------------------------------------------------------------=
-----
_______________________________________________
Vtd-xml-users mailing list
Vtd...@li...
https://lists.sourceforge.net/lists/listinfo/vtd-xml-users
|