6 Replies Latest reply on Jun 2, 2006 2:39 AM by credev

    XML Transformation Encoding

    credev
      Hello, when i do transformation of xml to html and if i have french characters i receive in the html garbage characters instead i tried all encoding starting with utf-8 .... but the problem persist.

      this is my xml
      <MyDoc>
      <TagTR index="PK">
      <TagTD libelle="Emballage">Emballage Intermédiaire</TagTD>
      </TagTR>
      </MyDoc>

      this is part of my my xsl
      <?xml version="1.0" encoding="utf-8"?>
      <xsl:stylesheet
      version="2.0"
      xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"
      xmlns=" http://www.w3.org/TR/REC-html40"
      xml:lang="fr">
      <xsl utput method="html" version="1.0" encoding="utf-8"/>
      <xsl:template match="MyDoc">
      <xsl:for-each select="TagTR">
      <tr>
      <td><xsl:value-of select="TagTD[@libelle='Emballage']" /></td>
      </tr>
      </tr>
      </xsl:for-each>
      </xsl:template>
      </xsl:stylesheet>

      this is the output iam receiving

      Emballage Intermédiaire




      any help please
        • 1. Re: XML Transformation Encoding
          Level 7
          credev wrote:
          > Hello, when i do transformation of xml to html and if i have french characters
          > i receive in the html garbage characters instead i tried all encoding starting
          > with utf-8 .... but the problem persist.
          >
          > this is my xml
          > <MyDoc>
          > <TagTR index="PK">
          > <TagTD libelle="Emballage">Emballage Interm?diaire</TagTD>
          > </TagTR>
          > </MyDoc>

          and what's the xml doc's original encoding? what ver of cf? are you "touching"
          the xml doc using cffile, etc.?


          • 2. Re: XML Transformation Encoding
            credev Level 1
            my xml is <?xml version="1.0" encoding="utf-8"?><MyDoc/> created with cfxml

            the thing is that iam creating an xmlDoc loaded in memory ( by retreviving data from DB) then aim transforming this xmlDoc to html usingthe above xsl.

            iam not beeing able to figure out whats going wrong.
            • 3. Re: XML Transformation Encoding
              tooMuchTrouble Level 3
              now that i see this stuff in the forums, it really looks like a simple encoding issue. but your xsl isn't complete enough for me to test to see where the issue actually lies.
              • 4. Re: XML Transformation Encoding
                credev Level 1
                well infact thats my xsl

                <?xml version="1.0" encoding="utf-8"?>
                <xsl:stylesheet
                version="2.0"
                xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"
                xmlns=" http://www.w3.org/TR/REC-html40"
                xml:lang="fr">

                <xsl utput method="html" version="1.0" encoding="utf-8"/>
                <xsl:template match="MyDoc">
                <xsl:for-each select="TagTR">
                <tr class="Arial_2_noir" height="10" align="left" valign="top" bgcolor="#CCCCCC">
                <td><xsl:value-of select="TagTD[@libelle='Emballage']" /></td>
                </tr>
                </xsl:for-each>
                </xsl:template>
                </xsl:stylesheet>

                and the xml doc is
                <?xml version="1.0"?>
                <MyDoc>
                <TagTR>
                <TagTD libelle="Emballage">Emballage Intermédiaire</TagTD>
                </TagTR>
                </MyDoc>
                • 5. Re: XML Transformation Encoding
                  Level 7
                  credev wrote:
                  > well infact thats my xsl

                  not to nit pick but that's not the same code & you did say it was "part". in any
                  case that xsl works. i output unicode hindi, arabic, thai, japanese, etc. ok. so
                  it's not cf, your xml or xsl. see: http://www.sustainablegis.com/unicode/xml/
                  using this code:

                  =====================
                  <cfprocessingdirective pageencoding="utf-8">
                  <cfquery name="getU" datasource="#dsn#">
                  SELECT uniText
                  FROM unicodeTest
                  ORDER BY uniLanguage
                  </cfquery>

                  <cfset xslFile=getDirectoryFromPath(GetCurrentTemplatePath())&"test.xsl">
                  <cffile action="read" file="#xslFile#" variable="xslDoc" charset="utf-8">

                  <cfxml variable="MyDoc">
                  <?xml version="1.0" encoding="utf-8"?>
                  <MyDoc>
                  <cfoutput query="getU">
                  <TagTR index="PK">
                  <TagTD libelle="Emballage">#uniText#</TagTD>
                  </TagTR>
                  </cfoutput>
                  </MyDoc>
                  </cfxml>

                  <cfset transformedXML = XmlTransform(mydoc, xslDoc)>

                  <table><cfoutput>#transformedXML#</cfoutput></table>
                  =====================

                  btw i don't like what the transform did to the vietnamese (last row in the table).

                  what ver of cf? if you dump the data out of the database via cf using utf-8
                  encoding, does it work? what encoding turns up in your browser when you run your
                  cf page?

                  • 6. Re: XML Transformation Encoding
                    credev Level 1
                    Well i should say thank you alot... you just fixed my problem

                    i added <cfprocessingdirective pageencoding="utf-8"> to the top page where iam loading my xml and it worked!

                    thank you