XML Schema questions (hopefully not too silly)

G

Gus Gassmann

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
 
M

Martin Honnen

Gus said:
<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.
 
G

Gus Gassmann

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
 
M

Martin Honnen

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top