473,324 Members | 2,541 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,324 software developers and data experts.

Elements with maxOccurs (some unbound, some 1)

Maybe I am looking to far into a simple problem, but I am having quite
a hard time figuring this out:

I am currently trying to create a schema to represent an Element which
contains other Elements (some of which have a restriction on how many
can occur). Here is an example of what I have done if that seems
confusing:

<xsd:element name="Object">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element ref="License" minOccurs="0"/>
<xsd:element ref="NameMemberReference" minOccurs="0"
maxOccurs="1"/>
<xsd:element ref="ParentMemberReference" minOccurs="0"
maxOccurs="1"/>
<xsd:element ref="Members"/>
<xsd:element ref="OnEdit" minOccurs="0"/>
<xsd:element ref="OnCommit" minOccurs="0"/>
<xsd:element ref="Permissions" minOccurs="0"/>
</xsd:choice>
<xsd:attribute ref="name" use="required"/>
</xsd:complexType>
</xsd:element>

I think the trouble with this is that the two elements that need to be
restricted to one occurance (NameMememberReference and
ParentMemberReference) are within an unbounded choice so they still
can be created multiple times.

I've played around with some other idea by using a Choice and an All
and I've also trying making groups but nothing has seemed to solve my
problem. Any ideas?

Thanks,
- Marc

May 22 '07 #1
3 2419
fo***********@gmail.com wrote:
Any ideas
Do you really need to leave the order unconstrained? If you're willing
to nail down the order slightly, factor the two maxOccurs='1' items out
and enclose them and the choice in a sequence.

Or make the whole thing a sequence and just require folks to give the
contents in that specific order, if there isn't a good reason to let
them randomly intermix the contents.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
May 22 '07 #2
Joseph Kesselman <keshlam-nos...@comcast.netwrote:
Do you really need to leave the order unconstrained?
Yep, the order is going to have to be left open. It's something beyond
my control.

May 23 '07 #3
If it was just a single constrained element, I'd suggest breaking it up
into submodels -- any mixture of the others, that one, any mixture of
the others.

With two, and being unwilling to constrain their order... I think you
can do it by combining that idea with Martin's solution in the thread
entitled "Xml Schema OR, XOR", breaking things down into non-redundant
cases. But you're going to wind up with a lot of copy-and-repeat Schema
code to express that.

There may be a better solution; my schema skills aren't supurb.

There's always the alternative of applying the at-most-one constraint in
applications (semantic validation) rather than in schemas (higher-level
syntactic validation).

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
May 23 '07 #4

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

Similar topics

4
by: Christine McGavran | last post by:
To continue a previous thread, sort of... I have defined a schema for describing a windows-style user interface. My application correctly parses and uses that schema. I'm now trying to get that...
9
by: Stanimir Stamenkov | last post by:
Using Xerces2 Java I'm trying to validate a CSV data following an XNI example <http://xml.apache.org/xerces2-j/xni-config.html#examples>. The CSV scanner generates XML tree events like: <csv>...
8
by: MENTAT | last post by:
Hi Guys, Newbie question here. Part of my xml looks like this. <node> <description/> <config/> <log/> <transition/> <node>
6
by: bosgoverde | last post by:
I've tried several ways to achieve a xsd schema for the following xml example, but failed to do so. Valid: <Person> <Interest>Movies</Interest> <Interest>Computers</Interest> </Person>...
4
by: Billy | last post by:
I have a current xsd that allows the xml to have 0..1 chassisid element and 0..1 terminalid element. But now I want to restrict these elements in a way that either both chassisid and terminalid...
0
by: John Harvey | last post by:
I have been struggling with the following: I want to create a class that contains an array of some user-defined type. so I have the following vb code: Public Class Communications Public...
2
by: mavis | last post by:
Could you please help me with this xsd definition? I need to define a set of elements occur in any order with multiple occurrences, but the same kind of elements need to group together... Sth...
2
by: klikic | last post by:
Hi. How can create a unordered sequence with defined elements that can occur ones and "other" elements that are ignored. Example: XML: <Recur> <ignoredElement>saasda</ignoredElement>...
4
by: BorisBoshond | last post by:
Hi all, Hope someone is able and willing to help me with following problem. I received a xsd file from another company, our company i supposed to return xml based on that xsd. Problem is that I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.