Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > $match = true() for empty $match??

Reply
Thread Tools

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

 
 
Victor
Guest
Posts: n/a
 
      05-14-2004
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?

--
Victor
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      05-14-2004
In article <c82liu$rqk$>,
Victor <engmark-> wrote:

>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
 
Reply With Quote
 
 
 
 
Victor
Guest
Posts: n/a
 
      05-17-2004
Richard Tobin wrote:

> In article <c82liu$rqk$>,
> Victor <engmark-> wrote:
>
>
>>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.


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

--
Victor
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DetailsView ASP Control and an empty field not an empty record. ButlerDJIAM ASP .Net 0 11-09-2006 06:40 PM
Altova Mapforce - xml 2 xml map: empty elements output although input element is not empty Lukas XML 3 11-10-2005 02:25 PM
empty lists vs empty generators Brian Roberts Python 12 05-04-2005 08:59 PM
Check if a directory is empty and empty it Marcia Hon C Programming 8 02-14-2004 03:53 AM
empty/non-empty element John XML 1 07-16-2003 10:23 AM



Advertisments