简短的问题:如何处理 xml 输入文件中的原始 & 符号。
添加:我什至没有选择带有&符号的字段。解析器抱怨文件中存在&符号。
长解释:我正在处理通过 url 响应生成的 xml。
<NOTE>I%20hope%20this%20won%27t%20require%20a%20signature%3f%20%20
There%20should%20be%20painters%20%26%20stone%20guys%20at%20the
%20house%20on%20Wednesday%2c%20but%20depending%20on%20what%20time%20
it%20is%20delivered%2c%20I%20can%27t%20guarantee%21%20%20
Also%2c%20just%20want%20to%20make%20sure%20the%20billing%20address
%20is%20different%20from%20shipping%20address%3f
</NOTE>
这是 url 解码成这样:
<NOTE>I hope this won't require a signature?
There should be painters & stone guys at the
house on Wednesday, but depending on what time it is delivered, I can't guarantee!
Also, just want to make sure the billing address is different from shipping address?
</NOTE>
问题:由于“painters & stone guy”中的“&”,xslproc 在最后一个字符串上阻塞,并出现以下错误:
xmlParseEntityRef: no name
<NOTE>I hope this won't require a signature? There should be painters &
看起来 xsltproc 需要关闭</NOTE>
我在不同的地方尝试了各种方式disable-output-escaping="yes"
。xsl:output
和xsl:value-of
并且也尝试过xsltproc --decode-uri
但无法弄清楚那个。没有文档。
注意:我想知道是否值得将输入保持为 urlencoded 格式。并使用 DOCTYPE.. 如下所示(不知道该怎么做)。输出最终是一个浏览器。
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
]>