For maximum flexibility in processing XML, I want to have all XML files
included/imported/refered to
specified via lookup tables. That way you can map things like the
following:
"http://www.arielpartners.com/dtd/subordinate.dtd" ==>
"c:\bar\subordinate.dtd"
"http://www.arielpartners.com/xslt/common-stuff.xsl" ==>
"/home/cstrong/my-environment/xsl/common-stuff.xsl"
To enable this, I would like to have a way of specifying a URIResolver
and/or EntityResolver for both
tasks that have to do with processing XML: <style> and <xmlvalidate>
JAXP provides an elegant way to do this:
For XSLT processing, one can specify:
- URIResolver, via javax.xml.transform.Transformer.setURIResolver()
- SAXParserFactory, via the property:
javax.xml.parsers.SAXParserFactory
For XML Parsing, one can specify:
- EntityResolver, via org.xml.sax.XMLReader.setEntityResolver()
OK, fine. How?
First off, <style> and <xmlvalidate> could be upgraded to _only_ support
TraX. I proposed this already
for release 1.5 and it didn't seem too controversial.
Secondly, we could add optional hooks for resolvers. Here is one
possibility:
<style
destdir = "/mumble"
style = "/foo/bar/transformer.xsl"
uriresolver = "com.arielpartners.ade.URIResolver"
entityresolver = "com.arielpartners.ade.EntityResolver"/>
<xmlvalidate
failonerror = "no"
entityresolver = "com.arielpartners.ade.EntityResolver"/>
The implementation could use Class.forName() and make sure it is of the
correct type.
Thoughts?
--Craeg
|