Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Element + complextype name in xml schema

Reply
Thread Tools

Element + complextype name in xml schema

 
 
Nicolas Mailhot
Guest
Posts: n/a
 
      04-08-2005
Hi,

I've been sent an xsd that uses the following construct :

<xsi:element name="foo">
<xsi:complexType name="foo">

Is this something allowed ? I couldn't find anything that said it's
wrong, but at the same time I have an xml parser that chokes on it and
none of the public xsd examples I've ever seen used it. I'd like to
know if I should file a bug on the parser or if I can tell the people
that send me the schema their definition does not fly.

I've little experience on xml schemas so far though it looks like I'm
up for an accelerated course.

Regards,

--
Nicolas Mailhot
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      04-08-2005


Nicolas Mailhot wrote:


> I've been sent an xsd that uses the following construct :
>
> <xsi:element name="foo">
> <xsi:complexType name="foo">
>
> Is this something allowed ? I couldn't find anything that said it's
> wrong, but at the same time I have an xml parser that chokes on it and
> none of the public xsd examples I've ever seen used it. I'd like to
> know if I should file a bug on the parser or if I can tell the people
> that send me the schema their definition does not fly.


I think it is allowed to have types and elements with the same name as
different scopes are used for type names and for element names.
I am however not sure it makes sense to have a name attribute on that
anonymous type nested inside the element declaration, usually if you
want to name a type you use
<xsd:complexType name="foo">
...
</xsd:complexType>

<xsd:element name="foo" type="foo" />


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Nicolas Mailhot
Guest
Posts: n/a
 
      04-08-2005
On Fri, 08 Apr 2005 17:36:33 +0200, Martin Honnen wrote:

> I am however not sure it makes sense to have a name attribute on that
> anonymous type nested inside the element declaration,


Sure, if it made sense it'd be used more often. But before I complain
about it I'd like to be dead-sure it's not allowed - if it were my own xsd
this would be different.

I _so_ wish there was an w3c validator service for xsds. The specs
themselves are sometimes not readable by mere mortals, and who's to say
one third-party tool is more right than another ?

Regards

--
Nicolas Mailhot
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      04-10-2005


Nicolas Mailhot wrote:


> But before I complain
> about it I'd like to be dead-sure it's not allowed - if it were my own xsd
> this would be different.


I have had a look through
http://www.w3.org/TR/xmlschema-1/#Co...pe_Definitions
and can't find anything in there suggesting that the name attribute on
xs:complexType is only allowed in certain cases or disallowed in other
cases.

However both Xerces Java as well as MSXML complain about that case and
indeed the schema for schemas says for topLevelComplexType

<xs:complexType name="topLevelComplexType">
<xs:complexContent>
<xs:restriction base="xs:complexType">
<xs:sequence>
<xs:element ref="xs:annotation" minOccurs="0"/>
<xs:group ref="xs:complexTypeModel"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NCName" use="required"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:restriction>
</xs:complexContent>

so there the name attribute is required while for localComplexType

<xs:complexType name="localComplexType">
<xs:complexContent>
<xs:restriction base="xs:complexType">
<xs:sequence>
<xs:element ref="xs:annotation" minOccurs="0"/>
<xs:group ref="xs:complexTypeModel"/>
</xs:sequence>
<xs:attribute name="name" use="prohibited"/>
<xs:attribute name="abstract" use="prohibited"/>
<xs:attribute name="final" use="prohibited"/>
<xs:attribute name="block" use="prohibited"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

the name attribute is prohibited.

So you should complain if someone sends you a schema with
<xs:element name="element-name">
<xs:complexType name="type-name">
as the name attribute on the local complex type is prohibited thus the
schema is not valid.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Nicolas Mailhot
Guest
Posts: n/a
 
      04-11-2005
Hi all,

For those who wonder I posted the same question on the w3c schema list
and everyone agreed this construct was forbidden by the spec (look up
the thread in archives for all the normative quotations)

So my problem is solved.

Thanks to everyone involved here

--
Nicolas Mailhot
 
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
XML Schema - Overwrite Element - ComplexType Istvan XML 1 08-22-2006 03:28 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
complexType in Xml Schema Peter Theill XML 2 11-25-2004 08:22 PM
xml schema complextype indicator tsolbjor XML 0 07-19-2004 01:17 PM
XML-Schema: How can I use a complexType without a certain order of elements? Wolfgang XML 2 10-07-2003 07:50 AM



Advertisments