question

aswinbh avatar image
aswinbh asked ericnute edited

Xpath expression or Query - needed

Background: I have an input file with following data (1st line is the banner): Fine name, UA Profile, UA Validation, URL Validation, Tidy Validation ts01_master_test_suite.fftc, Nokia2100, Y, Y, Y ts01_master_test_suite.fftc, Nokia1300, Y, N, Y ts01_master_test_suite.fftc, Nokia1100, Y, Y, Y ts02_service_requirements.fftc, Nokia1300, Y, Y, N Problem: I need to write a query which returns the count of unique rows with respect to File name. This query should return 2 for the above data as Filenames of 3 rows are same.
iTestxpath
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
AdamB avatar image
AdamB answered AdamB posted

aswinbh,

 

Could you click the "code copy" button and paste the example text into that.

 

 

it should look like thisit will be easier to evaluate.

  

 

 

11 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

aswinbh avatar image aswinbh commented ·
Hi,
I couldn't find the 'code copy' button. does it come only in specific version of iTest?
I have 3.3

0 Likes 0 ·
aswinbh avatar image aswinbh aswinbh commented ·
Re-writing the question:

Background: I have an input file with following data (1st line is the banner):

Fine name, UA Profile, UA Validation, URL Validation, Tidy Validation
ts01_master_test_suite.fftc, Nokia2100, Y, Y, Y
ts01_master_test_suite.fftc, Nokia1300, Y, N, Y
ts01_master_test_suite.fftc, Nokia1100, Y, Y, Y
ts02_service_requirements.fftc, Nokia1300, Y, Y, N

Problem: I need to write a query which returns the count of unique rows with respect to File name. This query should return 2 for the above data as Filenames of 3 rows are same.
0 Likes 0 ·
AdamB avatar image AdamB aswinbh commented ·

Does this do the trick?

 

 

//row[not(Fine_name = preceding-sibling::row/Fine_name)]/Fine_name

 

I've attached a response map for this.

 

This finds items where the "Fine_name" does not equal a previous "Fine_name".

 

0 Likes 0 ·
Table.ffrm (1.7 KiB)
ramarb avatar image ramarb AdamB commented ·

I think he needs file count. Hence, add a count Fn in XPATH query as below:

 

count(//row[not(Fine_name = preceding-sibling::row/Fine_name)]/Fine_name)

 

0 Likes 0 ·
AdamB avatar image AdamB ramarb commented ·

Missed that.  Thanks.

 

0 Likes 0 ·
aswinbh avatar image aswinbh AdamB commented ·
Thank you very much, Adam.
Can you please tell me where I can find help on xpath functions & preceding-sibling kind of stuff?

The URL given in iTest help ( http://jaxen.org/apidocs/index-all.html) is very much java devt oriented.
0 Likes 0 ·
AdamB avatar image AdamB aswinbh commented ·

I found it here:

 

http://www.jenitennison.com/xslt/grouping/index.html

 

This looked like another good resource:

http://www.dpawson.co.uk/xsl/sect2/N4486.html

 

I'm glad to see people starting to really use XPath.  

0 Likes 0 ·
ramarb avatar image ramarb aswinbh commented ·

Here are some links I see regularly::

To Start with X-PATH:
http://www.w3schools.com/XPath/default.asp

Functions in XPATH:
http://jaxen.codehaus.org/apidocs/org/jaxen/function/package-summary.html

0 Likes 0 ·
AdamB avatar image AdamB ramarb commented ·

Those are good.

 

I'll combine these into an XPath information/FAQ in the forums, with a bit of a write up of XPath. 

0 Likes 0 ·
aswinbh avatar image aswinbh ramarb commented ·
Thank you both.
0 Likes 0 ·
AdamB avatar image AdamB aswinbh commented ·
Sorry, the copy code button is in the forums.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.