Altova Mailing List Archives


RE: [xsl] Understanding xmlns declaration and encoding

From: "Michael Kay" <mhk@--------->
To:
Date: 9/8/2004 6:16:00 PM
> When I exclude this
> xmlns="http://www.w3.org/1999/xhtml"
> 
> from the stylesheet decleration, I notice that <br/> tags and 
> <hr/> tags
> end up like this: <br> and <hr>.  Including it results in the 
> <html> tag
> looking like this:
> <HTML xmlns="http://www.w3.org/1999/xhtml">
> 
> and the <br> and <hr> tags are now <br/> and <hr/> in the result.
> 
> Is this all confirmed and normal behaviour?

Yes. The output method defaults to HTML if the outermost element in the
result tree is an <html> element in the null namespace. And whether or not
the output method is HTML, elements in a non-null namespace are serialized
using XML rules, so an empty <br> element in the XHTML namespace is written
as <br/>.
> 
> I guess I don't understand when:
> <xsl:output method="html" encoding="??????????"/>
> The encoding has any effect on the outcome.
> 

The encoding parameter affects the outcome if (a) you are using the XSLT
processor to do the serialization (and not, say, the DOM save method), and
(b) the destination of the output is a byte stream rather than a character
stream. A common mistake for Microsoft users is to serialize to a character
stream, in which case the final encoding is outside the control of the XSLT
processor.

Michael Kay

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.