是否有任何正式方法或已知方法来规范化xml文件以生成差异?

问题描述:

WRT工具似乎会在xml之间生成差异,但仍然存在很多问题,所以还没有这个问题,所以任何知道此事的人都会向我显示链接或粘贴任何已经解决此问题的示例。

There seems to be many questions WRT tool to generate diffs between xmls, but there wasn't this question yet, so anyone who knows this show me a link or paste any example anyone already solved this problem.

规范化xml文件意味着

Canonicalizing an xml file means,


  • 重新排列属性的外观

  • 重新排列标签的外观(可通过命令行选项选择)

  • 如果结束没有结束,则插入行尾(CR / CR + LF / LF)标签

  • 插入缩进选项卡(空格)

  • 删除多余的空格和行尾

  • reordering the appearance of attributes
  • reordering the appearance of tags (selectable by command line option)
  • insert line ending(CR/CR+LF/LF) if there isn't at the end of a close tag
  • insert indentation tab(space)
  • remove redundant spaces and line endings

然后您可以清晰地比较xml文件以查看更新的部分。

And then you can cleanly diff the xml files to see which part was updated.

我想使用例程在UNIX环境中规范化,然后在签入版本控制存储库之前尽快。

I want to use the routine to canonicalize in unix environment, as quick as possible, before checking in to version control repository.

XMLStarlet 具有规范化模式de( c14n )。

XMLStarlet has a canonicalization mode (c14n).