xsl-list
[Top] [All Lists]

Re: [xsl] Universally quantified test of child attribute presence/absence

2007-03-20 05:19:50
Yves Forkl wrote:

While the expression for the positive test obviously is

every $child in * satisfies $child/@my_attribute

I am unsure about the correct form of the negated expression to mandate that no child may have that attribute. Which variant can or must be used, and why?

every $child in * satisfies $child[not(@my_attribute)]

will return true if no child has a @my_attribute that returns false. I.e., if the value were empty, but available, it would return false.


every $child in * satisfies not($child/@my_attribute)

will return true if no child has a sequence of nodes @my_attribute (alsways one or zero attribute nodes) that when normalized returns false. That is in this scenario effectively the same as above, I believe.


not(every $child in * satisfies $child/@my_attribute)

'every' returns a boolean. You an safely negate it, so this will work. However, note also:


The expression:

empty(*/@my_attribute)

will return true() when there is no child that has an attribute @my_attribute (i.e., in other words, it will return true when the expression returns an empty sequence).

The expression:

every $child in * satisfies $child/@my_attribute

may not return the expected answer when there are no childs at all: it will return true. This is illustrated if you compare the behavior in the following XPath equivalent:

count(*/@my_attribute) = count(*)


Cheers,
-- Abel Braaksma

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--