You might also consider the "is" operator; it should be more efficient.  
It's hard to tell from your example whether it's what you're after in 
some broader case, but it would work in the case of comparing a node to 
its root().

-Mike

On 2/8/2011 1:59 PM, Wyatt VanderStucken wrote:
> Thanks Mike, that's the trick I needed...
>
> On 2/8/2011 1:54 PM, Michael Blakeley wrote:
>> The eq operator is not the right tool for that job. Try fn:deep-equal() 
>> instead. If you are interested in the why, you might read 
>> http://www.w3.org/TR/xpath20/#id-atomization
>>
>> -- Mike
>>
>> On 8 Feb 2011, at 10:51 , Wyatt VanderStucken wrote:
>>
>>> Greetings all,
>>>
>>> I'm running into an issue where two clearly different elements seem to
>>> be equal.  Specifically, I'm using the root() function to determine if
>>> an element passed to a function is the root element.  I've included the
>>> code and resulting log file output below.  I'm using MarkLogic 4.1-5
>>> (XQuery version 0.9-ml).  Is there a better way to accomplish this?  Any
>>> ideas would be appreciated.
>>>
>>> CODE:
>>> define function augmentation:allowedSiblings($schema as element(), $xml
>>> as element(), $direction as xs:string) as element()* {
>>>       xdmp:log(concat("XML: ", xdmp:quote($xml))),
>>>       xdmp:log(concat("ROOT: ", xdmp:quote(root($xml)))),
>>>       if ($xml eq root($xml)) then xdmp:log("IS ROOT!!!")
>>>       else (
>>> xdmp:log("NOT ROOT"),
>>>           ...
>>>       )
>>> }
>>>
>>>
>>> LOG:
>>> 2011-02-08 13:33:48.435 Info: skins8003: XML:<paragraph
>>> id="11219203668758959999.12004024049727559426" tcs.iscustomized="yes"/>
>>>
>>> 2011-02-08 13:33:48.435 Info: skins8003: ROOT:<item_scoring_object
>>> accession_number="SO007350" id="7720283713666233372.4468704661156005354"
>>> tcs.iscustomized="yes"><item_scoring_information
>>> equivalent_value_flag="not_applicable" max_points="3"
>>> not_reached_weight="0.00" number_required_responses="0"
>>> omit_weight="0.00" scoring_sort_rule="no" wrong_weight="0.00"
>>> id="15035807845964682634.2143736121983627429"
>>> tcs.iscustomized="yes"><human_scored_keyset off_topic_codes="0"
>>> score_code_range_max="3" score_code_range_min="0"
>>> id="15794589581008873975.909344949806971956"
>>> tcs.iscustomized="yes"><scoring_guide max_points="3" min_points="2"
>>> id="2239949246564743106.1435441036091478339"
>>> tcs.iscustomized="yes"><item_score score_weight="1"
>>> id="443565930774040320.17569195943517610642"
>>> tcs.iscustomized="yes"><paragraph
>>> id="11219203668758959999.12004024049727559426"
>>> tcs.iscustomized="yes"/></item_score></scoring_guide></human_scored_keyset></item_scoring_information></item_scoring_object>
>>>
>>> 2011-02-08 13:33:48.435 Info: skins8003: IS ROOT!!!
>>>
>>> Thanks in advance,
>>>
>>> Wyatt VanderStucken
>>>
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to