Re: [xsl] Upper ASCII chars

Subject: Re: [xsl] Upper ASCII chars
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 5 Feb 2002 07:35:02 +0000
Hi Jay,

> I get the following in the file:
>
>    <param name="input1" 
> value="&pound;&copy;&reg;&Auml;&Euml;&Oacute;&aacute;&ouml;&yuml;.DTD">
>
> What I want, though, is:
>
>    <param name="input1" value="£©®ÄËÓáöÿ.DTD">
>
> Is there a way to achieve this?

It depends on what processor you're using. The XSLT 1.0 Rec states
that if the output method is html and the processor knows the
character entity reference for a character, then that character may be
output using the character entity reference, which is what you're
experiencing.

Some processors, notably Saxon (someone tell me if other processors
offer this) give you a bit of control over how you want the characters
to be serialized. With Saxon, you can do:

  <xsl:output method="html"
              saxon:character-representation="native;entity" />

to tell Saxon to serialize non-ASCII characters that can be serialized
as native characters in your character encoding as native characters,
and those that cannot be represented in your character encoding as
entities (if Saxon knows such an entity). This should give you the
result that you're after (assuming that the characters that you're
using are representable within your encoding).

[There's been a recent suggestion on xsl-editors@xxxxxx that a similar
functionality to saxon:character-representation be offered in XSLT 2.0
- you might want to post this example there to demonstrate another use
case.]

As an alternative, you could change the output method to xml and
generate well-formed HTML (or full XHTML if you want). The characters
won't be represented as entities in that case because XSLT 1.0
processors can't tell the difference between normal XML and
well-formed HTML, so won't escape any of the characters.

Out of interest, are you experiencing problems with browsers
recognising the character entity references, or is it purely that you
don't like the space that they take up, or find them less readable
than the native characters?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread