[jdom-interest] Re: JDOM and XSL
Tony Montgomery Smith
tonyms at compuserve.com
Mon Feb 5 14:43:27 PST 2001
Further to my last posting, the following more or less works:
public org.jdom.Document transform(BufferedReader bufferedReader, String
xslFileName)
{
org.jdom.Document targetDoc = null;
try
{
Processor processor = Processor.newInstance("xslt");
Templates templates = processor.process(new InputSource(xslFileName));
Transformer transformer = templates.newTransformer();
DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
// dfactory.setNamespaceAware(true);
DocumentBuilder docBuilder = dFactory.newDocumentBuilder();
org.w3c.dom.Document domDoc = docBuilder.newDocument();
transformer.transform(new InputSource(bufferedReader), new
Result(domDoc));
DOMBuilder builder = new DOMBuilder();
targetDoc = builder.build(domDoc);
}
catch (Exception e)
{
System.out.println(e);
}
return targetDoc;
}
I write "more or less" because about 1 time in 3 it makes a mistake in analysing
the document. If this were C code, I'd look for an unitialised variable, but
that is impossible in Java, isn't it?
More information about the jdom-interest
mailing list