Announcement

Collapse
No announcement yet.

XML file comparison

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML file comparison

    Comparing/Merging XML files is something that I do on an almost daily basis. What's the best way to set this up under BC3? I'd prefer if there was a pre-processor that would "pretty-print" the XML files before comparison in order to rule out that type of differences.

    Under BC2, I think there were 2 ways to handle this, I think there was a built-in method, and then another method that used an external conversion tool (maybe xml tidy).

    What's the preferred way of doing this under BC3? Will XML formatting be built into the final version, or should I go ahead and setup XML Tidy, or some other external conversion?

    Thanks,
    Rob

  • #2
    Hi Rob!

    There is already an entry defined for *.xml in the File Formats dialog.
    But with the factory defaults no conversion is performed before the files are displayed in the file compare.
    When you click on the drop-down-list in the Conversion section of that file type you can see the built-in conversions of BC3. But there is nothing for XML. So currently you must go the same way as with BC2 and setup an external conversion program like tidyHTML.

    But that should be no problem ...


    Bye
    Christoph

    Comment


    • #3
      The XML Tidy, XML Tidy (sorted attributes) rules are for this kind of purpose.

      They both use HTML tidy to pretty-print the XML ; the default config indents each attribute on a separate line.

      Sorting attributes is useful because a lot of XML-emitting tools tend to do what I call "juggle" - the order of things moves around as the tool edits them.

      This is all to do with the internal implementation of the tool writing the XML file ; some tools always serialize using a predictable order (usually ones that serialize an object graph from scratch), some tools (usually ones that manipulate an existing DOM tree in memory) "juggle".

      The rules on the download page can't "un-juggle" element order ; for that, I usually end up writing a small XSLT sheet specifically for the kind of file I'm comparing, which sorts the elements in a consistent order. On Windows, I use the Saxon.NET package to provide a transform program.

      To get the filetype detection right for each type, you have a number of options...

      * You can put more than just filenames in the mask property for a rule - so make your glob match a folder path as well as the file extention.
      * Make your "tidy" script read the schema attribute of the file and pick the right XSLT sheet
      * Give special-purpose XML files a special-purpose file extension (e.g. MyFile.magic.xml, etc)

      Comment


      • #4
        On examination I think this is wrong :

        * You can put more than just filenames in the mask property for a rule - so make your glob match a folder path as well as the file extention.

        I thought I managed to get this work in the office, but I try it at home and it fails.

        You can enable/disable file formats on a per-session basis though, so I've shunted the format down below the default "XML" format (it turns red to let me know it won't match) and disabled the default.

        I'd still like full-path masking to work though - any chance of that, Scooterites? (I'll make another post in the file formats folder)

        Comment


        • #5
          As pointed out to me on another thread..

          The reason I got it to work in the office was because I was comparing files immediately in the folder... use three dots to signify an arbitrary path depth.

          e.g.

          Web_Root\...\*.xml

          Comment

          Working...
          X