Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about qualified and unqualified elements

 
Oguz Ozun
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

I know this topic discussed several times before but I want to make sure the thing that I got is right.

From RMH book:
... If the XML document declares a default namespace, then all elements without prefixes are assigned to that namespace. This rule makes things tricky because unqualified elements are not supposed to be qualified, yet if there's a default namespace, then they are assigned to that namespace and are effectively qualified. ...


Supose that I have an XML schema give below:

<schema xmlns = "http://www.w3.org/2001/XMLSchema"
xmlns:xx = "http://www.xxx.com/MyNamespace"
targetNamespace = "http://www.xxx.com/MyNamespace"
elementFormDefault = "unqualified" >
...
<element name = "yyy" type = "xx:Mytype" />
<complexType name = "MyType">
<sequence>
<element name = "a" type = "string" />
<element name = "b" type = "int" />
</sequence>
</complexType>
...

And I have such XML document given below:
<yyy xmlns = "http://www.xxx.com/MyNamespace" ... >
<a>Oguz</a>
<b>20</b>
</yyy>

Is this document valid according to the schema above?

According to me, it's not because <a> and <b> elements shouldn't be qualified but they are qualified here because of default namespace. Am I correct?

Thanks in advance for your care.
 
Rodrigo Dinis
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Oguz,

You're not correct. What RMH book said is the elements would be implicitly qualified, not exactly qualified through the default namespace. You said in the elementFormDefault attribute that you want unqualified elements, so the document is correct because you didnt qualify the elements.

Regards,

Rodrigo.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic