Support #5473
closed
Error on XSLT transform because DTD not found,
Fixed in Maintenance Release:
Description
I am using saxon9ee.jar. I need to apply an XSLT within an existing java program. I am getting the XML file as an input stream. The problem is that the XML contains a DTD. I have the DTD file but don’t know where to place it and tell the java runtime where to find it.
This is being done programmatically, not by the command line.
The xml contains:
Error reported on transform is:
I/O error reported by XML parser processing null: /ST26SequenceListing_V1_3.dtd (No such file or directory)
code has
Xslt30Transformer.transform(source, destination)
where it fails
Any help would be appreciated.
I am new to this. From what I have read t seems the xml parser is failing, but I don't know how to get it to work. Thanks.
xml (it isn't a file) contains
xml has in it reference to: ST26SequenceListing_V1_3.dtd
There are two ways to get the relative URI ST26SequenceListing_V1_3.dtd
to resolve.
The first is to make sure that the parser is given a correct base URI, that is a file in the directory containing ST26SequenceListing_V1_3.dtd
. You can supply the base URI in the "systemId" property of the Source object passed as input to the transformation. If you supply a StreamSource based on a File or URI this will be set up automatically, but if you supply for example a Stream or a Reader then it needs to be done manually.
The second way is to set up a resolver as a callback which the XML parser calls when it needs to resolve the URI. You can do this at the XML parser level (supply a SAXSource
containing an XMLReader
whose EntityResolver
property has been set to a suitable callback), or you can do it at the Saxon Configuration
level - in the latest 11.x release, use Processor.getUnderlyingConfiguration().setResourceResolver()
.
Thank you. The first option looks easier, but the code is deployed on an application server so I don't know what base URI I should be providing.
I googled for the dtd file and downloaded it. I can probably put it under the resources folder of the app server. Are there any code examples of similar things?
The above worked.
Thank you so much for your help. Greatly appreciate it.
- Status changed from New to Closed
Closing this as the problem seems to have been resolved.
Please register to edit this issue
Also available in: Atom
PDF