[xsl] Relative URI "my-report.dtd"; can not be resolved without a document URI.

Subject: [xsl] Relative URI "my-report.dtd"; can not be resolved without a document URI.
From: "Brad Clark" <ralph@xxxxxxxxxxxx>
Date: 30 Apr 2003 13:57:17 -0000
I'm using xsl/fop to generate dynamic pdf's from xml. The xml has an
associated dtd which defines a number of entities. When the xml is
not dynamic but is loaded from a file, which resides in the same
directory as the dtd, the pdf gets generated fine. When the xml comes
from a dynamic string, the dtd specified in the DOCTYPE isn't found.

I know the reason is because the transformer doesn't have a base
directory to use for the relative uri. I defined a URIResolver and
called setURIResolver but it never seems to call the resolve callback.
What do I need to do so that the Transformer finds my dtd. Attached
is a snippet of code where the problem is occuring. Any help would be
greatly appreciated.

Thanks in Advance,


// Code Snippet

try {
FileOutputStream out = new FileOutputStream(REPORT_OUTPUT_BASEDIR +
Driver driver = new Driver();

Configuration.put("strokeSVGText", "false");
Transformer transformer =
new StreamSource(new File(REPORT_INPUT_BASEDIR +

transformer.setURIResolver(new MyResolver());

String test = 
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
"<!DOCTYPE my-report SYSTEM \"my-report.dtd\" >\n" +
"<my-report>\n" + 
"&cover1;\n" + 
"&introduction;\n" + 
"&body;\n" +
transformer.transform(new StreamSource(new StringReader(test)), new

} catch (Exception e) {

public class MyResolver implements javax.xml.transform.URIResolver {
public javax.xml.transform.Source resolve(String href, String base)
throws javax.xml.transform.TransformerException
try {
return new SAXSource(new InputSource(new FileReader(new
} catch (Exception e) {
return null;

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread