Configuring the Ignore Node in XML Side by Side assertion using a property.
search cancel

Configuring the Ignore Node in XML Side by Side assertion using a property.

book

Article ID: 233311

calendar_today

Updated On:

Products

CA Application Test

Issue/Introduction

How to use a property to configure the Ignore Node in XML Side by Side assertion.

The assertion compares test XML against a control XML. 

In Diff Viewer any node not in the control will be flagged:

How can a property be configured to ignore a specific node. 

Environment

All supported DevTest releases and platforms.

Cause

N/A

Resolution

Steps:
1) Create a template property. 
1a) In Settings -> Use Property, tick 'Use property for XML diff options'
1b) Click 'Create Config Property'. This will create a new property with a name like xmlDiffOptions1:

1c) To configure a node to ignore, right click the node in Select Contents, Test and then select the ignore option:

1d) In Settings -> Ignored Nodes, confirm the XPATH of the node to be ignored is listed
1e) Save and Exit the test.
1f) In the Project, under Properties Editor, confirm the property is now visible.
Use Launch Extended View and then Format to see it in this format:


2) Customise a new XML config property with all nodes to be ignored.
2a) For example to ignore /note/optional and /note/optional1 create a new property:

2b) Save and Exit the project
2c) Open the test and in the assertion select the new property.

2d) Confirm both the optional and optional1 nodes are now listed: 

2e) Confirm both the optional and optional1 nodes are ignored (but not optional2): 

3) Customise the list of nodes further by:
3a) Exit the test
3b) Open the project and make changes to the property, then Save and Exit the project.
3c) Open the test and confirm the new settings work.

Additional Information

The XPath '/note/optional' is a more basic version of:
/*[local-name()='note']/*[local-name()='optional']

For an XPath tutorial see:
https://www.w3schools.com/xml/xpath_intro.asp

For the local-name function see:
https://www.w3schools.com/xml/xsl_functions.asp

There is also a property description that explains local-name() is sometimes necessary: 
lisa.xml.xpath.computeXPath.alwaysUseLocalName
This property configures whether the XPath local-name() function is always used during XPath generation. The default value is false, meaning that the local-name() is only used when necessary. To generate an XPath that works regardless of the namespace of an XML node, set the value of this property to true.
Default: false