[Mono-devel-list] [Fwd: Re: the patch status followup]

Atsushi Eno atsushi at ximian.com
Wed Mar 2 08:27:05 EST 2005

Hi Andrew,

Thanks for forwarding it to public list as per my request.

Well, can you please give me an "yes/no" answer that if this
question is related to your XmlTextWriter patch? (Of course it is
no problem if this Q is nothing to do with the patch though.)

Andrew Skiba wrote:
> Hello,
> Atsushi Eno wrote:
>>>I'm investigating this case, and it confuses me a little bit. Code
>>> 		XmlElement b = d.CreateElement ("b");
>>>		b.SetAttribute ("xmlns","probe");
>>>produces element b with namespace "" but with attribute xmlns="probe"
>>>How do you make the same thing in XML without DOM? Should not this be
>>>treated exactly as
>>>		XmlElement b = d.CreateElement ("", "b", "probe");
>>I don't get what your question means. Creating XmlElement without
>>DOM sounds weird. 
> I mean, with DOM API you can create attribute with name xmlns. It looks
> that you can not do the same in text form of XML, xmlns will be
> interpreted as namespace declaration. It looks pretty strange. Let's

Am still confused. You discuss non-DOM stuff like "text form of XML".

As for "text form of XML", we can. The following example will result
in attribute xmlns="urn:blah" :

	xmlTextWriter.WriteStartAttribute ("", "xmlns",
	xmlTextWriter.WriteString ("urn:blah");
	xmlTextWriter.WriteEndAttribute ();

> suppose, you declare a _non-default_ namespace with
> 	b.SetAttribute ("xmlns:a", "probe");
> Then this namespace will be treated, naturally, as a namespace. But if
> you declare a _default_ namespace, it's not inherited to the children,
> so it's not really a namespace declaration. The output of the <b>

It *is* namespace declaration, as written in Namespaces in XML
recommendation: http://www.w3.org/TR/REC-xml-names/#ns-decl

> element is the same, but the output of children is different. I read DOM
> API standard and it says nothing about xmlns special processing. ECMA
> does not take into account case with empty prefix and localname="xmlns",
> which I also don't understand. The reason I don't understand it is
> because in XML when you write

As for DOM child nodes, there is no such rule that child nodes
inherit ancestors' namespaces. Every element nodes have its own
NamespaceURI property (namespaceURI attribute in DOM spec term).
and it is the namespace for the node.

> 	<b xmlns="probe">
> or
> 	<b xmlns:a="probe">
> the only difference is that the first one declares the default prefix,
> and the second declares non-default prefix.
> Thank you.
> Andrew Skiba.

Atsushi Eno

More information about the Mono-devel-list mailing list