473,387 Members | 1,545 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,387 software developers and data experts.

complexType in Xml Schema

Hi,

I'm trying to build an element which will allow Xml such as:

<location type="home">
<AddressLine1>xyz</AddressLine1>
</location>

<location type="work url">
<Url>http://xyz/</Url>
</location>

The content of the location node should allow anything so I'm trying to use
xsd:anyType. I've defined this complex type:

<xsd:complexType name="location">
<xsd:complexContent>
<xsd:extension base="xsd:anyType">
<xsd:attribute name="type" type="xsd:string" use="required" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

However my schema validator (XmlSchemaSet class of the .NET 2.0 frameworK)
can't validate and tells me "The derived type and the base type must have
the same content type.". What do I miss?
--
Rgd,
Peter Theill - http://www.theill.com/

Jul 20 '05 #1
2 2898


Peter Theill wrote:

I'm trying to build an element which will allow Xml such as:

<location type="home">
<AddressLine1>xyz</AddressLine1>
</location>

<location type="work url">
<Url>http://xyz/</Url>
</location>

The content of the location node should allow anything so I'm trying to use
xsd:anyType. I've defined this complex type:

<xsd:complexType name="location">
<xsd:complexContent>
<xsd:extension base="xsd:anyType">
<xsd:attribute name="type" type="xsd:string" use="required" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

However my schema validator (XmlSchemaSet class of the .NET 2.0 frameworK)
can't validate and tells me "The derived type and the base type must have
the same content type.". What do I miss?


Why can't you use
<xsd:complexType>
<xsd:sequence>
<xsd:any />
<xsd:sequence>
<xsd:attribute ... />
</xsd:complexType>
that is the proper way I think, you can then also decide whether to have
precessContents="lax" or processContents="skip" on the xsd:any element.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
> that is the proper way I think, you can then also decide whether to have
precessContents="lax" or processContents="skip" on the xsd:any element.


Thanks Martin, that was exactly what I was looking for. Now my validator is
able to process the file just fine.

Rgd,
Peter Theill
Jul 20 '05 #3

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

Similar topics

2
by: Moth | last post by:
On my first night with schemas, things are not proceeding according to expectations. Given three distinct complexType layouts: <sequence> multiple elements in strict sequence <choice> one...
2
by: Wolfgang | last post by:
Hello, I would like to use the schema, without asking for a certain order. "Sequence" is therefore not the answers. How can I do this? I want to use a order like: C1 E C2 E D E C1 D D C1
2
by: D. Alvarado | last post by:
Hello, I am trying to validate my XML document against a schema using the Sun Multi-Schema XML Validator. Unfortunately, my schema fails to validate, and is failing because of this cryptic...
0
by: tsolbjor | last post by:
Hi, Im trying to make a Schema with a complexType that can include different elements. It is not a sequence, and when I use the "all" indicator I cant set the maxOccurs="unbounded". Heres...
2
by: unishippers.suckfeed.newshosting.com | last post by:
Thanks for the response, Priscilla, it was very useful, Now: what if I want to have an empty group that will only contain atomic sub elements of the containing type: <object> <things>...
4
by: Nicolas Mailhot | last post by:
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...
2
by: steve_marjoribanks | last post by:
I have a section of a schema below and I've got a problem I can'y figure out. I'm not having a good day though so it's probably just me being stupid!! ;-) I need the shearStrength element to have...
1
by: Istvan | last post by:
Hi ! Can somebody tell me if it's possible to overwrite an element definition when I derive an complexType (with extension, or something like this ) ? The base complexType looks like: ...
1
by: mahesh.kanakaraj | last post by:
Hi All, I have a confusion in finding the 'effective content' of a complex type definition in a XML Schema. I shall give you an example situation to clearly explain my problem. Let's have...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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,...

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.