473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Element + complextype name in xml schema

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
Jul 20 '05 #1
4 1324


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/
Jul 20 '05 #2
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
Jul 20 '05 #3


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/
Jul 20 '05 #4
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
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: wooks | last post by:
<?xml version="1.0" ?> - <xsd:schema targetNamespace="urn:faster:userlogin" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:faster:userlogin"> <xsd:include...
0
by: CJ | last post by:
I started with this schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="response"> <xs:complexType> <xs:sequence> <xs:element...
4
by: Gordon Dickens | last post by:
I have target xml to generate from schema. All of the XML instances have the same global element i.e. <base>. I would like to combine all of the schemas into a single schema where I could...
6
by: Wole Ogunremi | last post by:
I guess this is a well asked question but it is tripping me up! I'm putting a forum together allowing xhtml markup content. I am validating against a schema but getting "Could not find schema...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
4
by: joewhitehair | last post by:
Using a schema, I created classes for my web service using the XSD.exe tool. With the classes I then wrote a web service function, but the WSDL that is generated has different minOccurs and...
0
by: bjhartin | last post by:
Hello, I'm struggling to extend the types defined in a schema. I've searched this group (and others) with no luck so far. I have the following two schemas: <!-- foobar.xsd --> <!-- A...
1
by: tankbattle | last post by:
That is, what's the difference between <complexType name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element...
2
by: mlb5000 | last post by:
I seem to be having issues validating an XML document using my schema. Both are below: The Schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema...
0
by: icesign | last post by:
I know that the selector of these elements has a scope relative to the element being declared, but maybe there is a way to get beyond bounds of this scope or maybe just a way to extend base element?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.