如何在xslt转换中保留十六进制代码?
输入:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
<root>
<p>This is sample character í</p>
</root>预期产出:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/">
<root>
<p aid:pstyle="para">This is sample character í</p>
</root>发布于 2014-02-24 13:00:11
使用字符映射控制输出序列化。您可以找到XSL规范这里的相关部分。
注意,您的代码还有其他问题。样式表必须包含可以触发的模板,例如xsl:template match="/"。否则,任何东西都不会被序列化。
另外,我不知道这与输入XML文档有什么关系,因为内容完全来自XSLT样式表。
样式表
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output use-character-maps="my-map" indent="yes"/>
<xsl:character-map name="my-map">
<xsl:output-character character="í" string="&#x000ED;"/>
</xsl:character-map>
<xsl:template match="/">
<root>
<p pstyle="para">This is sample character í</p>
</root>
</xsl:template>
</xsl:stylesheet>输出
<?xml version="1.0" encoding="UTF-8"?>
<root>
<p pstyle="para">This is sample character í</p>
</root>https://stackoverflow.com/questions/21988041
复制相似问题