Re: [xsl] encoding <-> omit-xml-declaration

Subject: Re: [xsl] encoding <-> omit-xml-declaration
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 18 Jan 2004 12:16:52 -0500
At 2004-01-18 17:48 +0100, Maia Zaharieva wrote:
i have just noticed, that if i have
    <xsl:output method="xml" omit-xml-declaration="yes"/>
i get the output file with no xml declaration (as it should be).

but if i set the encoding attribute on anything different than UTF-8 the
omit-xml-declaration get ignored and i always get the xml declaration at the
beginning of the output file.

could anyone explain me this correlation?

One function of the XML declaration is to tell an XML processor in what encoding to expect the file, and if the declaration is absent the XML processor is *required to assume* it to be either UTF-8 or UTF-16.


Since you are asking for a character set other than UTF-8 or UTF-16 to be used, the resulting file would not be well-formed if you omitted the XML declaration, thus the XSLT processor is obliged to include it.

Not including it would result in non-well-formed output, which is not allowed for XSLT (unless someone shoots themselves in the foot with disable-output-escaping).

I hope this helps.

....................... Ken

--
North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15
-          (San Francisco, CA): 3-day XSLT/2-day XSL-FO 2004-03-22
Asia        (Hong Kong, China): 3-day XSLT/2-day XSL-FO 2004-05-17
Europe       (Bremen, Germany): 3-day XSLT/2-day XSL-FO 2004-05-24
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread