tags:

views:

151

answers:

1

I have just been working on an old Java app and switched the jre from 1.5 to 1.6. The app uses xsl to transform xml to html and this had been working fine until I changed the jre.

Here is a extract from the xsl and xml:

XML

<link href="Uml&amp;#228;ut.txt" target="_blank">
    <style tag="text">Umläut.txt</style>
</link>

XSL

<xsl:template match="link">
    <xsl:element name="td">
        <xsl:element name="a">
            <xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
            <xsl:attribute name="target"><xsl:value-of select="@target"/></xsl:attribute>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:element>
</xsl:template>

The result using jre 1.5 looks like this

<td><a href="Uml&#228;ut.txt" target="_blank">
    <text>Uml&auml;ut.txt</text>
</a></td>

The result with jre 1.6

<td><a href="Uml&amp;#228;ut.txt" target="_blank">
    <text>Uml&auml;ut.txt</text>
</a></td>

Can anyone explain what has gone wrong here? Why does 1.5 convert &amp; to & and 1.6 not? What can I do to correct this?

+3  A: 

The output that you are now getting with jre 1.6 is correct.

It may be that there was a bug in the earlier version of XALAN that has been corrected in the version included in Java 1.6.

Looking at the input XML, if the intent was to have an entity reference for ä, then it should be &#228;, not &amp;#228 (which is just an entity reference for & followed by the string #228;, not an entity reference for ä).

Mads Hansen