XSD: What is elementFormDefault="qualified" for?

Discussion in 'XML' started by daz_oldham, May 12, 2006.

  1. daz_oldham

    daz_oldham Guest

    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
    daz_oldham, May 12, 2006
    #1
    1. Advertising

  2. Hi Darren,

    "daz_oldham" <> 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
    Boris Kolpackov, May 12, 2006
    #2
    1. Advertising

  3. daz_oldham

    daz_oldham Guest

    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
    daz_oldham, May 15, 2006
    #3
  4. 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" <> wrote in message
    news:...
    > 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
    >
    Stan Kitsis [MSFT], May 15, 2006
    #4
  5. "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
    Joe Kesselman, May 15, 2006
    #5
  6. Darren,

    "daz_oldham" <> 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 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
    --
    Boris Kolpackov
    Code Synthesis Tools CC
    http://www.codesynthesis.com
    Open-Source, Cross-Platform C++ XML Data Binding
    Boris Kolpackov, May 16, 2006
    #6
  7. daz_oldham

    andyC

    Joined:
    Jan 18, 2008
    Messages:
    1
    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: Jan 18, 2008
    andyC, Jan 18, 2008
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,098
    Markus
    Nov 22, 2005
  2. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    484
    C. M. Sperberg-McQueen
    Sep 26, 2003
  3. Replies:
    1
    Views:
    855
    Martin Honnen
    Jan 14, 2004
  4. dickster
    Replies:
    3
    Views:
    780
    dickster
    Feb 20, 2006
  5. Szabolcs Borsanyi

    Pointer to qualified poitner to qualified object

    Szabolcs Borsanyi, May 30, 2008, in forum: C Programming
    Replies:
    13
    Views:
    556
    Keith Thompson
    Jun 8, 2008
Loading...

Share This Page