Bug 38302 - XPath ignores xpathString if same xml file
XPath ignores xpathString if same xml file
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.1.1
PC Windows XP
: P2 normal (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2006-01-17 16:23 UTC by Troll
Modified: 2006-04-30 11:00 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Troll 2006-01-17 16:23:31 UTC
I have an xml file with more than one attribute that I like to parse with the
__XPath function, but the function ignores the attribute name on the second call
per request.

Example:
xmlfile testusers.xml:
<users>
<user username="u1" password="p1"/>
<user username="u2" password="p2"/>
</users>

the XPath function call 
${__XPath(testusers.xml,//user/@username)} will return u1 and u2 respectively, but
${__XPath(testusers.xml,//user/@password)} will also return u1 and u2. 

XPathWrapper.getXPathString() only checks if it is the same file, should
probably check xpathString too
Comment 1 Sebb 2006-01-17 17:57:16 UTC
(In reply to comment #0)
> the XPath function call 
> ${__XPath(testusers.xml,//user/@username)} will return u1 and u2 
respectively, but
> ${__XPath(testusers.xml,//user/@password)} will also return u1 and u2. 

The above calls are identical, so the response should be identical as well.

> XPathWrapper.getXPathString() only checks if it is the same file, should
> probably check xpathString too

Please explain
Comment 2 Troll 2006-01-18 10:45:08 UTC
(In reply to comment #1)

> > the XPath function call 
> > ${__XPath(testusers.xml,//user/@username)} will return u1 and u2 
> respectively, but
> > ${__XPath(testusers.xml,//user/@password)} will also return u1 and u2. 
> 
> The above calls are identical, so the response should be identical as well.

I would expect 
${__XPath(testusers.xml,//user/@password)} to return p1 and p2 respectively, the
call is asking for a different attribute value (password and not username).
If the calls were identical, you couldn't parse more than one attribute from
each xml file.
Comment 3 Sebb 2006-02-20 20:40:08 UTC
Sorry, my mistake, I misread it - of course ...@username is not the same 
as ...@password - duh!

I now understand the comment about the XPath string check as well.

I'll take another look at fixing this.
Comment 4 Sebb 2006-02-21 01:23:54 UTC
As far as I can tell, at present each call only ever returns the first match - I
could not get the function to return u2 (using your example). Does it work for you?

There does not seem to be any code to increment the internal pointer.
This obviously needs to be fixed as well...

BTW, a work-round at present is to use different file names for the same file,
e.g. testusers.xml and ./testusers.xml
Comment 5 Sebb 2006-02-21 03:46:37 UTC
I think I've fixed both problems in the 2.1 branch.

The nightly build 2-1.20060221 contains the fixes.
Comment 6 Sebb 2006-02-22 01:09:33 UTC
Found a problem - the nodelist was not being shared across threads.

This is in the 2-1.20060222 build.