[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Universally quantified test of child attribute pr

Subject: Re: Universally quantified test of child attribute presence/absence
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 20 Mar 2007 12:19:47 GMT
Re:  Universally quantified test of child attribute  pr
the simplest way of negating an expression is to put not around it so if 

every $child in * satisfies $child[@my_attribute]

is the positive test

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

is the negative test, and if that's the simplest for you to grock later
than that's what I'd use.

Personally I'd have probably written the "positive test" in negative
form, rather than saying every chiuld has teh attribute, say no child
doesn't have the attribute
not(*[not(@my_attribute)])
which is also valid xpath 1 of course.
This would make your "negative" test
exists(*[not(@my_attribute)]

Your other two expressions are valid but mean something else.

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


are true if every element does not have the attribute.





However none of the tests seem to capture what you say in english

>  all of its element children carry a specific attribute or if they don't. A 
> mixed situation is to be considered as a fatal error, caught in an 
> xsl:otherwise clause.

the tests you show test that all the elements have or dont have the
attribute, but only test for one or the other, they don't test for the
mixed case.
The most direct test for the mixed test is just to test
test="*[@my_attribute] and *[not(@my_attribute)]"


David

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.