Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML Schema questions (hopefully not too silly)

Reply
Thread Tools

XML Schema questions (hopefully not too silly)

 
 
Gus Gassmann
Guest
Posts: n/a
 
      09-19-2007
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      09-19-2007
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/
 
Reply With Quote
 
 
 
 
Gus Gassmann
Guest
Posts: n/a
 
      09-20-2007
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

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      09-20-2007
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/
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
Validation with XSD using XML::LibXML::Schema, and XML::Validator::Schema huntingseasonson@gmail.com Perl Misc 5 11-29-2006 12:37 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
XML Schema to XML Schema Conversion Hari Om XML 1 03-02-2004 09:04 PM
XML schema regular expressions question and recommended XML Schema book Fred Smith XML 1 02-05-2004 11:12 AM



Advertisments