aspose file tools
The moose likes Web Services Certification (SCDJWS/OCPJWSD) and the fly likes Question about qualified and unqualified elements Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCPJWSD)
Reply Bookmark "Question about qualified and unqualified elements" Watch "Question about qualified and unqualified elements" New topic
Author

Question about qualified and unqualified elements

Oguz Ozun
Greenhorn

Joined: May 10, 2007
Posts: 19
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

Joined: May 28, 2003
Posts: 40
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.


Rodrigo Dinis
SCEA
SCJWSD
SCJD
SCBCD
SCWCD
SCJP
CNA
Brasilia - BRASIL
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Question about qualified and unqualified elements
 
Similar Threads
XSD Schema Error in WSAD
how do I set xsd element attributes?
targetNamespace and default namespace
namespaces
targetNamespace,xmlns