xsl-list
[Top] [All Lists]

RE: declare the charset by an output element not the xml declaration?

2004-06-16 10:33:42
The short answer is: No.

The long answer:
As far as I know, your XSL processor is going to output UTF-8 unless you tell 
it otherwise. You do this through an output element, or by configuring the 
transformer. It may be possible with some command line transformers to pass in 
the output encoding that you want, I don't generally do command line 
transformations though...

When you place the encoding in the xml declaration you are telling the parser 
how that document is encoded, and thus how to interpret the bytes as it reads 
them from the file (or other source). Once the document has been parsed its 
generally going to end up as UTF-16 (at least in the java world). This is the 
same in any xml file, which includes xsl and xhtml files. The output element in 
XSL is used to determine how the bytes of the output document are going to be 
serialized to the disk (or other destination)

The meta tag in html serves the same purpose as the encoding attribute in the 
xml processing instruction, which is to tell the browser how the bytes of that 
file are to be interpreted.

Josh

-----Original Message-----
From: Markus Hanel [mailto:markus(_dot_)hanel(_at_)gmx(_dot_)at]
Sent: Wednesday, June 16, 2004 1:12 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] declare the charset by an output element not the xml
declaration?


Hallo,
the encoding is placed in two files:
1. the xml file: 
2. the xsl stylesheet

Is it possible to place the encoding in the xml declaration of the xml file
to "ISO-8859-1", set no encoding in the xml declaration of the the xsl
stylesheet and create the html output with a meta tag with charset
"ISO-8859-1"?
markus

You are creating an output element in your html, which html is not going
to understand. You need to use a meta tag, as previously mentioned.

The other problem is that by default your output is going to be in UTF-8,
unless you have set the serializer to output something different. For
example, in Java you can use the Transformer.setOutputProperty() method to
override the encoding in the stylesheet.

Josh

-----Original Message-----
From: Markus Hanel [mailto:markus(_dot_)hanel(_at_)gmx(_dot_)at]
Sent: Tuesday, June 15, 2004 7:40 AM
To: xsl mailinglist
Subject: [xsl] declare the charset by an output element not the xml
declaration?


Hallo,
we want to hold the charset of the stylesheet flexibel. Is it well formed
to
give no encoding in the xml declaration but in the output element?

Many thanks,
markus

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/">
<html>
<head>
<xsl:processing-instruction name='output'>
  <xsl:text>method="html"
</xsl:text><xsl:text>encoding="</xsl:text><xsl:value-of
select="$etc/et[attribute::name = 'charset']" /><xsl:text>"</xsl:text>
</xsl:processing-instruction>
<title></title>
</head>

<body>
  <xsl:apply-templates />
</body>
</html>
</xsl:template>


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



<Prev in Thread] Current Thread [Next in Thread>