xsl-list
[Top] [All Lists]

Re: double condition syntax

2004-02-07 09:42:13
Hi Marina,

I need to add a second condition to variable 'vNumNotSame' that also
checks to see if the MESSAGE was the same as the previous sibling
MESSAGE, and if so NOT to count it.

The current node-set is constructed with:

  LOG/*[number(TARGET_CHAR_LOCATION_ID) != number(LOCATION_ID)]

To get the immediately preceding sibling of the element you're looking
at, you need:

  preceding-sibling::*[1]

To get its <MESSAGE> element child, you need:

  preceding-sibling::*[1]/MESSAGE

And to make sure that it's not the same as the context element's
<MESSAGE> element, you need:

  preceding-sibling::*[1]/MESSAGE != MESSAGE

You need to test this condition *and* the one that you've got at the
moment, so the final path is:

  LOG/*[number(TARGET_CHAR_LOCATION_ID) != number(LOCATION_ID) and
        preceding-sibling::*[1]/MESSAGE != MESSAGE]

So to set $vNumNotSame, you need:

  <xsl:variable name="vNumNotSame"
    select="count(LOG/*[number(TARGET_CHAR_LOCATION_ID) !=
                        number(LOCATION_ID) and
                        preceding-sibling::*[1]/MESSAGE !=
                        MESSAGE])"/>

Note that you probably want to change how to calculate the number of
messages sent to the *same* location, since it now isn't the same as
$vTotalSent - $vNumNotSame.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>