XML Schema questions (hopefully not too silly)

Discussion in 'XML' started by Gus Gassmann, Sep 19, 2007.

  1. Gus Gassmann

    Gus Gassmann Guest

    Hi all:

    I've been working with XML schemas for about a year now, strictly
    monkey-see-monkey-do so far. (For instance, I did not know about
    namespaces until yesterday.) My access to the internet is also rather
    intermittent at the moment, so please be gentle...

    My question concerns the control elements in XML Schema, such as
    <sequence>, <choice>, <type>, etc. I was given an XML reader that I
    need to tweak to my own setup. The reader seems to assume that the
    control elements all live in the default namespace (no prefixes),
    while the XML schemas I have all use a declared namespace instead.
    It's easy enough to change the reader, but I want to be sure that
    this does not break anything else later on.

    Hence the question: Are the control elements <choice>, <sequence>,
    <type>, etc. reserved or is it possible/advisable/normal to redefine
    them somehow and to use the redefined or renamed elements in place of
    the original ones at http://www.w3.org/2001/XMLSchema.

    Let's say I have something like:

    <?xml version="1.0" encoding="US-ASCII"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:mine="foo"
    targetNamespace="foo" elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <complexType name="choice">
    ....

    Is this legal?

    Put another way: say, I am parsing an XML schema. When I find an
    element <mine:choice> in a namespace other than "http://www.w3.org/
    2001/XMLSchema", is it safe to assume that it does _not_ set up a
    choice the way <choice> does in XML Schema?

    Also, it appears to be legal for an <element> to have a name but no
    type. (I was given an example that parses in my development system,
    XMLSpy.) Is there such a thing as a default type? Is it safe to treat

    <element name="foobar"/>

    as a string?

    Thanks very much for any feedback.

    gus gassmann
    Gus Gassmann, Sep 19, 2007
    #1
    1. Advertising

  2. Gus Gassmann wrote:

    > <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:mine="foo"
    > targetNamespace="foo" elementFormDefault="qualified"
    > attributeFormDefault="unqualified">
    >
    > <complexType name="choice">
    > ...
    >
    > Is this legal?
    >
    > Put another way: say, I am parsing an XML schema. When I find an
    > element <mine:choice> in a namespace other than "http://www.w3.org/
    > 2001/XMLSchema", is it safe to assume that it does _not_ set up a
    > choice the way <choice> does in XML Schema?


    Your sample above defines a complex type named 'choice' in the target
    namespace named 'foo'. It does not define an element at all.
    However if it defined an element named 'choice' in the namespace 'foo'
    then that is not a choice element in the W3C XML schema namespace
    http://www.w3.org/2001/XMLSchema and therefore does have a completely
    different meaning.

    > Also, it appears to be legal for an <element> to have a name but no
    > type. (I was given an example that parses in my development system,
    > XMLSpy.) Is there such a thing as a default type? Is it safe to treat
    >
    > <element name="foobar"/>
    >
    > as a string?


    No, such an element can have any contents, see
    <URL:http://www.w3.org/TR/xmlschema-0/#anyType>. There are no
    constraints at all on the contents of that element so it could have
    simple contents of any type as well as child elements.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Sep 19, 2007
    #2
    1. Advertising

  3. Gus Gassmann

    Gus Gassmann Guest

    Martin,

    thank you very much for your informative response. May I ask a follow-
    up question: Is it mandatory for an XML schema to use
    http://www.w3.org/2001/XMLSchema as one of the namespaces? Could one
    write a valid schema with a different namespace?

    Cheers

    gus
    Gus Gassmann, Sep 20, 2007
    #3
  4. Gus Gassmann wrote:

    > thank you very much for your informative response. May I ask a follow-
    > up question: Is it mandatory for an XML schema to use
    > http://www.w3.org/2001/XMLSchema as one of the namespaces? Could one
    > write a valid schema with a different namespace?


    That namespace http://www.w3.org/2001/XMLSchema is used and defined for
    the W3C XML schema language here: <URL:http://www.w3.org/TR/xmlschema-1/>.

    There are other schema languages using other namespaces.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Sep 20, 2007
    #4
    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,498
    Markus
    Nov 23, 2005
  2. Fred Smith
    Replies:
    1
    Views:
    928
    Martin Honnen
    Feb 5, 2004
  3. Hari Om
    Replies:
    1
    Views:
    452
    Martin SChukrazy
    Mar 2, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,173
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    3
    Views:
    2,799
Loading...

Share This Page