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

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_LINE" 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_LINE" 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 4548
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_LINE" 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:element name="EXTRA_LINE" 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
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...
1
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...
4
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...
16
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):...
5
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...
1
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...
2
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...
3
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 : ...
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: 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: 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
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: 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
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
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.