|
From: Fernando G. <fer...@gm...> - 2007-03-27 08:55:55
|
Hi again,
I'm having some problems using XPath expressions...
When I use the "/wfs:FeatureCollection/gml:featureMember" expression it
works fine.
But if I add one more element:
"/wfs:FeatureCollection/gml:featureMember/cite:Streams" it matches
nothing...
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 = 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 = -1;
while ((result = ap.evalXPath()) != -1) {
long l = vn.getElementFragment();
int tokenOffset = (int) (0x0000FFFF & l);
int tokenLength = (int) ((0xFFFF0000 & l) >> 32);
System.out.println(new String(b, tokenOffset, tokenLength));
}
I have the following XML file:
<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="
http://www.opengis.net/gml" xmlns:cite="http://www.opengeospatial.net/cite"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.opengeospatial.net/cite
http://www.refractions.net:8082/geoserver1.3.1/wfs/DescribeFeatureType?typeName=cite:Streams
http://www.opengis.net/wfs
http://www.refractions.net:8082/geoserver1.3.1/schemas/wfs/1.0.0/WFS-basic.xsd
">
<gml:boundedBy>
<gml:Box>
<gml:coordinates decimal="." cs="," ts=" ">-0.0004,-0.0024 0.0036,
0.0024</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<cite:Streams fid="Streams.1">
<cite:the_geom>
<gml:MultiLineString>
...
|