Xml 如何在xslt转换中保留十六进制代码
如何在xslt转换中保留十六进制代码 输入:Xml 如何在xslt转换中保留十六进制代码,xml,xslt,xslt-2.0,hex,Xml,Xslt,Xslt 2.0,Hex,如何在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
<?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>
这是示例字符í
使用字符映射控制输出序列化。您将找到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>
这是示例字符í
输出
<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>
这是示例字符í
转换需要哪个XSLT版本(1.0或2.0),到目前为止您尝试了什么?