2

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

Siyon DP
  • 504
  • 6
  • 20
  • This is somehow not like XSLT works. XSLT is a template language applying changes / modifications based on some rules while manually editing a XML document does not produce any meaningful rules to apply to all similar data structures. Read a good XSLT reference, start thinking about which changes you want to do, and then write some templates. – Matthias Nov 05 '13 at 06:30
  • Thank's for the quick remark, see updated question – Siyon DP Nov 05 '13 at 09:10

2 Answers2

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.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
0

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.

Mathias Müller
  • 22,203
  • 13
  • 58
  • 75