xml - 如何在 XSLT 中使用字符映射?

标签 xml xslt

我有这个 XSLT 样式表:

<xsl:stylesheet version="3.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:character-map name="cm">
       <xsl:output-character character="1" string="abc"/>   
       <xsl:output-character character="2" string="def"/>
       <xsl:output-character character="3" string='ghi'/>
    </xsl:character-map>
    <xsl:template match="/">
        123abc
       <abc att="123abc"/>
       <xsl:value-of select="'123abc'"/>
    </xsl:template>
</xsl:stylesheet>

无论我如何尝试,字符映射似乎都不起作用。有人可以告诉我如何让它工作吗?我错过了什么吗?

最佳答案

您已经定义了一个字符映射表,但您没有使用它。尝试:

<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:character-map name="cm">
    <xsl:output-character character="1" string="abc"/>   
    <xsl:output-character character="2" string="def"/>
    <xsl:output-character character="3" string='ghi'/>
</xsl:character-map>

<xsl:output use-character-maps="cm" />

<xsl:template match="/">
    123abc
   <abc att="123abc"/>
   <xsl:value-of select="'123abc'"/>
</xsl:template>

</xsl:stylesheet>

关于xml - 如何在 XSLT 中使用字符映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25830205/

相关文章:

使用 Eclipse 的安卓图形用户界面

C# JsonConvert SerializeXmlNode 空属性

java - 使用 java 验证 .wsdl 文件的 API

xml - XSLT 和 xsl :for-each with a wildcard

java - JAXP XSLT document()函数问题

xml - (xslt 1.0) 如何用 xml 中所有文本值中的一些字符串替换空格?

java - 在不将所有比较数据加载到内存的情况下比较两组 XML 数据

java - Android - 如何使表格行的高度大小等于

css - 如何使用外部 CSS 在 XSL 定义中设置 HTML 兼容标签的样式?

xslt - xsl :param and xsl:variable 之间的区别