简体   繁体   English

在 xslt 转换期间从输入 xml 中删除与号

[英]Remove Ampersand from an input xml during xslt transformation

I am new to xslt.我是 xslt 的新手。 I have an input xml and that has to be sorted.我有一个输入 xml 并且必须进行排序。 To get the sorted output xml, a xslt has been built and sorting is working fine.为了得到排序的 output xml,xslt 已经构建并且排序工作正常。 But if the one of the tags (sorting is not based on this tag) in the input xml contains '&', the xslt transformation fails while parsing the input xml.但是如果输入 xml 中的标签之一(排序不是基于此标签)包含 '&',则 xslt 转换在解析输入 Z0F635D0E0F3874FFF8B581C132ZEC6 时会失败。 how to escape the '&' in the input xml from compilation.如何从编译中转义输入 xml 中的“&”。

When you say "the input XML contains '&'", that's technically incorrect: if it contains an unescaped '&' then it's not XML.当您说“输入 XML 包含 '&'”时,这在技术上是不正确的:如果它包含未转义的 '&',那么它不是 XML。

If you're asking how to escape the ampersand correctly while generating the XML, then that depends on the tools you are using to generate the XML.如果您在生成 XML 时询问如何正确转义 & 符号,那么这取决于您用于生成 XML 的工具。

If you're asking how to fix broken XML containing unescaped ampersands, then the answer in the general case is that you can't (there's a reason they have to be escaped, after all).如果您要问如何修复损坏的 XML 包含未转义的 & 符号,那么一般情况下的答案是您不能(毕竟它们必须被转义是有原因的)。 But a search for XML and ampersand will find plenty of suggestions for partial solutions.但是搜索 XML 和 & 会发现很多关于部分解决方案的建议。

Thank you very much for your response.非常感谢您的回复。 As you told, the xml was having unescaped '&'.正如你所说,xml 有未转义的“&”。 Example: Test A & B.. So during the xslt transformation, it was failing while parsing the xml.示例:测试 A 和 B.. 所以在 xslt 转换期间,它在解析 xml 时失败。 After making the change in the source system as在源系统中进行更改后
the parsing is working fine.解析工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM