Re: [Saxdotnet-devel] StartElement, when URI is not present
Brought to you by:
jeffrafter,
kwaclaw
From: Elliotte H. <el...@me...> - 2004-12-07 20:19:49
|
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. > 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. > 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. I've seen developers of various stripes try to introduce null into XML, and it's almost always a disaster. There is null in Java and, I assume, C#. But this is not something that has any reflection in XML. -- Elliotte Rusty Harold el...@me... XML in a Nutshell 3rd Edition Just Published! http://www.cafeconleche.org/books/xian3/ http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim |