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

Reply via email to