Re:ouputting <?xml version="1.0"?> through stylesheet.

Subject: Re:ouputting <?xml version="1.0"?> through stylesheet.
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Wed, 24 May 2000 09:59:20 +0100
Srirangababu,

>Can anyone tell me how can i output the statment 
><?xml version="1.0"?> using stylesheet.

The big realisation is that you don't have to construct an XML declaration
(the statement <?xml version="1.0"?>) by hand within the stylesheet.
Instead, the xsl:output element gives instructions about how and whether to
output the XML declaration (and the DOCTYPE) for the generated XML document.

This is covered by Section 16 (Output) of the XSLT Recommendation
<http://www.w3.org/TR/xslt#output>.

The first thing that you need to do is make sure that the output method is
'xml'.  By default, it should be 'xml' unless the document element in your
output is 'html', in which case the output method is set as 'html'.  To
make sure that the output method is 'xml', put an xsl:output element in
your stylesheet, like:

<xsl:output method="xml" />

If the output method is 'xml', then the XSLT processor will often
automatically generate an XML declaration.  If the XSLT processor you're
using doesn't give an XML declaration even though the output method's
'xml', then you can try forcing by telling it the XML declaration should
*not* be omitted:

<xsl:output method="xml" omit-xml-declaration="no" />

That should give you the basic XML declaration.  If you want to change the
content of the XML declaration, then there are three other attributes on
xsl:output that do that:

1. version    - changes the version information (e.g. version="1.0")
2. encoding   - changes the encoding declaration (e.g. encoding="UTF-8")
3. standalone - changes the standalone declaration (e.g. standalone="no")

I hope that helps.

Cheers,

Jeni

Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email
jeni.tennison@xxxxxxxxxxxxxxxx



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


Current Thread