views:

94

answers:

1

Hello everyone,

Suppose I have the following XML document, which has no default namespace defined, and "Information" element is not prefixed with any namespace prefix. My questions are, 1. what is the namespace element "Information" belong to? 2. is there any way to apply XML schema check against "Information" element (for example, I want to check the content of Information element is not null or something using schema definition)?

<?xml version="1.0" encoding="utf-8"?>
<Information>Hello XML</Information>

thanks in advance, George

+5  A: 

From the specification:

If there is no default namespace declaration in scope, the namespace name has no value. The namespace name for an unprefixed attribute name always has no value. In all cases, the local name is local part (which is of course the same as the unprefixed name itself).

So the namespace here is actually the empty string "".

Joey
Cool @Johannes, 1. So in my sample Information element is not belonging to any namespace, correct? 2. Are there any ways to use XML schema to check against such kinds of elements?
George2
Another quick question, about terminology, should I call element like Information in my sample, A. Not belongint to any namespace or B. belong to no namespace or C. Local element?
George2
I have no idea of your second question. You might need to wait until somebody comes along who knows. And I'm not that well-versed in XML currently to answer the question in your second comment, sorry. Digging up specs is easy, but actually knowing stuff is not :-)
Joey
Hi Johannes, I asked a couple of questions, which one do you mean my second question?
George2
The one with a 2 in front of it: »2. Are there any ways to use XML schema to check against such kinds of elements?«. You already have a chronological total order on the questions you ask, so the second one is actually quite uniquely identified :)
Joey
@Johannes, so you could answer all my other questions except 2? :-)
George2
No, I could answer your first and only your first question. And that's what I did.
Joey