|
From: Jimmy Z. <cra...@co...> - 2007-03-28 01:36:22
|
It seems that "ap.declareXPathNameSpace("cite", =
"www.opengeospatial.net/cite");" should
have been "ap.declareXPathNameSpace("cite", =
"http://www.opengeospatial.net/cite");"
also ap.selectElementNS is not for XPath eval/selection, it is to =
emulate DOM's
noteIterator inteface.
Let me know if there is any question...
----- 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"); =
=
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
-------------------------------------------------------------------------=
-----
_______________________________________________
Vtd-xml-users mailing list
Vtd...@li...
https://lists.sourceforge.net/lists/listinfo/vtd-xml-users
|