我正在使用 XslCompiledTranform
来转换XML / XSL .
这是我的测试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
表现得那样?我想要我的属性 exactly 我指定它们的方式并没有进行魔法转换 .
我的设置如下:
var oXSL = new XslCompiledTransform( );
XsltSettings oXslSettings = new XsltSettings( );
XmlUrlResolver oUriResolver = new XmlUrlResolver( );
oXslSettings.EnableDocumentFunction = true;
oXslSettings.EnableScript = false;
oXSL.Load( sXslPath, oXslSettings, oUriResolver );
勒内
1 回答
欲了解更多信息,请阅读规范:http://www.w3.org/TR/xslt#section-HTML-Output-Method
使用
<xsl:output method="xml"/>
输入XML:
XSLT:
C#源代码:
输出: