Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML schema: duplicate element occurences

Reply
Thread Tools

XML schema: duplicate element occurences

 
 
John Jørgensen
Guest
Posts: n/a
 
      07-07-2004
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
 
Reply With Quote
 
 
 
 
Henry S. Thompson
Guest
Posts: n/a
 
      07-08-2004
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:
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
Reply With Quote
 
 
 
 
John Jørgensen
Guest
Posts: n/a
 
      07-09-2004

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

Thanks a lot!!!

/John

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
number of occurences and trim methods... I need help .. nightrosee@gmail.com C++ 3 05-04-2006 10:20 AM
searching for the number of occurences of a string M.N.A.Smadi Python 3 03-06-2006 01:44 AM
C program to count occurences of substrings in strings JD C Programming 1 11-12-2005 11:56 AM
Counting occurences of words in a list of strings Travers Naran Python 4 05-25-2005 05:58 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57