So, I would say that there are two cases here then:

1. The variable was never set at all in the VariableContext
2. The variable was set, but was set to null.

In case 1, I would say it should throw an exception. In case 2, it should
simply return nothing when executed, without throwing an exception. This is
consistent with all the XSLT implementations I have ever used - the
processor will only complain if the variable was never declared, not if it
was empty.

An exception should also be thrown case 1 is in force and the xpath is
something like "foo/bar[. = $whatever]"

David


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Steen
Lehmann
Sent: Wednesday, 4 December 2002 5:14 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [Jaxen] should using a variable with no value throw
anexception.


Let's go with the spec on this one:

"A VariableReference evaluates to the value to which the variable name is
bound in the set of variable bindings in the context. It is an error if the
variable name is not bound to any value in the set of variable bindings in
the expression context."
(XPath 1.0, section 3.1)

-- Steen

>>> "James Strachan" <[EMAIL PROTECTED]> 12/03/02 10:42 AM >>>
I guess it depends on the use case of whether variables having no value is
valid or not.

I've a use case where having variables undefined is valid, so I've gone
ahead and implemented my own VariableContext for which an empty Document is
returned if there is no value available. I guess thanks to the interface,
Jaxen users can have behaviour either way.

James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: "Jan Dvorak" <[EMAIL PROTECTED]>
To: "James Strachan" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, December 03, 2002 4:11 PM
Subject: Re: [Jaxen] should using a variable with no value throw an
exception.


I'd prefer if it failed, rather than silently ignored what I think is a
clear
case of an error condition.

Jan

Dne ut 3. prosinec 2002 16:52 James Strachan napsal(a):
| If I were to evaluate the XPath:
|
|     $foo/bar/whatever
|
| Do folks think its correct behaviour to throw an exception if foo does not
| exist, or just to quietly ignore it and return no results? I thought the
| latter would be more appropriate but it seems that Jaxen right now
| implements the former.
|
| Thoughts?
|
| James

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET
comprehensive development tool, built to increase your
productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest



-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET
comprehensive development tool, built to increase your
productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest



-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET 
comprehensive development tool, built to increase your 
productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to