Re: [Saxdotnet-devel] String.Empty vs. null
Brought to you by:
jeffrafter,
kwaclaw
From: Karl W. <ka...@wa...> - 2005-01-13 19:37:06
|
Jeff Rafter wrote: >> We really only have two cases: foo has a namespace, or it doesn't. >> >> Or did you mean something else? > > > <snip/> > >>> <foo bar=""> >>> Would the bar attribute's value be null or string.empty? >> >> String.Empty. null would mean: no value. >> > > This is the contradiction I am referring to... technically the value of > bar is emtpy which is more or less null. But we make the distinction > because it is helpful to know that even though there is no value, the > attribute bar is present. I am not sure if so documented, but if an attribute is passed through SAX (IAttributes), it can never have a null value argument, simply because an attribute without value is nonsense. null means "no value" (see below). > This is the same as the xmlns="" declarations. > Technically the value means null-- literally it is empty-- and it is > helpful to be able to distinguish between the two (at least in editor > applications)... I don't quite agree - null means "no value". there is no null value for strings. null is a value for references/pointers. The string arguments in SAX are not strings, but string references, and as such they can be null, meaning they do not point to any string object. This is also one of the reasons why namespace URI references are not allowed to be empty strings in XML, even though URI references in general are allowed to, and do have a specific meaning assigned to an empty string. Otherwise one could not express "absence" or "removal" of namespaces in the serialized format, because XML is a text format - everything must be expressed as text. xmlns="" can be interpreted on two levels: 1) an attribute with name xmlns and value "". 2) an expression of the fact that the default namespace is turned off. The concept of null comes into play at a later stage, and that is when the parser wants to pass a name to the app. How does it express that this name has/does not have a namespace? If the uri argument, which is a string reference, points to nothing (==null) then we don't have an uri string object, and therefore no namespace. So, I simply don't see a contradiction. Karl |