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: Equals (=)


>      How does XSL compare two elements to see if they are equal?
> i.e. <xsl:if test = "$element1=$element2>
>
> In my current situation(comparing using Saxon), doing this seems to be
> tremendously faster than comparing all of the children of element1 and
> element2.  My assumption is that the parser hashes up each element and
> compares them.  Is this correct?
>
No; the meaning of this construct is to compare the string value of element1
with the string value of element2. Saxon implements it by getting the string
value of both elements and comparing them.

Saxon's internal routine to walk all the descendant text nodes of an element
to assemble its string value is going to be a lot more efficient than doing
the same thing at stylesheet level. But note, it's possible for two elements
to have the same string value and yet not have the same structural content,
for example

<element>text</element>
is "equal" to
<element><x>text</x></element>

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]