xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: Namespaces Question...
Date Mon, 21 Feb 2000 18:34:20 GMT
Tim Bray wrote:
> 
> At 09:51 PM 2/19/00 -0800, Pierpaolo Fumagalli wrote:
> ><document xmlns="http://www.betaversion.org/document"
> >          xmlns:pier="http://www.betaversion.org/~pier/nsdecl">
> >  <pier:testelement value="somevalue"/>
> ></document>
> >
> >I wanted to know what namespace URI the "value" attribute has...
> >- is it the empty string ""?
> >- is it the "pier" namespace "http://www.betaversion.org/~pier/nsdecl"?
> >- is it the default namespace "http://www.betaversion.org/document"?
> 
> The attribute "value=" is not in any namespace.  An API could choose to
> signal this with either a null value or an empty string, (the latter works
> since the empty string can never be a legal namespace name), or by other
> methods including exceptions and return code with side effects depending
> on your programming language and religion.   I prefer the empty string
> because in Java you can always say
> 
>  if (ns.equals(whateverNamespaceICareAbout))
> 
> instead of
> 
>  if ((ns != null) && ns.equals(whateverNamespaceICareAbout))

What about

 if (whateverNamespaceICareAbout.equals(ns))

that way you don't care if it's null or not :)

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------



Mime
View raw message