不想xslt解释实体字符 [英] don't want xslt intepret the entity characters
本文介绍了不想xslt解释实体字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
xml如下:
< cell i='0' j='0' vi='0' parity='Odd' subType='-1'> & #34;String& #39;</cell>
但是在解释了xsl之后,输出是这样的:
But after the intepretion of the xsl, the output is like this:
< td nowrap="true" class="gridCell" i="0" j="0">"String'< /td>
我想保留&#34;和&#39;。我尝试过字符映射,但是它不起作用。代码如下:
I would like to keep the & #34; and & #39;. I've tried character map,but it doesn't work. The code is like this:
< xsl:character-map name="raquo.ent">
<xsl:output-character character="'" string="&apos;"/>
<xsl:output-character character="'" string="&apos;"/>
< /xsl:character-map>
< xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" use-character-maps="raquo.ent"/>
有人可以帮忙吗?
推荐答案
这种转变:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes"
use-character-maps="raquo.ent"/>
<xsl:character-map name="raquo.ent">
<xsl:output-character character=""" string='&#34;'/>
<xsl:output-character character="'" string='&#39;'/>
</xsl:character-map>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
在应用于提供的XML文档时:
<cell i='0' j='0' vi='0' parity='Odd' subType='-1'>"String'</cell>
产生想要的正确结果:
<cell i="0" j="0" vi="0" parity="Odd" subType="-1">"String'</cell>
这篇关于不想xslt解释实体字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文