And Operator for Advanced Xpath logic

1
Hi Team, I studying on the section 4.1.1 on the Mendix academy advanced xpath learning path. But I couldn't get one point . In the learn path it writes two different Xpaths showing the use of the “and” operator and makes a statement that they should retrieve different data. But when I tried, both xpath tables retrieve the same data (I think they should also retrieve the same data). In simple mathematical terms, A∩B = (A)∩(B) I'm leaving this section of Learnpath below. It would be great if you could share your knowledge with me about why these two Xpaths should return different data. Thanks Ridvan   Edit------     4.1.1 / 5 Learn Path Open the list view in the tab Example A and set the XPath query to the query below: [Sales.SalesOrderHeader_Customer/Sales.Customer/Sales.Customer_SalesTerritory/Sales.SalesTerritory [CountryRegionCode = 'US' and SalesYTD > 4000000 ] ] Open the list view in the tab Example B and set the XPath query to the query below: [Sales.SalesOrderHeader_Customer/Sales.Customer/Sales.Customer_SalesTerritory/Sales.SalesTerritory/CountryRegionCode = 'US' and Sales.SalesOrderHeader_Customer/Sales.Customer/Sales.Customer_SalesTerritory/Sales.SalesTerritory/SalesYTD > 4000000 ] Run your application locally and look at the difference between the number of sales orders being retrieved.
asked
2 answers
1

Hi Ismail,

If the results of the two queriers match depends on the data you use.

 

Consider a SalesOrderHeader object associated with following two customers:

  • Customer1: associated with SalesTerritory with SalesYTD > 4000000 and CountryRegionCode = ‘NL’
  • Customer 2: associated with SalesTerritory with SalesYTD = 5 and CountryRegionCode = ‘US’

This SalesOrderHeader will not be retrieved by the first query, because there is no link to a *single* SalesTerritory with both matching CountryRegionCode and SalesYTD

This SalesOrderHeader will be retrieved by the second query, because there is a link to a SalesTerritory with  matching CountryRegionCode and with *another* SalesTerritory with matching SalesYTD.

I hope this helps.

answered
1

The first Xpath constraint returns all SalesTerritories where CountryRegionCode is 'US' AND where SalesYTD exceeds 4000000 (BOTH must be true); the second one returns all SalesTerritories where RegionCode is US and all SalesTerritories where SalesYTD exceeds 4000000; So the second result list might comprise SalesTerritories where CountryCode is NOT 'US' (but exceeds 4000000), and SalesTerritories where SalesYTD are below 4000000 (but CountryCode is 'US')

answered