[英]How to get Saxon to output un-escaped CDATA section
How can I get Saxon to convert a CDATA string into an XdmNode without escaping the < & > ? 如何在不转义<&>的情况下让Saxon将CDATA字符串转换为XdmNode?
Here is my 'ToXdmNode' function: 这是我的“ ToXdmNode”功能:
Processor processor = xxx.GetProcessor();
var builder = processor.NewDocumentBuilder();
builder.BaseUri = xxx.BaseUri;
var tr = new StringReader("<stuff><![CDATA[<blah>]]></stuff>");
var node = builder.Build(tr);
This code converts 此代码转换
<stuff><![CDATA[<blah>]]></stuff>
into an XdmNode that looks like: 到看起来像这样的XdmNode中:
<stuff><blah></stuff>
This causes problems later on when I send the OuterXml onto the next step. 这会在以后将OuterXml发送到下一步时引起问题。
How can I get my XdmNode to be unescaped? 如何使我的XdmNode取消转义?
You say the code converts 你说代码转换
<stuff><![CDATA[<blah>]]></stuff>
into an XdmNode that looks like: 到看起来像这样的XdmNode中:
<stuff><blah></stuff>
but actually that's not a conversion: the two things are just different serializations of the same content. 但这实际上不是转换:这两件事只是同一内容的不同序列化。
If you want to create the non-well-formed string 如果要创建格式不正确的字符串
<stuff><blah></stuff>
then that's tricky using XSLT, because not being XML, this isn't the serialization of any valid XDM node. 那么使用XSLT会很棘手,因为不是XML,这不是任何有效XDM节点的序列化。 However, you can contrive it with the help of disable-output-escaping
. 但是,您可以在disable-output-escaping
的帮助下进行设计。 For example the transformation 例如转换
<xsl:template match="stuff">
<xsl:copy>
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:copy>
</xsl:template>
will produce this output provided that you send the transformation output to a Serializer (and not, for example, to an XdmNode). 如果您将转换输出发送到序列化器(而不是发送到XdmNode),则将生成此输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.