This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Extracting a list of unique base urls from anchors in a html docu ment.
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Extracting a list of unique base urls from anchors in a html docu ment.
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Sat, 15 Sep 2001 19:28:05 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
> This is an example from XSLT Prog.Ref 2nd. ed.:
> (On page 624)
>
> /cities/city[not(@country=preceding-sibling::city/@country)]
>
> I'm propably wrong, but to me, the above expression and mine
> seem similar.
> Both compare the string value of the attribibute of the
> context node with
> the values of the preceding tree.
>
> The only difference is that my template doesn't compare the
> attribute values
> as-is, but applies a substring before doing so.
>
Unfortunately that difference is crucial.
When you compare two node-sets ($ns1 = $ns2), the result is true if there is
a node in $ns1 and a node in $ns2 that have the same string value.
When you compare two strings (substring($ns1,1,1) = substring($ns2,1,1)),
the result is true if the two strings are equal. The substring() function
converts $ns1 to a string by taking the string-value of the first node.
This is of course a nasty pitfall in the design of the XPath language and I
don't think many people would defend it as being a good thing (in fact many
people have criticized it as being an extremely bad thing), but that's the
way the spec is written.
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list