473,467 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

XML Schema - inheritance, attribute redeclaration

Hi,

I have following problem with XML Schema definition.
I have following element InitialEcrHeader:

<xs:complexType name="InitialEcrHeader">
<xs:complexContent>
<xs:extension base="ecm:EcmObject">
<xs:sequence>
<xs:element name="CoordinatorContact" type="xs:token"
minOccurs="0" maxOccurs="unbounded"></xs:element>
<xs:element name="EcManager" type="xs:token" minOccurs="0"></
xs:element>
<xs:element name="DistributionList" type="xs:token"
minOccurs="0" maxOccurs="unbounded"></xs:element>
<xs:element name="LeadingChangeScope" type="xs:token"
minOccurs="0" maxOccurs="unbounded"></xs:element>
<xs:element name="ParticipantContact" type="xs:token"
minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

There is element EcrHeader which inherits from InitialEcrHeader:
<xs:complexType name="EcrHeader">
<xs:complexContent>
<xs:extension base="ecr:InitialEcrHeader">
<xs:sequence>
<xs:element name="EcManager" type="xs:token"></xs:element>
<xs:element name="LeadingChangeScope" type="xs:token"
minOccurs="1" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

Goal:
In EcrHeader element there should be exatcly only one occurence of
EcManager. In InitialEcrHeader it is defined as optional. I would like
to overwrite this definition with the new one - in EcrHeader. But
while instantiating this XML Schema it is allowed to create 2
EcManager elements inside EcrHeader - and it is not allowed for my
case.
Can someone give a tip how to achive that?

<p:Header key="a2" xsi:type="p:EcrHeader">
<p:Description key="a3">
<p:Text>sd</p:Text>
</p:Description>
<p:EcManager>aa</p:EcManager>
<p:EcManager>bb</p:EcManager>
<p:LeadingChangeScope>dd</p:LeadingChangeScope>
</p:Header>

TIA
Krzysztof Nogal

Apr 23 '07 #1
2 3416
Hi Krzysztof,

The derivation you posted is invalid. You are trying to restrict the
original type and your example uses extension - this won't work. Here's
what you need:

<xs:complexType name="EcrHeader">

<xs:complexContent>

<xs:restriction base="ecr:InitialEcrHeader">

<xs:sequence>

<xs:element name="EcManager" type="xs:token"/>

<xs:element name="LeadingChangeScope" type="xs:token"
minOccurs="1" maxOccurs="unbounded"/>

</xs:sequence>

</xs:restriction>

</xs:complexContent>

</xs:complexType>
Note, if you want to keep other elements in this type, you'll need to list
them in the sequence.

--
Stan Kitsis
Program Manager
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Krzysztof Nogal" <kn****@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Hi,

I have following problem with XML Schema definition.
I have following element InitialEcrHeader:

<xs:complexType name="InitialEcrHeader">
<xs:complexContent>
<xs:extension base="ecm:EcmObject">
<xs:sequence>
<xs:element name="CoordinatorContact" type="xs:token"
minOccurs="0" maxOccurs="unbounded"></xs:element>
<xs:element name="EcManager" type="xs:token" minOccurs="0"></
xs:element>
<xs:element name="DistributionList" type="xs:token"
minOccurs="0" maxOccurs="unbounded"></xs:element>
<xs:element name="LeadingChangeScope" type="xs:token"
minOccurs="0" maxOccurs="unbounded"></xs:element>
<xs:element name="ParticipantContact" type="xs:token"
minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

There is element EcrHeader which inherits from InitialEcrHeader:
<xs:complexType name="EcrHeader">
<xs:complexContent>
<xs:extension base="ecr:InitialEcrHeader">
<xs:sequence>
<xs:element name="EcManager" type="xs:token"></xs:element>
<xs:element name="LeadingChangeScope" type="xs:token"
minOccurs="1" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

Goal:
In EcrHeader element there should be exatcly only one occurence of
EcManager. In InitialEcrHeader it is defined as optional. I would like
to overwrite this definition with the new one - in EcrHeader. But
while instantiating this XML Schema it is allowed to create 2
EcManager elements inside EcrHeader - and it is not allowed for my
case.
Can someone give a tip how to achive that?

<p:Header key="a2" xsi:type="p:EcrHeader">
<p:Description key="a3">
<p:Text>sd</p:Text>
</p:Description>
<p:EcManager>aa</p:EcManager>
<p:EcManager>bb</p:EcManager>
<p:LeadingChangeScope>dd</p:LeadingChangeScope>
</p:Header>

TIA
Krzysztof Nogal

Apr 27 '07 #2
Hi Stan,

Thanks for the tip - it is exactly what I missed here. It solved my
problem. Thanks!

Regards,
Krzysztof Nogal

Apr 30 '07 #3

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

Similar topics

6
by: Patrick K. O'Brien | last post by:
I'm looking for a good schema to use as an example for an object database system. Something like a books/authors/publishers or teachers/students/courses kind of thing. There are plenty of...
0
by: peterpeter | last post by:
Hi. There is a XML schema problem that I have with key/keyref: I have two complex (A and B) types which both inherit from a common base typ (Base). A refers B using a xs:IDREF element named...
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...
0
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
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...
0
by: Derek | last post by:
I am creating an intranet using Visual Web Developer Express Edition. Everything has been working OK until yesterday when I started getting 62 messages all beginning "Could not find schema...
3
by: Eric Lilja | last post by:
Hello again, I'm having a new problem converting a dtd to an xml schema. This once is a little bit more complicated than in my previous question. The following file validates correctly: <?xml...
2
by: Wilson | last post by:
Hi, a very simple question. I am trying to understand inheritance using c++ and dont cee how i could use three classes to create an accounting program using inheritance. e.g one class containing...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
1
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.