Is there any formal way or known way to canonicalize an xml file to generate diffs?

你离开我真会死。 提交于 2019-12-22 08:53:10

问题


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.

Canonicalizing an xml file means,

  • 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

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

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


回答1:


XMLStarlet has a canonicalization mode (c14n).




回答2:


Instead, you could use the xmldiff tool: Using the XML Diff and Patch Tool in Your Applications

The XML Diff and Patch GUI Tool



来源:https://stackoverflow.com/questions/2019149/is-there-any-formal-way-or-known-way-to-canonicalize-an-xml-file-to-generate-dif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!