[Home] [By Thread] [By Date] [Recent Entries]
At 02:37 PM 4/2/2004, you wrote:
1) What is the number of reports which are coded with either an "a" or "b" where the last "a" or "b" code of the report (in document order) is an "a"? XPath typically provides several ways to skin any particular cat. But count(/reportlist/report [codelist/code/@type='a' or codelist/code/@type='b'] [descendant::code[@type='a' or @type='b'][last()]/@type='a']) will do this. 2) What is the number of reports which are coded with either an "a" or "b" where the last "a" or "b" code of the report (in document order) is a "b". This looks the same as above, except that final equality test is @type='b' not @type='a'. In my previous posting I recevied several helpful responses. It is also possible to write expressions for cases even more general. As always, the trick is in getting the spec right. Once you do that, if you know XPath, it isn't hard. Experience teaching XSLT suggests that a thorough and more-or-less formal introduction to XPath goes a very long way. "Faking it" proves to be false economy, as the time you saved learning it is more than overtaken by time spend guessing and pulling hair. So take a course that gives due attention to mastering XPath (my company offers one :-), or take the time to work through a decent introduction to the subject. For completeness, I can also offer you the long version of the first of these: count(/child::reportlist/child::report
[child::codelist/child::code/attribute::type='a' or
child::codelist/child::code/attribute::type='b']
[descendant::code[attribute::type='a' or attribute::type='b']
[position() = last()]/attribute::type='a'])Cheers, Wendell
|

Cart



