Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSD Schema Authoring Question

Reply
Thread Tools

XSD Schema Authoring Question

 
 
Mike
Guest
Posts: n/a
 
      02-05-2008
I'd like to create a complex type that behaves like an <xs:all> but
has unbounded cardinality of its children. Or, another way to say it,
is I'd like an <xs:sequence> that doesn't really care about order.
For instance:

<foo>
<bar/>
<bar/>
<baz/>
<bar/>
</foo>

and

<foo>
<baz/>
</foo>

would both match

<xs:element name="foo">
<xs:complexType>
<xs:all>
<xs:element name="bar" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="baz" />
</xs:all>
</xs:complexType>
</xs:element>

except of course for the fact that maxOccurs can only be "1" in
<xs:all>.

Do you see what I mean? I want to specify that these particular
children elements can occur in their parent, in no particular (known
to the schema) order, each with their own possibly unbounded
cardinality. No other types of children can occur, and I want a
validating parser to keep track of the cardinality of the children to
ensure they're not happening too (in)frequently.

There must be a way to do this, I just can't figure out how. Any help
much appreciated!

Mike
 
Reply With Quote
 
 
 
 
P. Lepin
Guest
Posts: n/a
 
      02-05-2008

Mike wrote:
> <foo>
> <bar/>
> <bar/>
> <baz/>
> <bar/>
> </foo>
>
> and
>
> <foo>
> <baz/>
> </foo>
>
> would both match
>
> <xs:element name="foo">
> <xs:complexType>
> <xs:all>
> <xs:element name="bar" minOccurs="0" maxOccurs="unbounded" />
> <xs:element name="baz" />
> </xs:all>
> </xs:complexType>
> </xs:element>
>
> except of course for the fact that maxOccurs can only be "1" in
> <xs:all>.
>
> Do you see what I mean? I want to specify that these particular
> children elements can occur in their parent, in no particular (known
> to the schema) order, each with their own possibly unbounded
> cardinality. No other types of children can occur, and I want a
> validating parser to keep track of the cardinality of the children to
> ensure they're not happening too (in)frequently.


I believe this isn't possible. Either specify a strict ordering of elements
(xs:sequence), or allow any number of applicable elements (xs:choice with
minOccurs/maxOccurs). Check semantics on the application-side if necessary,
and/or use a more powerful schema definition language. W3C's XML Schema
Definition Language was not designed to define arbitrarily complex
grammars.

> There must be a way to do this, I just can't figure out how. Any help
> much appreciated!


The fact that you want to do something doesn't yet mean it's possible.

--
Presented in Brain Control where available.
 
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
Validation with XSD using XML::LibXML::Schema, and XML::Validator::Schema huntingseasonson@gmail.com Perl Misc 5 11-29-2006 12:37 PM
Type cast indicated in xsd schema? (newbie question) christian.eickhoff@nt.uni-saarland.de XML 0 11-20-2006 08:02 AM
Validation of XSD (XML Schema) against XSD Rushi XML 1 12-09-2005 08:12 AM
XML schema - Make xsd include another xsd stiank81 XML 4 06-26-2005 05:11 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM



Advertisments