xml: ignoring difference in similar numbers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stefano
    Visitor
    • Feb 2016
    • 4

    xml: ignoring difference in similar numbers

    Hello,
    I have to compare lots of "similar" numbers in XML files, and consider them different only if their difference is greater than some value.

    As an example the difference between these files should be ignored by beyond compare:

    file 1: <DETAIL COD="C13" VAL="133,95"/>
    file 2: <DETAIL COD="C13" VAL="134,02"/>

    Is it possible by configuring some option, or maybe even writing some sort of plugin?

    Thanks.
  • Aaron
    Team Scooter
    • Oct 2007
    • 16001

    #2
    Hello,

    BC4 do not have a numerical tolerance value in our Text Compare (the session for XML files). We could define a grammar element to ignore specific text mask, but can't compare the numeric value between both sides.

    We do have a numeric tolerance in the Table Compare, but this session type is for data files such as CSV, with Rows/Columns and not XML files.

    Adding support for this type of comparison is on our wishlist, but is not a feature we'll be able to tackle short term. Would helping define a grammar to ignore this section of the node help? Unimportant Differences are still differences until the Ignore Unimportant Differences toggle is enabled, so you could toggle between showing and hiding any differences that occur.
    Aaron P Scooter Software

    Comment

    • stefano
      Visitor
      • Feb 2016
      • 4

      #3
      Thank for your fast reply.
      Defining a grammar would not help, unfortunately, but I can develop a tool to convert my XML files to CSV and then use the numeric tolerance in table compare, like you said. Can you provide me guidelines on how to do that?
      Thanks in advance.

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 16001

        #4
        Hello,

        I'm unsure how to help with the XML to CSV conversion command line utility, but you can define a new File Format in the Tools menu -> File Formats dialog, New: Table format. This format, in the Conversion tab, can accept any command line utility that takes a source %s input, and exports a temporary text %t output. The %t file is the file we would open in the comparison view. It would run once for each side, so the intended conversion in this case would be a source .xml and outputs a temporary .csv file. The format mask can be assigned as *.xml. When launching the Table compare, and opening an .xml file, it would open with this format and perform the conversion in the background.
        We have a sample KB article discussing this with RESX files in the Text Compare, here:
        http://www.scootersoftware.com/suppo...rnalconversion

        The Table Compare's Session menu -> Session Settings, Columns tab, contains cells for each column of each file. You can Edit a column pair and set a Numeric tolerance. Or, Edit Defaults to add a Numeric tolerance for any Numeric columns. Note, the column must contain only numbers to be detected as Numeric. Session Settings can be saved in that specific View, updated for a parent Folder Compare session, or set as a new default for all future Table Compare sessions.
        Aaron P Scooter Software

        Comment

        • stefano
          Visitor
          • Feb 2016
          • 4

          #5
          OK. I'll try and then report here.
          Thanks!

          Comment

          • stefano
            Visitor
            • Feb 2016
            • 4

            #6
            Hello Aaron,
            I wrote a simple bat file to convert xml into csv, using xml starlet utility. I used this script in conversion tab, and then added a numeric tolerance, like you suggested. I have not fully tested it yet, but seems to work correctly.
            Thanks!

            Comment

            Working...