This is one (of many) limitations of W3C schemas.  Relax NG is a little more
versatile, but it isn't perfect either.

> 2)  We could specify any order and any
> frequency for all items (choice maxOccurs="unbounded")
> which means they could do this:

Actually, you can't do that directly with W3C schemas because xs:all
restricts cardinality to 1 (minOccurs="0", maxOccurs="1").  You can get
around it though by using a group that uses "sequence" instead of "all",
setting maxOccurs on each item to "unbounded", and then referencing that
group with maxOccurs = unbounded in turn.

<rant>
The cause of this problem is the short-sighted and idiotic W3C decision that
allowing a cardinality of other than one in an xs:all construct would be
"too difficult for processors to implement."  This was such a stupid move
that it had to be political in nature and makes me wonder which member's
processor was so poorly written that they couldn't handle implementing
something like:

<xs:all>
        <xs:element name="n" minOccurs="3" maxOccurs="5"/>
        ...
</xs:all>

That is not a difficult case to handle at all.  A mere few moments of
thought reveals at least one reasonably efficient and recursable algorithm,
there are probably many others.
</rant>


I THINK Relax NG will do what you want using "interleave".

John Atchley
Senior Software Analyst
Engineering and Design, Courseware Support
FlightSafety International, Inc.
mailto:[EMAIL PROTECTED]


-----Original Message-----
From: Christopher Birkett [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 9:14 AM
To: [EMAIL PROTECTED]
Subject: Cannot do any order and control the maxOccurs.


Hi,
I sent this summary of a major limitation of XML
Schemas to my boss.  If anyone knows how to get
around it please tell me.

XML Schema Limitation:
1.  You cannot specify any order and have some, but
not all, of the elements' frequency greater than one.
    a.  What I mean by this is that presently our
multivalued fields are represented by specifying the
element any many times as needed.
         Example:
         <App>
             <cn>Word</cn>
             <Extension>doc</Extension>
             <Extension>txt</Extension>
         </App>
         In this example, if we wanted to say that
<cn> can only appear once and <sw-AppExtension> can
appear as many times as needed, then we would have to
put a restriction on the order the elements come in. 
Meaning, we couldn't put <Extension> before <cn>.
 
         To almost get around this limitation (if we
want any order and control the frequency) we have 2
options:
         1)  We would have to declare <Extension> as
an XML Schema list type.  The problem with this list
type is that the delimiter is a space, so they don't
recommend using a list for strings.
         Example:
         <Extension>doc txt</Extension>
         As you can see one of our values for another
field might have a space in it.  We could use our own
delimiter, but then we wouldn't be following the
standard.
 
         2)  We could specify any order and any
frequency for all items (choice maxOccurs="unbounded")
which means they could do this:
              <swApp>
                 <cn>Word</cn>
                 <cn>Microsoft Word</cn>
                
<sw-AppExtension>doc</sw-AppExtension>
                
<sw-AppExtension>txt</sw-AppExtension>
             </swApp>
 
             This really isn't what we want because cn
should only be there once (it is not a multivalued
field).

If anyone knows of anyway to get around this please
let me know.

Thanks,
Chris


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to