Organizing XML attribute namespaces

The related question is the one I asked earlier ...

Just checking something: should the xmlns, xmlns: xsi and xsi: schemaLocation attributes order in the XML file?

I find this to happen - at least when using XML Notepad 2007 to view an XML file. For example (suppose my XML file is legal according to my schema), this does not give errors (example 1):

<myroot xmlns="http://www.someurl.com/ns/myroot" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.someurl.com/ns/myroot http://www.someurl.com/xml/schemas/myschema.xsd"> <sometag>somecontent</sometag> </myroot> 

but it does (example 2):

 <myroot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.someurl.com/ns/myroot http://www.someurl.com/xml/schemas/myschema.xsd" xmlns="http://www.someurl.com/ns/myroot"> <sometag>somecontent</sometag> </myroot> 

(The error is that "sometag" is an illegal entry in accordance with the scheme).

My problem is that if I use the code from my other question to create my schema names and attributes, I get the XML attributes output as in example 2 ...

Should the xmlns attribute always be the first in the attribute list?

+4
source share
1 answer

A - I noticed my problem ...

The XML I'm actually working on is terribly complex, and I did not notice that I inserted xmlns = "" in all of my child nodes. As soon as I remove, the problem will disappear and the order of the namespace attributes does not make any difference - this is what I expected ...

+1
source

All Articles