简体   繁体   English

Java / XSL:jre 1.5和jre 1.6之间的转换结果不同

[英]Java / XSL: Transformation result different between jre 1.5 and jre 1.6

I have just been working on an old Java app and switched the jre from 1.5 to 1.6. 我刚刚在开发一个旧的Java应用程序,并将jre从1.5切换到1.6。 The app uses xsl to transform xml to html and this had been working fine until I changed the jre. 该应用程序使用xsl将xml转换为html,并且在我更改jre之前一直运行良好。

Here is a extract from the xsl and xml: 这是xsl和xml的摘录:

XML XML

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

XSL 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 使用jre 1.5的结果如下所示

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

The result with jre 1.6 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; 为什么1.5转换&amp; to & and 1.6 not? &和1.6不? What can I do to correct this? 我该怎么做才能纠正这个问题?

The output that you are now getting with jre 1.6 is correct. 您现在通过jre 1.6获得的输出是正确的。

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. 可能是XALAN的早期版本中存在一个错误,该错误已在Java 1.6中包含的版本中得到纠正。

Looking at the input XML, if the intent was to have an entity reference for ä , then it should be &#228; 查看输入XML,如果要使用ä的实体引用,则应为&#228; , not &amp;#228 (which is just an entity reference for & followed by the string #228; , not an entity reference for ä ). ,而不是&amp;#228 (这只是&的实体引用,后跟字符串#228; ;,不是ä的实体引用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM