[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Relative URI "my-report.dtd"; can not be resolved with

Subject: 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
transformer dtd
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,

Ralph


// Code Snippet

try {
FileOutputStream out = new FileOutputStream(REPORT_OUTPUT_BASEDIR +
"test.pdf");
Driver driver = new Driver();

//driver.setLogger(log);
driver.setRenderer(Driver.RENDER_PDF);
driver.setOutputStream(out); 
Configuration.put("strokeSVGText", "false");
Transformer transformer =
TransformerFactory.newInstance().newTransformer(
new StreamSource(new File(REPORT_INPUT_BASEDIR +
"report-pdf-servlet.xsl")));

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" +
"</my-report>\n";
transformer.transform(new StreamSource(new StringReader(test)), new
SAXResult(driver.getContentHandler()));

} catch (Exception e) {
e.printStackTrace();
} 



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
File(REPORT_INPUT_BASEDIR + href))));
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.