Special characters turn out as garbage in xslt->html conversion

Subject: Special characters turn out as garbage in xslt->html conversion
From: Guðmundur Erlingsson <txakolin@xxxxxxxxx>
Date: Fri, 8 Sep 2000 09:03:15 -0000
Hi all,

First of, thanks to all who gave me advice on xslt->html conversion, I have
now solved the problem. Except it led to another problem. But that's life,
right.

Anyway, I have a xml-file with a list of employees. The list is broken into
alphabetical sections. In the XSL-file I put in two loops. The first one
goes through the document and collects data on the alphabetical sections and
outputs an html table that shows all the letters of the alphabets as links
to the appropriate sections. It looks like this:

                <xsl:for-each select="skjal/hluti">
                  <td><a>
                    <xsl:attribute name="href">#<xsl:value-of select="@id"/>

                    </xsl:attribute><xsl:value-of select="@id"/>
                    </a>
                  </td>
                </xsl:for-each>

The second loop goes through the document, one section at a time, prints out
the name of each section and displays appropriate data on employees that
pertain to that section, like this:

            <xsl:for-each select="skjal/hluti">
              <h2>
                <a>
                  <xsl:attribute name="name">
                    <xsl:value-of select="@id"/>
                  </xsl:attribute>
                  <xsl:value-of select="@id"/>
                </a>
              </h2>
               <xsl:for-each select="starfsm">
                <p class="noindent">
                  <xsl:choose>
                    <xsl:when test="starf[.='']"><xsl:value-of
select="nafn"/></xsl:when>
                    <xsl:otherwise><xsl:value-of select="nafn"/>,
</xsl:otherwise>
                  </xsl:choose>
                  <xsl:choose>
                    <xsl:when test="starf[.='']"></xsl:when>
                    <xsl:otherwise><xsl:value-of
select="starf"/></xsl:otherwise>
                  </xsl:choose>
                  <xsl:choose>
                    <xsl:when test="deild[.='']"><br/></xsl:when>
                    <xsl:otherwise><br/><xsl:value-of
select="deild"/><br/></xsl:otherwise>
                  </xsl:choose>
                  <xsl:choose>
                    <xsl:when test="netfang[.='']"></xsl:when>
                    <xsl:otherwise><i>Netfang:</i> <tt><xsl:value-of
select="netfang"/></tt><br/></xsl:otherwise>
                 </xsl:choose>
                 <i>Sími:</i> <xsl:value-of select="simi"/></p><br/>
               </xsl:for-each>
             </xsl:for-each>


So far so good. As I am using Icelandic I put 'encoding="iso-8859-1"' at
beginning of the files, and also use "<xsl:output method="html"/>" (I'm
using instant-saxon for the conversion to html). Everything works ok, except
the "href" attribute. That is, the second loop gives this (for an A with
acute accent): 

      <a name="&Aacute;">&Aacute;</a>

just like it should. If however the html-attribute is "href" the output is
like this in html:

      <a href="#%C3%81">&Aacute;</a>

I have absolutely no idea why this happens and haven't been able to find any
clues. This could of course be a bug in saxon for all I know. Any ideas?

Guðmundur


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


Current Thread