No announcement yet.

Matching algorithm when inserting xml elements

  • Filter
  • Time
  • Show
Clear All
new posts

  • Matching algorithm when inserting xml elements

    In the attached screen shots, you can see two different ways of matching the same inserted xml element. BC3 seems to switch between them arbitrarily. With only one change, it shows as desired. With an earlier change, it highlights the 'wrong' closing tag. Is there anything I can go to influence this?

    It would be great if I could click within the mismatch, and flip between the two ways of looking at it.

    This problem also affects many other languages, eg, C++ method braces and SQL procedures.

  • #2
    Changing BC's alignment setting might change this, but it doesn't currently provide a good way to control this behavior.

    To change alignment in the Text Compare, select "Session > Session Settings". Go to the "Alignment" tab. Change from "Standard method" to "Alternate method".

    Improving the alignment algorithm is on our wish list for a future version of BC.
    Chris K Scooter Software


    • #3
      Thanks Chris. Changing to alternate did not make any difference. Using Unaligned, simply shows the remainder of the file as mismatched from the opening tag of the new element. Changing the Standard alignment skew, or the closeness option didn't make any difference.

      I notice that Google have released a diff-match-patch suite. How does its algorithm compare with BCs? I wonder if it has control over whether to match the previous, or next closing delimiter, when inserts occur.


      • #4

        Our current algorithm goes line by line, and does not currently match based on the syntax of the language of the file. It is something we are looking into.

        In the meantime, you can highlight multiple lines (an entire node section), and right click and choose Align With, then highlight an entire other node section to force an alignment. You can also do one line at a time.

        If you would like, please send in a pair of sample files to [email protected]. Please also include a link to this forum thread. We can then add the files to our test cases to check against them as we try out new features.
        Aaron P Scooter Software


        • #5
          It looks like the GoogleCode project for diff-match-patch is based on the Myer's diff algorithm, which is the same algorithm our Alternate Alignment setting is based on. They might be doing some extra work to help their results, but the basic algorithm would be similar.
          Aaron P Scooter Software


          • #6
            Hello. It has been 3 years since this discussion. I never sent the files in, but I wonder if this aspect of matching has been improved? In the attached image, it should be possible to show all 6 lines with the text 'this.' highlighted as having been inserted. Thanks!
            Attached Files


            • #7
              BC4 tweaks the Standard and Myers alignment, while also adding the Patience Diff alignment algorithm. If you are unable to send in files, you can try out our BC4 trial without removing or altering your BC3 install:
              Beyond Compare is a multi-platform utility that combines directory compare and file compare functions in one package. Use it to manage source code, keep directories in sync, compare program output, etc.

              The alignment settings are controlled in the Text Compare's Session menu -> Session Settings, Alignment tab.
              Aaron P Scooter Software


              • #8
                Same problem in BC4

                I have upgraded to BC4 and tested the different Alignment settings. None of them make any difference! According to the F1 help, they do not have any effect on the alignment of the mismatch ON A SINGLE LINE.

                What I'm asking for, is that when you find a line that doesn't match then:

                while (character before frame == last character in the frame)
                shift the frame back one character.

                Ideally you would then repeat that for each block of changes - shift it backwards while the characters before the block match the characters at the end of the block.

                I have the attached files (renamed to .txt).

                Hope that makes sense.

                Attached Files


                • #9
                  Ah, thanks for the example files and clarification. I missed that earlier this post was about both line alignment and character alignment.

                  For character (within a line) alignment, we appreciate the example files. The best workaround in the current version is to define a grammar that matches on different logical parts of your line. In these files, you can define a grammar, type Basic, that matches on the "this." prefix, and that then helps influence the character alignment and gets the results you expect. By defining different concepts for your files, this can help the character alignment shift and find matches.
                  Aaron P Scooter Software