No announcement yet.

Aligning XML files by an attribute of an element

  • Filter
  • Time
  • Show
Clear All
new posts

  • Aligning XML files by an attribute of an element

    eg, I'm getting the following alignment happening in a tidied XML file:
    I dont want the <difference node to align (ideally along with all its sub-nodes!) if the fqn attribute value attribute is different

    Text Compare
    Produced: 19/01/2021 09:27:25

    Mode: All, With Context, Just Selection
    16226 <difference objecttype="table" status="different" fqn="table-[dbo].[TRADEFLOW_DocumentHistory]">
    16227 <object llastmodified="2021-01-08 12:12" owner="dbo" id="1">
    16228 TRADEFLOW_DocumentHistory
    14380 <difference objecttype="table" status="different" fqn="table-[dbo].[BILLING_RegisterInvoiceProcessData]">
    14381 <object llastmodified="2021-01-15 12:11" owner="dbo" id="1">
    14382 BILLING_RegisterInvoiceProcessData
    16229 14383 </object>
    16230 <object owner="dbo" rlastmodified="2020-09-28 22:35" id="2">
    16231 TRADEFLOW_DocumentHistory
    14384 <object owner="dbo" rlastmodified="2021-01-14 15:49" id="2">
    14385 BILLING_RegisterInvoiceProcessData
    16232 14386 </object>
    16233 14387 <comparisonstrings>
    16234 14388 <line type="different">

    I've created a grammer for the <difference line, eg
    reg exp of :\<difference .* fqn=".+"

    and tried several other things, but nothing seems to make a difference except for "Never Align Differences" which isnt helpful for the rest of the file as I do want to see differences

    I have BC4 v4.2.9

  • #2

    Defining grammar elements can help influence the line by line alignment that the Text Compare uses, but you will probably need to alter the Session Settings, Alignment tab settings, too. Here you can set different options, such as Never Align Differences (which would prevent the fqn= line from aligning) and try different alignment settings. Of note, Never Align Differences only applies to Important (red) differences. You can define an element to match on only the fqn= line, then mark Everything Else as Unimportant. The Unimportant Blue differences would still align, but the important FQN line wouldn't. Just be careful not to toggle on Ignore Unimportant Differences in this case, as this controls whether Unimportant Differences are treated as Differences or Same text.

    This example is a pretty small set, but if one of the nodes exists on both sides, you may be able to tweak the Alignment settings so that node correctly finds it's match, which would help push the other side as an orphan line.
    Aaron P Scooter Software