Namespace in schema Question

Discussion in 'XML' started by kurtrips@gmail.com, May 21, 2006.

  1. Guest

    Hi,

    The schema tag (the root tag) of a schema file looks like

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">

    It is mentioned on many web pages across the net that
    "the parser does not connect to the server and try to download the
    document that's found at http://www.w3.org/2001/XMLSchema. Indeed
    there may not be any such document".

    So if this is only used as prefix, I may instead have
    <xs:schema xmlns:xs="anything"
    elementFormDefault="qualified">.

    But when I validate my xml with this new xsd, I get "The element
    'Books' is used but not declared in the DTD/Schema." It works fine in
    case 1. (Books is the root element of my xml file).
    Is this because this URL is hardcoded somewhere in the code of the
    parser itself?
    (I am using the MSXML 3.0 parser.)
    , May 21, 2006
    #1
    1. Advertising

  2. wrote:
    > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > Is this because this URL is hardcoded somewhere in the code of the
    > parser itself?


    Namespace URIs are meaningful even though there's often no "resource" at
    the location they name. In this case, the specific URI being bound to
    the xs: prefix is the one which is explicitly reserved for use in
    defining schemas. If you use something else, this XML document is no
    longer a schema document.

    The whole point of namespaces is that they are named groups of names. If
    you change the name of the group (the namespace URI), the names are no
    longer part of that group.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, May 21, 2006
    #2
    1. Advertising

  3. Guest

    Thanks for the prompt reply.

    Joe Kesselman wrote:
    > In this case, the specific URI being bound to
    > the xs: prefix is the one which is explicitly reserved for use in
    > defining schemas. If you use something else, this XML document is no
    > longer a schema document.


    I do think that this *explicit reservation* is declared inside the
    parser code. There's no other possible place.
    , May 21, 2006
    #3
  4. wrote:
    > I do think that this *explicit reservation* is declared inside the
    > parser code. There's no other possible place.


    Well, inside the schema processing code, which is usually but not
    necessarily part of the parser per se, but why quibble.

    The important thing is that it's declared in the schema spec. <grin/>


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, May 21, 2006
    #4
  5. In article <>,
    <> wrote:

    >So if this is only used as prefix, I may instead have
    ><xs:schema xmlns:xs="anything"
    >elementFormDefault="qualified">.
    >
    >But when I validate my xml with this new xsd, I get "The element
    >'Books' is used but not declared in the DTD/Schema." It works fine in
    >case 1. (Books is the root element of my xml file).
    >Is this because this URL is hardcoded somewhere in the code of the
    >parser itself?


    Yes. That's how it distinguishes schema declarations from other things,
    by their being in the namespace http://www.w3.org/2001/XMLSchema.
    With your modified declaration, <xs:element name="Books"> is no longer
    a schema declaration at all, so any <Books> elements are undeclared.

    -- Richard
    Richard Tobin, May 21, 2006
    #5
    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,494
    Markus
    Nov 23, 2005
  2. Klaus Johannes Rusch

    Re: Convert DB2 schema to XML Schema

    Klaus Johannes Rusch, Aug 6, 2003, in forum: XML
    Replies:
    0
    Views:
    548
    Klaus Johannes Rusch
    Aug 6, 2003
  3. Fred Smith
    Replies:
    1
    Views:
    921
    Martin Honnen
    Feb 5, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,166
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    1
    Views:
    500
    George Bina
    Jul 20, 2006
Loading...

Share This Page