This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: omit-xml-declaration="yes" doesn't work
- To: xsl-list <XSL-List at lists dot mulberrytech dot com>
- Subject: [xsl] Re: omit-xml-declaration="yes" doesn't work
- From: Alex Hunsley <lard at tardis dot ed dot ac dot uk>
- Date: Fri, 19 Oct 2001 12:27:58 +0100
- References: <3BD00B00.B7931C4@tardis.ed.ac.uk>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Alex Hunsley wrote:
>
> Note: I've searched the xsl-dev archives and found people talking about
> this problem, but couldn't find a solution.
>
> I'm using jaxp-1.1 (saxon) to do transformations to some xhtml so I can
> display it as html. It all works fine, except that the
> omit-xml-declaration="yes" instruction seems to be ignored.
>
> The complete xsl:output element in my stylesheet is as follows:
>
> <xsl:output method="html" omit-xml-declaration="yes" indent="yes"/>
>
> The document output from the transformation still has the following
> first line:
>
> <?xml version="1.0" encoding="iso-8859-1"?>
>
> which it shouldn't, as far as I can see.
>
> Can anyone offer any advice on this problem?
>
> thanks
Problem solved! Someone kick me...
the solution, for the benefit of anyone else wondering: you set a
property on the Transformer object before doing the transform, as
follows:
// set properties on the transformer so
// we don't get an xml declaration in output
Properties props = new Properties();
props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperties(props);
// do the transformation
transformer.transform(transformSource, result);
cheers
alex
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list