Or if you really want to variable to contain a copy of the node, rather than
the original, then in place of xsl:sequence you could do
<xsl:variable name="person" as="node()">
<xsl:copy-of select="."/>
</xsl:variable>
But I find it hard to think of a good reason for making a copy: people often
use xsl:copy-of unnecessarily when xsl:sequence is more direct.
Michael Kay
Saxonica
> On 15 Apr 2025, at 22:15, Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
> On 15/04/2025 23:11, Wolfhart Totschnig wolfhart.totschnig@xxxxxxxxxxx
wrote:
>> Dear list,
>>
>> I would like to ask for your help with the following puzzling behavior that
I have encountered. The situation is that I am testing whether the context
node, which is a <person> element with child elements (first?, middle?, last),
is deep-equal to one of a set of other nodes. I found the following solution:
>>
>> some $p in //person satisfies deep-equal($p, .)
>>
>> However, when I store the context node in a variable, like so:
>>
>> <xsl:variable name="person">
>> \xA0\xA0 <xsl:copy-of select="."/>
>> </xsl:variable>
>
>
> That creates a document node containing a copy of the context node, so you
either need
>
> <xsl:variable name="person" select="."/>
>
> or, if you, for reasons I don't see, want to use the inner selection, use
>
> <xsl:variable name="person" as="node()">
>
> <xsl:sequence select="."/>
>
> </xsl:variable>
>
>>
>> and then make the comparison with the variable, like so:
>>
>> some $p in //person satisfies deep-equal($p, $person)
>>
>> then the test comes out false. Why is that? Why does it make a difference
whether I store the context node in a variable or call it directly?
>>
>>
> A document node is not deep-equal to an element node.
|