users@jaxb.java.net

Re: Appending processing instructions

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 13 Sep 2006 15:54:29 -0700

Kasia Trapszo wrote:
> I know the recommended method is to simply output the instruction to
> whatever output stream & disable the com.sun.xml.bind.xmlDeclaration
> property on the marshaller, but that doesn't work so well when
> outputting to a JAXBSource object.
>
> Any suggestions?
>
> code looks something like..
>
> JAXBSource source = new JAXBSource(marshaller, document);
> transfomer.transform(source, new StreamResult(out));
>
> The xsl transformer really does not like this. If I convert to a Dom and
> append a processing instruction to that, it works fine, but it seems
> like an unnecessary conversion step.

True. The only hesitation I have is that this is the only time I need to
produce PI, and there are other things people will want to produce, like
comment, DOCTYPE decl, etc.

If you are feeding this into XSLT, wouldn't it be easier to just use
XSLT to generate the PI?

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com