[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: big hairy Xpath (Solved!)
Russ,
You will understand this better if you revise your understanding of what a predicate (bracketed expression) does. Another name for a predicate (and arguably a more proper way in XPath 2.0, in which its operation is generalized to all sequences of items, not just sets of nodes) is a "filter expression". So: 1. child::entry - selects all 'entry' element children of the context node 2. child::entry[true()] - selects all 'entry' children, and filters them with the expression 'true()'. Since 'true()' is always true, the sequence of nodes returned will be the same as 1. 3. child::entry[false()] - by the inverse logic, returns an empty sequence. 'false()' is never true, so all 'entry' children are filtered out. (Only elements in the set for which the expression is true are kept.) 4. entry[@n='1'] - entry children that have an @n attribute with the string value "1". There may be any number of these, or none at all. Note that each 'entry' element is used separately as the evaluation context for the expression "@n='1'", which is how some of them pass and others fail. 5. Description[.='Special'] - 'Description' element children whose string value = "Special". Again, how many you get depends on your data and your context node (where you started the path). 6. favorite[@owner='zyx'][@rating > 3] - 'favorite' element children that have an @owner attribute = "zyx", and also a @rating with numeric value greater than 3. 7. favorite[@owner='zyx' and @rating > 3] - exactly the same thing, except expressed somewhat differently: instead of two predicates (the second of which filters the results of the first filter), only one predicate is used, with the conditions paired together using a Boolean 'and' operator. 8. child::child[child::grandchild] - 'child' element children that have 'grandchild' element children. This works because the expression 'child::grandchild' will cast to Boolean true() for any 'child' element children that have 'grandchild' children. 9. child[grandchild] - the same as 8., except in short (abbreviated) syntax. You can read more in a good reference to XPath. I hope this helps, Wendell At 07:14 PM 4/17/2009, you wrote: Hi All, ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|