Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSD: What is elementFormDefault="qualified" for?

Reply
Thread Tools

XSD: What is elementFormDefault="qualified" for?

 
 
daz_oldham
Guest
Posts: n/a
 
      05-12-2006
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

 
Reply With Quote
 
 
 
 
Boris Kolpackov
Guest
Posts: n/a
 
      05-12-2006
Hi Darren,

"daz_oldham" <(E-Mail Removed)> writes:

> 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

 
Reply With Quote
 
 
 
 
daz_oldham
Guest
Posts: n/a
 
      05-15-2006
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

 
Reply With Quote
 
Stan Kitsis [MSFT]
Guest
Posts: n/a
 
      05-15-2006
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.

"daz_oldham" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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
>



 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      05-15-2006
"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

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
Boris Kolpackov
Guest
Posts: n/a
 
      05-16-2006
Darren,

"daz_oldham" <(E-Mail Removed)> writes:

> 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 xmlnssd="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
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
 
Reply With Quote
 
andyC andyC is offline
Junior Member
Join Date: Jan 2008
Posts: 1
 
      01-18-2008
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 by andyC; 01-18-2008 at 07:45 AM.. Reason: name not given
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments