Re: [Saxdotnet-devel] StartElement, when URI is not present
Brought to you by:
jeffrafter,
kwaclaw
From: Karl W. <ka...@wa...> - 2004-12-07 20:28:01
|
> Karl Waclawek wrote: > > > > I can understand this, but you would usually check the Uri anyway, > > since you want to know if the name has a namespace. So you would > > get used to "if (uri == null)" fairly quickly. > > In fact, I find that I don't do that nearly as often as you'd think. As > long as I know the URI is not null there are a lot of cases where I can > treat the empty space exactly the same as any other namespace. If I had > to worry about it being null, I absolutely couldn't do that and I'd have > to litter my code with a lot of null checks or catch > (NullPointerException). It just works out cleaner to be able to treat no > namespace the same as any other namespace. which I can do most (not all) > of the time if it's the empty string and none of the time if it's null. As I said before, I am not dead-set against String.Empty. If the majority of discussion participants vote for it, then I will change it in the API. > > Somewhat confusing is that RFC 2396 assigns some semantics to empty URIs: > > <quote> > > 4.2. Same-document References > > > > A URI reference that does not contain a URI is a reference to the > > current document. In other words, an empty URI reference within a > > document is interpreted as a reference to the start of that document, > > and a reference containing only a fragment identifier is a reference > > to the identified fragment of that document. Traversal of such a > > reference should not result in an additional retrieval action. > > However, if the URI reference occurs in a context that is always > > intended to result in a new request, as in the case of HTML's FORM > > element, then an empty URI reference represents the base URI of the > > current document and should be replaced by that URI when transformed > > into a request. > > </quote> > > This is irrelevant here. namespace URIs do not indicate any document, > whether they're the empty string or not. Well, this is not clear to me. There is a current document, which has an URI, and the URI reference would point to it. So, one could make a case that we have an URI and therefore a namespace. > > xmlns="" is just syntax for null, as it means that there is no default > > namespace (where one might have been before), it doesn't mean that the > > default namespace has an empty string as URI (which is not a valid URI). > > There is no such thing as null in XML. The concept of null is completely > foreign to it. There is no null namespace URI, no null element, no null > value. The concept of null is simply the concept of absence. Since there is no special syntax provided, the above is the one that has been assigned that meaning (for namespaces, not in general). Karl |