xmlxsltxml-declaration

Capitalization of "encoding" value in XML declarations


I am facing some problems with XML casing. I need to produce the following XML declaration using a XSLT file:

<?xml version="1.0" encoding="ISO-8859-1" ?>

However, after this gets processed by my XSLT engine, the declarations changes the character casing from an all-caps ISO to purely small cap iso.

<?xml version="1.0" encoding="iso-8859-1" ?>

My questions were:

  1. Are there any significant differences between these two declarations?
  2. Is it possible to retain the capitalisation of ISO?

Solution

  • As part of 1) of your question has already been answered by the question referenced in Tangelo's comment, I will just address part 2).

    You should be able use the element to control the encoding via the 'encoding' attribute. The value of the attribute should be emitted exactly as you specify its case in the style-sheet.

    Example:

    <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" />
    

    However, having said that, please note this extract from the XSLT 1.0 spec ...

    • encoding: specifies the preferred character encoding that the XSLT processor should use to encode sequences of characters as sequences of bytes; the value of the attribute should be treated case-insensitively; the value must contain only characters in the range #x21 to #x7E (i.e. printable ASCII characters); the value should either be a charset registered with the Internet Assigned Numbers Authority [IANA], [RFC2278] or start with X-

    That means there is no absolute guaranteed way to control the case genererically across all XSLT processors, so now the question comes down to what is your XSLT processor? The answer will be vendor specific.