package uk.ac.leeds.ccg.gml; import uk.ac.leeds.ccg.geotools.*; import org.apache.xerces.parsers.*; import org.w3c.dom.*; import java.util.*; import java.net.*; public class GMLReader { DOMParser parser; PolygonLayer layer=new PolygonLayer(); SimpleGeoData descriptions = new SimpleGeoData(); /** * Build a list of features from GML. * There is a security * constraint in java applets which prevents an applet from accessing a * URL different to the server where the applet came from. So if you want * to access a Web Feature Server from somewhere on the web, you need to set * up a local proxy. A local proxy sits on the server where the applet * came from, it recieves calls from the applet, forwards them onto the * Web Feature Server, and then funnels the responses back to the applet. *
If you are not using an applet, or if the URL of the GML is on the * same server as the applet, then you can set proxy to null. * @param url URL of the GML features * @param proxy URL of the local proxy server. */ public GMLReader(URL url, URL proxy){ try{ parser = new DOMParser(); if(proxy==null){ //parser.setFeature( // "http://xml.org/sax/features/validation", true); //parser.setFeature( // "http://apache.org/xml/features/continue-after-fatal-error" // ,true); parser.parse(url.toString()); }else{ //parser.setFeature( // proxy.toString() // +"?ProxyURL=" // +"http://xml.org/sax/features/validation" // ,true); //parser.setFeature( // proxy.toString() // +"?ProxyURL=" // +"http://apache.org/xml/features/continue-after-fatal-error" // ,true); parser.parse( proxy.toString() +"?ProxyURL=" +url.toString()); } Document d = parser.getDocument(); //FEATURES NodeList features = d.getElementsByTagName("Feature"); for(int i=0;i