Transforming/Outputting special characters (e.g. alpha)

Here should go questions about transforming XML with XSLT and FOP.
jsb
Posts: 20
Location: Houston, Texas, USA

Transforming/Outputting special characters (e.g. alpha)

Thu Dec 08, 2005 4:31 am

I have an XML source file that I transform through an XSL file.
When the word "beta-rad" is encountered, I try to replace that with an actual greek beta symbol. I am using this in my xsl file:

<xsl:when test="$property_string = 'beta-rad'">
(&#x3B2;<sub>rad</sub>)
...

On Windows XP, using Internet Explorer 6, I get the desired result. Under Windows 2000, using IE 6, I get this:

[ (qbar) (Sw) (bw) (αrad) (rudder-pos-rad) (table) ]

Does anyone know why it's a different result on the two machines?

Jon
Jon Berndt
Development Coordinator
JSBSim Project
Open Source Flight Dynamics Model
http://www.jsbsim.org
george
Site Admin
Posts: 2100

Thu Dec 08, 2005 11:46 am

Hi Jon,

It is not a different result, it is a difference in how that result is rendered. The output that you get is in both cases encoded in UTF-8 and in the first case the browser renders that as UTF-8 and you see the correct result and in the second case the browser uses some other encoding and you see a different result. Try setting the encoding in the second case to UTF-8 and you should see the beta character.

Also if you generate the charset in the output HTML then the browser should know what encoding to use, for instance the following stylesheet applied on any XML file generates the output below that contains the charset specified as UTF-8:

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" encoding="UTF-8"/>   
    <xsl:template match="/">
        <html>
            <head></head>
            <body>               
                (&#x3B2;<sub>rad</sub>)
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>


Code: Select all

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   </head>
   <body>
     
      (β<sub>rad</sub>)
     
   </body>
</html>


Best Regards,
George
jsb
Posts: 20
Location: Houston, Texas, USA

Thu Dec 08, 2005 2:58 pm

george wrote:Hi Jon,

It is not a different result, it is a difference in how that result is rendered. The output that you get is in both cases encoded in UTF-8 and in the first case the browser renders that as UTF-8 and you see the correct result and in the second case the browser uses some other encoding and you see a different result. Try setting the encoding in the second case to UTF-8 and you should see the beta character.

...

Best Regards,
George


Hi, George,

Thanks for the help - that fixed it, of course.

Best regards,

Jon
Jon Berndt

Development Coordinator

JSBSim Project

Open Source Flight Dynamics Model

http://www.jsbsim.org

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest