
I have the following code:
Code: Select all
declare variable $x1 := <top>
<rec>
<d1>25</d1>
<d2>10</d2>
</rec>
</top>;
declare variable $x2 := <top>
<rec>
<d1>30</d1>
<d2>10</d2>
</rec>
</top>;
for $node in $x1/rec
return for $elem in $node/*
return if ($elem = $x2/rec/*[local-name()=local-name($elem)])
then (<match>{$elem}</match>)
else (<diff>{$elem}</diff>)
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<diff>
<d1>25</d1>
</diff>
<match>
<d2>10</d2>
</match>
Code: Select all
return if ($elem = $x2/rec/local-name($elem))
then (<match>{$elem}</match>)
else (<diff>{$elem}</diff>)
- Checking with the debugger, I find local-name(elem) = 'd1'
- but also $x2/rec/local-name($elem) evaluates to 'd1' (rather than what I expected: 30
Thanks for your help! Stefan