This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]