We were just talking with Ben about how to make our parsers use schemas 
provided as jar files - I don't quite understand his technique yet but I am 
hopeful it can be adapted for wider use in the library.

The WMS parser code is basically "geotools parser 3" and is not the most 
flexible or easier to approach parser around :-(

From the test cases:

File getCaps = TestData.file(this, "1.3.0Capabilities.xml");
URL getCapsURL = getCaps.toURI().toURL();

Object object = DocumentFactory.getInstance(getCapsURL.openStream(), null, 
Level.WARNING);

Schema schema = WMSSchema.getInstance();
SchemaFactory.getInstance(WMSSchema.NAMESPACE);

The idea with this parser is that either it fetches the schema; or the schema 
has been compiled into code. What version of WMS Capabilities are you wanting 
to parse?

Long term we would like to generate a new parser using the same technology used 
by the gt-xsd-filter, gt-xsd-gml etc modules. Depending on your interests 
perhaps you can help out?

Jody



On 20/05/2010, at 7:05 PM, Heimo Laukkanen wrote:

> Hi all,
> 
> we are doing a project in Finnish meteorological institute and trying
> to use Geotools library ( xml and wms extensions ) for our benefit.
> 
> At the moment we are parsing WMS getCapabilities responses with
> Geotools-library, but can't seem to be able to make the parser to use
> local schemas, rather it tries to take contact to opengis -servers.
> 
> What we have done is we forked DocumentFactory.java (
> xml/src/main/java/org/geotools/xml/ ) and modified getParser by
> setting as local schema source list of local schemafiles.
> 
> It is possible that we should have more schemas locally, but we can't
> figure out which ones they should be. Parser configuration should be
> done like documentation suggests, but would appreciate a reply if
> someone spots an error there.
> 
> Here are our changes.
> 
>    Defined properties for parser configuration:
> 
>    static final String JAXP_SCHEMA_SOURCE =
>            "http://java.sun.com/xml/jaxp/properties/schemaSource";;
>    static final String JAXP_SCHEMA_LANGUAGE =
>            "http://java.sun.com/xml/jaxp/properties/schemaLanguage";;
> 
>    added getSchemas method, which loads following schemafiles:
> "capabilities_1_3_0.xsd", "sld_capabilities.xsd", "xlinks.xsd"
>    and returns them as an object array.
> 
>    Then we modified getParser to set validation true ( otherwise
> setting schema files throws error ) and set properties for schema
> language and schema source.
> 
>    private static SAXParser getParser() throws SAXException {
>        SAXParserFactory spf = SAXParserFactory.newInstance();
>        spf.setNamespaceAware(true);
>        spf.setValidating(true); // CHANGE HERE
>        try {
>            SAXParser sp = spf.newSAXParser();
> 
>            //CHANGES HERE
>            sp.setProperty(JAXP_SCHEMA_LANGUAGE,
>                    "http://www.w3.org/2001/XMLSchema";);
> 
>            sp.setProperty(JAXP_SCHEMA_SOURCE, getSchemas());
> 
>            return sp;
>        } catch (ParserConfigurationException e) {
>            throw new SAXException(e);
>        }
>    }
> 
> Now even after this the parser tries to open network connection during
> parsing to opengis servers.
> 
> Our network environment has mandatory proxy, so without setting proxy
> configuration we see that parsing fails with "Connection
> refused"-error and with wireshark we see that the program tried to
> open a connection to opengis server.
> 
> This isn't a major problem for us yet, but before going to production
> we would really like to get the parsing to be done without network
> traffic.
> 
> Any ideas or thoughts on what to do and / or what we might do wrong currently?
> 
> Any help is appreciated, thanks!
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Geotools-devel mailing list
> Geotools-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel

------------------------------------------------------------------------------

_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to