XSD: What is elementFormDefault="qualified" for?

D

daz_oldham

Hi everyone

I am a new poster to this group, so hello to you all!

Having just started a new job I have been thrown in the deep end with
some heavy XML work so I am finding my feet and I am sure that this
will be the first of many posts on here!

My first question is to do with Complex Types in XSD. I have figured
out what a complex type is, and I have found that what the API provider
is doing, is to do <xs:extension /> in a secondary set of XSDs.

What I have noticed is that at the top of the XSD in the <xs:schema />
opening tag, it says elementFormDefault="qualified" - and I was just
wondering if somebody could tell me what it is there for because I
can't find any documentation on what it does?

Many thanks in advance

Darren
 
B

Boris Kolpackov

Hi Darren,

daz_oldham said:
What I have noticed is that at the top of the XSD in the <xs:schema />
opening tag, it says elementFormDefault="qualified" - and I was just
wondering if somebody could tell me what it is there for because I
can't find any documentation on what it does?

elementFormDefault="qualified" declaration indicates that all elements,
even local (i.e., those defined within complexType) should be qualified
in the instance documents.

hth,
-boris
 
D

daz_oldham

Thanks Boris, I know that you're answer is spot-on but still with my
newbie hat on - what does "qualified" mean?

I know that is a very novice question, but as I say, I am really new to
all this!

Many thanks

Darren
 
S

Stan Kitsis [MSFT]

All "qualified" elements and attributes are in the targetNamespace of the
schema and all "unqualified" elements and attributes are in no namespace.
All global elements and attributes are qualified.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Joe Kesselman

"Qualified", in XML terms, means "Associated with a namespace, either by
the use of a declared prefix or via a default namespace declaration".

As to what elementFormDefault means: It indicates "whether or not
locally declared elements and attributes must be unqualified." See the
discussion and examples at

http://www.w3.org/TR/2004/REC-xmlschema-0-20041028/#NS
 
B

Boris Kolpackov

Darren,

daz_oldham said:
Thanks Boris, I know that you're answer is spot-on but still with my
newbie hat on - what does "qualified" mean?

Ok, I guess an example is in order:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/library"
elementFormDefault="qualified">

<xsd:element name="catalog">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="book" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:schema>


With this schema, your instance would then look lool like this:

<lib:catalog xmlns:lib="http://www.example.com/library">
<lib:book>XML Schema</lib:book>
</lib:catalog>

If you change the above schema to read elementFormDefault="uqualified",
then the instance becomes:

<lib:catalog xmlns:lib="http://www.example.com/library">
<book>XML Schema</book>
</lib:catalog>

In XML Schema terms, in the first case, local element catalog/book belongs
to the http://www.example.com/library namespace (and therefore has to be
prefixed with the corresponding namespace prefix (lib in our case)). In
the second case, the same element does not belong to any namespace and
therefore can be used as-is in the instance document.


hth,
-boris
 
Joined
Jan 18, 2008
Messages
1
Reaction score
0
Element form default-confusion ...

Element form default is kept qualified when the namespace is not needed to be hidden in the xml document or instance document .That means for all the elements in the xml document you have to prefix the namspace variable also.
All the elements in the instance document must have namespace variables prefixed with them.

Element form default is kept unqualified when the namespace needs to be hidden in the xml schema itself and need not be exposed in the instance document. That means all the elements that are used in the xml document don't have to be prefixed with the namspace variables. Only the root element has to be prefixed with the namespace variable.

--regards
Andy
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top