RE: [xsl] Extracting a list of unique base urls from anchors in a html docu ment.

Subject: RE: [xsl] Extracting a list of unique base urls from anchors in a html docu ment.
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Sat, 15 Sep 2001 19:28:05 +0100
> 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


Current Thread