[jdom-interest] transforming xsl to html question
david
simoon at theworld.com
Wed Mar 19 04:56:26 PST 2003
Hi
I'm using JDOM to build an xml doc and then I'm transformming that to HTML
using an xslt stylesheet. The problem I have is that the html contains xml
style closing tags
ie: <img src="image"/> instead of <img> </img>
This is causing a problem with some browsers. How can I make it output
html style closing tags.
Xalan has an option for this on the command line that works.
Code follows
Thanks
David
try {
htmlPage= transform (xmlPage,xslStylesheet);
} catch (Exception e) {
}
XMLOutputter outputter = new XMLOutputter(" ",true,"iso-8859-1");
outputter.output(htmlPage,out);
protected static Document transform(Document in, String stylesheet)
throws JDOMException {
try {
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(new StreamSource(stylesheet));
JDOMResult out = new JDOMResult();
transformer.transform(new JDOMSource(in), out);
return out.getDocument();
}
catch (TransformerException e) {
throw new JDOMException("XSLT Trandformation failed", e);
}
}
More information about the jdom-interest
mailing list