[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Microsoft.XMLDOM UTF-8 Encoding!

Subject: Re: Microsoft.XMLDOM UTF-8 Encoding!
From: Daniel Bibbens <dbibbens@xxxxxxxxxx>
Date: Fri, 11 Jul 2003 21:51:17 -0500
microsoft.xmldom doctype
This comes up on this list every so often. I've gone through this,
too. The secret is to get all the encoding to match. You have the
least amount of control over the browsers, so target their default
settings. Here's what works for me:

For outputting (X)HTML (note the encoding) -

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns:cvs="http://www.cvshome.org/docs/manual/"
  cvs:id="$Id: index.xsl,v 1.1 2003/06/24 18:32:00 dbibbens Exp $"> 

  <xsl:output 
    method="xml"
    media-type="text/html"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
    doctype-system="DTD/xhtml1-strict.dtd"
    cdata-section-elements="script style"
    encoding="ISO-8859-1"/>

  <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml" 
      cvs:id="$Id: index.xsl,v 1.1 2003/06/24 18:32:00 dbibbens Exp $">
      <head>
        <link rel="stylesheet" type="text/css" href="/css/xo.css"/> 
        ...
      </head>
      <body>
      ...
      </body>
    </html>   
  </xsl:template>  
</xsl:stylesheet>

The above produces the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html 
  xmlns="http://www.w3.org/1999/xhtml" 
  xmlns:cvs="http://www.cvshome.org/docs/manual/" 
  cvs:id="$Id: index.xsl,v 1.1 2003/06/24 18:32:00 dbibbens Exp $">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    ...
  </head>
  <body>
  ...
  </body>
</html>

 
For outputting XML (again note the ecoding):

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
     xmlns:cvs="http://www.cvshome.org/docs/manual/cvs_12.html"
     cvs:id="$Id: catalog-item.xsl,v 1.2 2003/06/24 19:15:20 dbibbens Exp $">

  <xsl:import href="http://xobjex.com/model/share/instance-id.xsl?print=src"/>

  <xsl:output method="xml" encoding="utf-8"/>

  <xsl:template match="/">
    <xsl:call-template name="catalog-item"/>
  </xsl:template>

  <xsl:template name="catalog-item">

    <xsl:element name="catalog-item">
      <xsl:attribute name="instance-id">
        <xsl:call-template name="instance-id"/>
      </xsl:attribute>
      <xsl:attribute name="cvs:id">
        <xsl:text>$Id: catalog-item.xsl,v 1.2 2003/06/24 19:15:20
      dbibbens Exp $</xsl:text>
      </xsl:attribute>
      <xsl:element name="name">
        <xsl:value-of select="//@name"/>
      </xsl:element>
      <xsl:element name="description">
        <xsl:value-of select="//@description"/>
      </xsl:element>
      <xsl:element name="attributes">
        <xsl:for-each select="//@attribute">
          <xsl:element name="attribute">
            <xsl:attribute name="name">
              <xsl:value-of select="substring-before(.,',')"/>
            </xsl:attribute>
            <xsl:attribute name="value">
              <xsl:value-of select="substring-after(.,',')"/>
            </xsl:attribute>
          </xsl:element>
        </xsl:for-each>
      </xsl:element>
      <xsl:element name="graphics">
        <xsl:for-each select="//@graphic">
          <xsl:element name="graphic">
            <xsl:attribute name="uri">
              <xsl:value-of select="."/>
            </xsl:attribute>
          </xsl:element>          
        </xsl:for-each>
      </xsl:element>      
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>

Which produces:

<?xml version="1.0" encoding="utf-8"?>
<catalog-item 
     xmlns:cvs="http://www.cvshome.org/docs/manual/cvs_12.html" 
     instance-id="Pw9szxiUGC0AAV1ke@8" cvs:id="$Id: catalog-item.xsl,v 1.2
     2003/06/24 19:15:20 dbibbens Exp$">
   <name></name>
   <description></description>
   <attributes>
     <attribute name="color" value="blue"/>
     <attribute name="color" value="red"/>
   </attributes>
   <graphics/>
</catalog-item>

"[Tech]" <tech@xxxxxxxxxxx> writes:

> Hi,
>
> I create a valid UTF-8 encoding XML file with "Microsoft.XMLDOM".
> It's OK when a parse my XML/XSL with ASP.
>
> But not if I open the file directly with Mozilla or IE
>
> 1. My XML file are OK
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl" href="sauve.xsl"?>
>
> 2. My XSL file
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="html" encoding="UTF-8" indent="no"/>
>
> 3. And I force the "Content-Type"!
> <xsl:template match="/">
>    ...
> =>>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
>   ...
>
> Mozilla say (File info tab) that is "ISO" file but say about "Content-Type"
> == >text/html; charset=UTF-8
>
> Gorgeous!
>
> Tx
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.