xsl-list
[Top] [All Lists]

RE: How to specify document order location path for identical elements with different parents?

2004-04-02 13:14:09
-----Original Message-----
From: Alan Stein [mailto:as(_at_)medcosm(_dot_)com]

Thanks much for the help with my previous posting.

I think I've better articulated my question in the following example:

Given the following XML:

<snip />


How do I perform the following queries?

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"?


Hi,

To break it down:

1) reports coded with either an 'a' or 'b':

<xsl:variable name="var-one"
              select="report[codelist/code[
                @type='a' or @type='b']]" />

2) ... where the last 'a' or 'b' code in doc order is 'a'

<xsl:variable name="var-two"
              select="$var-one[codelist/code/@type[last()]='a']" />

all-in-one?

<xsl:variable name="vcount" select="count(/*/report[codelist/code[
                              @type='a' or @type='b']/@type[last()]='a'])"
/>

yup, should do the trick.. untested though


Hope this helps!

Cheers,

Andreas