Track changes to XML file in XSLT format

独自空忆成欢 提交于 2019-12-13 00:26:08

问题


I need to update XML data from time to time

  1. Add elements orderly.
  2. Change attribute values keeping others (user specific data) untouched
  3. Some other.

If I could :

  • Open xml editor
  • Change the xml like it should be
  • Press a buton that will compare original file with edited ver.
  • Save the differences as XSLT file

    then apply the XSLT diff file on each user data,

That would be great! Didn't find a tool like this on the net

Any suggestions?? Thanks ahead


回答1:


So, basically, you want to manipulate an XML file and have your tool work out the XSLT stylesheet it would take to produce the same output? To my knowledge, there is no such tool.

But of course XSLT is there to spare you the need to alter your XML files by hand alltogether. Rather, you do the following:

  1. Identify the changes to the XML files (i.e. which elements, attributes, nodes need to be modified, deleted, added?)
  2. Write a stylesheet that adresses (matches) these nodes and process them

If, in the course of writing your stylesheet, you encounter any problems, that's when you come back here, share your code and get help.




回答2:


There are tools like DeltaXML that will compare two XML documents and give you a third document listing the differences. It's feasible to take this list of differences and generate a stylesheet that will perform the transformation from either of the two input documents to the other. However, generating a stylesheet that will still do something useful if either of the inputs has changed is of course tricky - this is the general problem of merging changesets and handling conflicts.



来源:https://stackoverflow.com/questions/19782528/track-changes-to-xml-file-in-xslt-format

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