XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Beware of XPath expressions that produce false positives

 Hi Roger,

> Example of a Condition:
>
> The <B> element is empty.
>
> Will the following XPath correctly indicate when the condition is present?

A few notes:

1. You haven't defined what should  "empty" mean exactly. Therefore,
*any* XPath expression attempting to express this undefined concept of
"empty" is potentially wrong.

2. The provided example of expressions with "false positive" results
only reflect the misunderstanding in 1) above.

3. In case "empty" is strictly defined, then it is not correct to say
that an XPath expression "returns false positives" -- the correct
terminology is: the XPath expression is *wrong*. And the reason for
having wrong expressions in any language -- not only in XPath, that
surprise us, is lack of adequate testing.

Cheers,
Dimitre

On Sat, Sep 24, 2016 at 5:27 AM, Costello, Roger L. <costello@mitre.org> wrote:
> Hi Folks,
>
> A few days ago David Carlisle posted a message with an excellent analysis of
> several XPath expressions. His message got me to thinking: It’s really easy
> to write XPath expressions that yield false positives. Stated differently,
> it’s really hard to write correct XPath expressions.
>
> [Definition] False positive: a test result which incorrectly indicates that
> a particular condition or attribute is present.
>
> Example of a Condition:
>
> The <B> element is empty.
>
> Will the following XPath correctly indicate when the condition is present?
>
> normalize-space(B) eq ''
>
> Evaluating the XPath expression on the following XML correctly indicates
> that the condition is present.
>
> <Row>
>     <A>foo</A>
>     <B/>
>     <C>bar</C>
> </Row>
>
>
>
> Evaluating the XPath expression on the following XML correctly indicates
> that the condition is not present.
>
> <Row>
>     <A>foo</A>
>     <B>99</B>
>     <C>bar</C>
> </Row>
>
>
>
> Evaluating the XPath expression on the following XML incorrectly indicates
> that the condition is present.
>
>
>
> <Row>
>     <A>foo</A>
>     <B><bad/></B>
>     <C>bar</C>
> </Row>
>
>
>
> Evaluating the XPath expression produces a false positive.
>
>
>
> Evaluating the XPath expression on the following XML incorrectly indicates
> that the condition is present.
>
>
>
> <Row>
>     <A>foo</A>
>     <B><!-- Hello, world --></B>
>     <C>bar</C>
> </Row>
>
>
>
> Evaluating the XPath expression produces a false positive.
>
>
>
> /Roger



-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS