473,763 Members | 4,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML schema: duplicate element occurences

Hi

How do I express - in XSD - that an element can contain a sequenced
list of elements, and one of these elements may occur (0-n times) at
BOTH sequence position x AND y?

Example:
<PRIORITY sorting="900"/>
<NAMEINFO>
subtags and data
</NAMEINFO>
<EXTRA_LINE>
subtags and data
</EXTRA_LINE>
<EXTRA_LINE>
subtags and data
</EXTRA_LINE>
<ADDRINFO>
subtags and data
</ADDRINFO>
<PHONEINFO>
subtags and data
</PHONEINFO>
<EXTRA_LINE>
subtags and data
</EXTRA_LINE>

Currently, my schema looks something like:
<xs:complexType >
<xs:sequence>
<xs:element name="PRIORITY" maxOccurs="1" minOccurs="1">
blablabla
</xs:element>
<xs:element name="NAMEINFO" minOccurs="0">
blablabla
</xs:element>
<xs:element name="LOGO" minOccurs="0">
blablabla
</xs:element>
<xs:element name="EXTRA_LIN E" maxOccurs="10" minOccurs="0">
blablabla
</xs:element>
<xs:element name="ADDRINFO" >
blablabla
</xs:element>
<xs:element name="PHONEINFO ">
blablabla
</xs:element>
<xs:element name="EXTRA_LIN E" maxOccurs="10" minOccurs="0">
blablabla
</xs:element>
</xs:complexType>
</xs:element>

Validation says: Duplicated definition for: 'EXTRA_LINE'

I know I can just rename one of my EXTRA_LINE groups or add an extra
level somewhere, but I'm not too keen on that...

Any suggestions?

Regards
/John
Jul 20 '05 #1
2 4577
That's not a very helpful error message, I agree, but _if_ the
blablabla that you have edited out is <xs:complexType >
.. . . </xs:complexType> then there is indeed a problem. You're not
allowed to have the same element with two different type definitions
in the same content model. If your two EXTRA_LINE elements actually
have (textually) the _same_ type definition, move it out to the top
level, give it a name, and change your model above to use

<xs:element name="EXTRA_LIN E" ref="[your type]" min=0 max=10/>

and you should be fine.

ht

[1] http://www.w3.org/2001/03/webdata/xsv
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jul 20 '05 #2

The "<xs:elemen t name="EXTRA_LIN E" ref="[your type]" min=0 max=10/>"
was excatly what I needed...

Thanks a lot!!!

/John

Jul 20 '05 #3

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

Similar topics

0
1464
by: cr | last post by:
Could somebody tell me whether the use of duplicate element definition or reference are permitted in XML schemas? For example: <complexType name="PurchaseOrderType"> <sequence> <element name="shipTo" type="string"/> <element name="shipTo" type="string"/> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1
1393
by: Robert Ludewig | last post by:
<LinkList> <Link ID="A01" /> <Link ID="A02" /> <Link ID="A03" /> <Link ID="A01" /> </LinkList> How can I specify in a xmlschema that in the linklist are no occurences with same ID ? (Last Link is illegal)
4
2507
by: Iain A. Mcleod | last post by:
Hi I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema: project and projectCollection. A projectcollection is just a set of projects. Therefore, I wish to include the project customType in the projectCollection namespace. I therefore have declared two xsd documents: project.xsd and projectcollection.xsd
16
6016
by: Brad Wood | last post by:
I'm using a 2.0 XmlReaderSettings object with setting.ValidationType set to ValdationType.Schema to validate a document against a schema. Following is a schema fragment (names altered): <xsd:element name="Stuff"> <xsd:complexType> <xsd:sequence> <xsd:element ref="RequiredSimpleThing1"/> <xsd:element ref="RequiredSimpleThing2"/> <xsd:element name="OptionalSimpleThing1" type="OptionalType"
5
3417
by: j.tremlett | last post by:
Hi, I have read various articles on this and I have had a few suggestions but would like to know which is correct. I have an XML file with the element <root> Within <root> I can have a number of child elements occuring in any order and any number of times.
1
373
by: Nichino | last post by:
Hello, I'm trying to define my first Xml Schema and have a problem. The XML I'd like to define through the Schema is the following one. Can you help me please? I don't know how to insert the 3 final notes. Many thanks and my apologies for the trouble. Best, Nick <language>
2
567
by: bmichel | last post by:
Regarding the XSD schema shown below, I want to modifiy it so that: - the "owner_id" attribute in the "dog" element to exist in one of the "owner" element "id" attribute. - the "id" attribute in the "owner" element is unique. How should I modify the XSD? Examples (in the xml): Example 1 should be validated == Example 1 ==
3
544
by: calestar | last post by:
Hi ! I'm kinda beginning with XML and I've got this fairly complex schema (±108 KB on 9 files ... ). I need to do some restriction in it. The structure is something like : -------------------------------------------------------------------- <xs:complexType name="myElem"> <xs:sequence> <xs:element name="title" type="xs:string" />
0
2824
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" xmlns="http://tempuri.org/schema.xsd" xmlns:mstns="http://tempuri.org/schema.xsd" ...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9997
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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

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.