I have two questions:
Is there any reason for the org.geotools.xml.DOMParser to require a *Document*? 
It uses it in a DOMSource, which takes a Node. Are there some hidden 
requirements/edge cases later in the processing which needs the more 
specialized Document, or can the DOMParser be relaxed to take a Node?

And: It seems the Parser and DOMParser are very eager to do full schema 
validation, no matter where I use setValidating and setStrict false. What is 
the correct way of preventing external schema lookups?

My specific use case here is that I have an already-parsed XML document as DOM, 
and want to pick a filter-encoding out of a specific node, without any need for 
the rest of the document.

The simple version would seem to be something like

Configuration configuration = new org.geotools.filter.v2_0.FESConfiguration();
Filter filter = (Filter) new DOMParser(configuration, 
iWouldLikeThisToBeANode).parse();

but that is not possible.

Duplicating the functionality of the DOMParser, I can make a method like

public Object parse(Configuration configuration, org.w3c.dom.Node node) throws 
TransformerException {
    Source source = new DOMSource(node);
    Parser parser = new Parser(configuration);
    parser.setValidating(false);
    parser.setStrict(false);
    handler = parser.getParserHandler();
    handler.setValidating(false);
    handler.setStrict(false);
    SAXResult result = new SAXResult(handler);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(source, result);
    return handler.getValue();
}

which seems to work on Nodes (though it needs to live in the org.geotools.xml 
package to get access to the package-local getParserHandler()), but it still 
seems to go through an expensive schema lookup in 
org.geotools.xml.impl.HTTPURIHandler, despite me trying to set Strict and 
Validating false everywhere I can.

JWN
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to