sebb wrote:
On 31/01/2008, Ronan Klyne <[EMAIL PROTECTED]> wrote:
Hello all,

I'm having a little trouble with the XPath Extractor.
The problem presents itself whenspecified element is not present in the
page. Instead of the expression returning my default value of "ERROR",
it returns "". This looks to me like a bug in the substring-* functions.

This expression works as expected:
//[EMAIL PROTECTED]"tabLinkFunc"]/@href
There is no such element, so it returns "ERROR". Correct.

The second, which does not:
substring-before(substring-after(//[EMAIL PROTECTED]"tabLinkFunc"]/@href,
"@as_id="), "&")
There is no such element, so it should also return "ERROR". But it
returns "" instead.

Any thoughts/suggestions, anyone?


Are there any errors reported in jmeter.log?

If not, then it is most likely that the behaviour is determined by the
XPath implementation.

There are no related errors in jmeter.log.

I observe (in XPathExtractor.java) that unless the XPath library returns an XObject identifying itself as a CLASS_NODESET, the result is converted to a string and stored in the appropriate variable. The default is only used in exceptional cases.

There are classes of XPath object which are not 'successful' responses which do not throw exceptions.

These are the XPath types that the Xalan library defines:
CLASS_BOOLEAN
CLASS_NODESET
CLASS_NUMBER
CLASS_RTREEFRAG
CLASS_STRING
CLASS_NULL
CLASS_UNKNOWN
CLASS_UNRESOLVEDVARIABLE

I think that the last three should result in either an error condition or the default value being used.


I believe I saw the behaviour I did because the final result of my XPath expression was coming from applying a function to an empty nodeset, rather than returning said nodeset.

        # r

--
Ronan Klyne
Business Collaborator Developer
Tel: +44 01189 028518
[EMAIL PROTECTED]
www.groupbc.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to