[英]Java: XSLT with output HTML but without HTML entities
Is it possible to to a XSL transformation mit xsl:output method set to HTML but without using HTML entities in the output? 是否可以将XSL转换mit xsl:output方法设置为HTML但不在输出中使用HTML实体? The output should either use numeric entities or no entities at all (as i am using UTF-8 entities are not required).
输出应该使用数字实体或根本不使用实体(因为我不需要使用UTF-8实体)。
You can use disable-output-escaping
. 您可以使用
disable-output-escaping
。 Using this input: 使用此输入:
<test>Café</test>
with this XSL stylesheet: 使用此XSL样式表:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="test">
<xsl:copy>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
will render: 将呈现:
<test>Café</test>
But if you add disable-output-escaping="yes"
to <xsl:value-of>
: 但是如果你将
disable-output-escaping="yes"
到<xsl:value-of>
:
<xsl:value-of select="." disable-output-escaping="yes"/>
you get: 你得到:
<test>Café</test>
You might also get unescaped HTML if you use a transformer that doesn't escape HTML by default, such as Saxon 9. I also believe you can configure Xalan to not escape HTML entities by default. 如果您使用默认情况下不会转义HTML的转换器(例如Saxon 9),您也可能会获得非转义HTML。我还相信您可以将Xalan配置为默认情况下不转义HTML实体。
You can try a different transformer which disables output escaping by default. 您可以尝试使用另一个默认禁用输出转义的变换器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.