$match = true() for empty $match??

V

Victor

While debugging my stylesheet using XMLSpy, I got a really weird result:
<xsl:if test="$match = true()"> matches even if $match is an empty node
fragment. How can this be?
 
R

Richard Tobin

Victor said:
While debugging my stylesheet using XMLSpy, I got a really weird result:
<xsl:if test="$match = true()"> matches even if $match is an empty node
fragment. How can this be?

What do you mean by "empty node fragment"? Do you mean "empty node set",
"empty result tree fragment", or what?

If the value of $match is a node set, then "$match = true()" is true
if and only if the node set is non-empty.

If the value of $match is a result tree fragment, then it is
"equivalent to a node-set containing just a single root node" (section
11.2) so it is never empty and "$match = true()" is always true.

I suspect this is different in XSLT version 2, which might explain why
different versions of Saxon and Xalan give me different results when I
test it.

-- Richard
 
V

Victor

Richard said:
What do you mean by "empty node fragment"? Do you mean "empty node set",
"empty result tree fragment", or what?

If the value of $match is a node set, then "$match = true()" is true
if and only if the node set is non-empty.

If the value of $match is a result tree fragment, then it is
"equivalent to a node-set containing just a single root node" (section
11.2) so it is never empty and "$match = true()" is always true.

A-hah! Thank you, this seems to solve the mystery (especially since the
XSL spec says empty node sets equal false().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top