Is there an easy way to take a DOM object (such as a Document or
Element), and render it in a JSP? Specifically, I want to inline part
of a Document inside of an xml page created by a JSP.
There's nothing in the DOM interface to do it - no "toXML" method or
similar.
You have to create an object which will take the DOM tree and render it to
XML. I did this recently, but can't remember quite how, and the code is in
my other trousers. I think the relevant class came from javax.xml. Google
will find what you need.
One annoyance i came across is that the DOM tree doesn't record the
document's doctype; there's a method for getting it, but the
implementation i was using returned null (which is explicitly allowed, and
i suspect quite common - there's no way for a parser using a pluggable DOM
implementation to set it). This meant that there was no way to make a
valid XML document from it, since such a thing requires a doctype. Cue
colossal parsing errors on the other side ...
That shouldn't matter in your situation, though.
tom