473,569 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Element + complextype name in xml schema

Hi,

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

<xsi:element name="foo">
<xsi:complexTyp e 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 1340


Nicolas Mailhot wrote:

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

<xsi:element name="foo">
<xsi:complexTyp e 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:complexTyp e 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 topLevelComplex Type

<xs:complexTy pe name="topLevelC omplexType">
<xs:complexCont ent>
<xs:restricti on base="xs:comple xType">
<xs:sequence>
<xs:element ref="xs:annotat ion" minOccurs="0"/>
<xs:group ref="xs:complex TypeModel"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NCName " use="required"/>
<xs:anyAttribut e namespace="##ot her" processContents ="lax"/>
</xs:restriction>
</xs:complexConte nt>

so there the name attribute is required while for localComplexTyp e

<xs:complexTy pe name="localComp lexType">
<xs:complexCont ent>
<xs:restricti on base="xs:comple xType">
<xs:sequence>
<xs:element ref="xs:annotat ion" minOccurs="0"/>
<xs:group ref="xs:complex TypeModel"/>
</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:anyAttribut e namespace="##ot her" processContents ="lax"/>
</xs:restriction>
</xs:complexConte nt>
</xs:complexType>

the name attribute is prohibited.

So you should complain if someone sends you a schema with
<xs:element name="element-name">
<xs:complexTy pe 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
3227
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 schemaLocation="C:\Faster\App\Demo\DataTypes\login.xsd" /> <xsd:include schemaLocation="C:\Faster\App\Demo\DataTypes\password.xsd" /> - <xsd:complexType name="userloginType"> -...
0
1821
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 name="SysTime" type="xs:string"/> <xs:element name="Item"> <xs:complexType> <xs:sequence>
4
2383
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 generate any of the specific instances. sample schema one: <?xml version="1.0" encoding="UTF-8"?> <xs:schema...
6
2441
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 information for element <elementName>... I would appreciate if anyone could advice where I am going wrong. TIA Here's my xsd:
6
2569
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 schema for it with Visual Studio, I get the error "Failed to create a schema for this data file because:
4
2494
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 maxOccurs values for my elements. I can seem to figure out why this has changed or how to correct it. I can't find any way to manually modify the classes...
0
1286
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 'base' schema which will be 'extended' by customer specific ones --> <xs:schema ...>
1
4734
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 name="city" type="string"/> </sequence> </complexType> and <complexType name="Address" block="restriction">
2
18136
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 xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Receivers" > <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element ref="MulticastReceiver"/>
0
2798
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? Here’s a working example: <xs:schema id="schema" targetNamespace="http://tempuri.org/schema.xsd" elementFormDefault="qualified" ...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.