| Subject: Re: [xsl] preceding...please help understanding... From: Mike Brown <mike@xxxxxxxx> Date: Sat, 7 Sep 2002 12:13:10 -0600 (MDT) | 
Bill Carter wrote:
> I am having trouble understanding preceding.
What you don't realize about preceding is not affecting your results.
The preceding axis picks up more nodes than preceding-sibling. You
probably want preceding-sibling. Otherwise, if you have something like
<foo>
  <stocks>
    <ticker>ZZZ</ticker>
    <ticker>AAA</sticker>
  </stocks>
  <stocks>
    <ticker>AAA</sticker>
    <ticker>BBB</sticker>
  </stocks>
</foo>
and you start at the BBB ticker, preceding::ticker picks up the first
ZZZ and AAA as well as the immediately preceding AAA. 
preceding-sibling::ticker will get you just the ones you want.
What you're confused about, though, and this is what is skewing your results,
is equality comparisons on node-sets.
$set1 = $set2 is true if any node in $set1 has a string-value equal to the
string-value of any node in $set2.
$set1 != $set2 is true if any node in $set1 has a string-value not equal to
the string-value of any node in $set2. != is very rarely what you want. Use
not() and = instead, like this:
not($set1 = $set2)
...which will be true if no node in $set1 has a string-value equal to the
string-value of any node in $set2.
Similar rules apply if instead of $set1 you have any other object type;
if the operand on the right is a node-set, then the string-value of the left 
operand is compared to the string-value of every node in the node-set.
   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] preceding...please help u, J.Pietschmann | Thread | [xsl] thanks! now help on alternati, Bill Carter | 
| Re: [xsl] preceding...please help u, J.Pietschmann | Date | [xsl] thanks! now help on alternati, Bill Carter | 
| Month |