问题
I need to update XML data from time to time
- Add elements orderly.
- Change attribute values keeping others (user specific data) untouched
- 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:
- Identify the changes to the XML files (i.e. which elements, attributes, nodes need to be modified, deleted, added?)
- 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