I currently have a Java XSLT transformation process that includes an
EntityResolver attached to an XMLReader for the source XML file. This resolver
redirects a DTD reference in the source file to a local DTD. In my XSL
stylesheet, I am referencing an SVG file via a document() function, and I need
to redirect the SVG's DTD reference from an"http://" to a local "file://"
location.
The EntityResolver I have attached to the XMLReader for the source file
doesn't execute for the stylesheet, and this is where I'm getting stuck. Is it
possible to attach another instance of my EntityResolver to the transform, and
if so how do I do that?
Following is the applicable code I have set up for the transform:
Sorry for the delay in responding. One answer is to define a URIResolver
associated with the transformation. This will be called when the document()
function executes. Your URIResolver should return a SAXSource, whose XMLReader
is a parser in which an EntityResolver has been set.
Another option is to set the configuration property setSourceParser() to an
XMLReader that is a subclass of (or wrapper around) the "real" XML parser; on
initialisation this can set the EntityResolver property of the real parser as
required.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I currently have a Java XSLT transformation process that includes an
EntityResolver attached to an XMLReader for the source XML file. This resolver
redirects a DTD reference in the source file to a local DTD. In my XSL
stylesheet, I am referencing an SVG file via a document() function, and I need
to redirect the SVG's DTD reference from an"http://" to a local "file://"
location.
The EntityResolver I have attached to the XMLReader for the source file
doesn't execute for the stylesheet, and this is where I'm getting stuck. Is it
possible to attach another instance of my EntityResolver to the transform, and
if so how do I do that?
Following is the applicable code I have set up for the transform:
Sorry for the delay in responding. One answer is to define a URIResolver
associated with the transformation. This will be called when the document()
function executes. Your URIResolver should return a SAXSource, whose XMLReader
is a parser in which an EntityResolver has been set.
Another option is to set the configuration property setSourceParser() to an
XMLReader that is a subclass of (or wrapper around) the "real" XML parser; on
initialisation this can set the EntityResolver property of the real parser as
required.