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

Victor (5)

Usenet Archive
Joined
May 7, 2004
Messages
11
Reaction score
0
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?
 

Richard Tobin

Usenet Archive
Joined
Jan 6, 2000
Messages
4,251
Reaction score
0
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
 

Victor (5)

Usenet Archive
Joined
May 7, 2004
Messages
11
Reaction score
0
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

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top