0
我正在使用XslCompiledTranform
来转换XML/XSL。XslCompiledTransform:属性值编码不正确
这是我的测试XSL:
<span title="{./tooltip}" anattribute="{./tooltip}">
<xsl:value-of select="./tooltip"/>
</span>
你可以看到,测试我把同样的XSL值,即@tooltip
到title
属性,一个未定义的属性anattribute
,也可以作为文本节点。
在我的XML中,@tooltip
编码为“this is a <script> tag
”。更确切地说:值中没有HTML标签。一切都进行编码,因此<
和>
如果我改变上述我得到的结果是:
<span title="this is a <script> tag" anattribute="this is a <script> tag">
this is a <script> tag
</span>
为什么保持节点值的编码,为什么它的属性替代编码值?最重要的是:我该如何阻止XslCompiledTransform
的行为?我希望我的属性完全按照我指定的方式,并且不进行魔术转换。
我的设置如下:
var oXSL = new XslCompiledTransform();
XsltSettings oXslSettings = new XsltSettings();
XmlUrlResolver oUriResolver = new XmlUrlResolver();
oXslSettings.EnableDocumentFunction = true;
oXslSettings.EnableScript = false;
oXSL.Load(sXslPath, oXslSettings, oUriResolver);
勒
我从你的例子中看到的是,你的输出方法= “XML”。那不一样。我的方法=“html”。但是在两者中,<在属性中都是无效的。地狱是我的< and >然后来自哪里? – Krumelur
我试过了。它确实是输出=“html”,它打破了它。它适用于output =“xml”。所以谢谢你的答案,但为什么? – Krumelur
@Krumelur,比使用'output method =“xml”'。有什么问题? –