01: package org.geotools.demo.xml;
02:
03: import java.io.InputStream;
04: import java.io.Reader;
05: import java.io.StringReader;
06:
07: import org.geotools.filter.text.cql2.CQL;
08: import org.geotools.xml.Configuration;
09: import org.geotools.xml.Parser;
10: import org.opengis.filter.Filter;
11: import org.xml.sax.InputSource;
12:
13: public class XXXExample {
14:
15: static String xml = "<Filter xmlns:gml=\"http://www.opengis.net/gml\">"
16: + " <Overlaps>"
17: + " <PropertyName>testGeometry</PropertyName>"
18: + "<gml:Polygon srsName=\"http://www.opengis.net/gml/srs/EPSG#4326\">"
19: + "<gml:outerBoundaryIs>"
20: + "<gml:LinearRing>"
21: + "<gml:coordinates>0,0 0,10 10,10 10,0 0,0</gml:coordinates>"
22: + "</gml:LinearRing>"
23: + "</gml:outerBoundaryIs>"
24: + "</gml:Polygon>" + " </Overlaps>" + "</Filter>";
25:
26: public static void main(String args[]) throws Exception {
27: //the xml instance document above
28: Reader reader = new StringReader(xml);
29: InputSource input = new InputSource(reader);
30:
31: //create the parser with the filter 1.0 configuration
32: Configuration configuration = new org.geotools.filter.v1_0.OGCConfiguration();
33: Parser parser = new Parser(configuration);
34:
35: //parse
36: Filter filter = (Filter) parser.parse(input);
37: System.out.println("got:" + filter);
38: }
39: }
|