Schema: complexType restrictions

M

Moth

On my first night with schemas, things are not proceeding according to
expectations. Given three distinct complexType layouts:

<sequence> multiple elements in strict sequence
<choice> one element singled out from group of elements
<all> multiple elements in no particular order, each represented
only once

- how would you handle a typical xhtml setup with multiple elements
represented any number of times in no particular order:

<h>Heading</h>
<p>Paragraph</p>
<p>Paragraph</p>
<h>Heading</h>
<p>Paragraph</p>

The implied maxOccur of "1" on the <all> container has really thrown
me off! Thanks for any insight you may provide.
 
M

Martin Honnen

Moth said:
On my first night with schemas, things are not proceeding according to
expectations. Given three distinct complexType layouts:

<sequence> multiple elements in strict sequence
<choice> one element singled out from group of elements
<all> multiple elements in no particular order, each represented
only once

- how would you handle a typical xhtml setup with multiple elements
represented any number of times in no particular order:

<h>Heading</h>
<p>Paragraph</p>
<p>Paragraph</p>
<h>Heading</h>
<p>Paragraph</p>

The implied maxOccur of "1" on the <all> container has really thrown
me off! Thanks for any insight you may provide.

<h> is not a defined XHTML 1.0 tag but I assume you want <h1> there. As
for XHTML as a schema look at
http://www.w3.org/TR/xhtml-m12n-schema/
There you find

<xs:complexType name="body.type" mixed="true">
<xs:group ref="Block.mix" minOccurs="1" maxOccurs="unbounded"/>
<xs:attributeGroup ref="body.attlist"/>
</xs:complexType>

<xs:element name="body" type="body.type"/>

and then

<xs:group name="Block.mix">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="Heading.class"/>
<xs:group ref="List.class"/>
<xs:group ref="Block.class"/>
<xs:group ref="Misc.class"/>
</xs:choice>
</xs:group>
 
M

Moth

Martin said:
<h> is not a defined XHTML 1.0 tag but I assume you want <h1> there.

It is XHTML2!
<xs:complexType name="body.type" mixed="true">
<xs:group ref="Block.mix" minOccurs="1" maxOccurs="unbounded"/>
<xs:attributeGroup ref="body.attlist"/>
</xs:complexType>

<xs:element name="body" type="body.type"/>

and then

<xs:group name="Block.mix">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="Heading.class"/>
<xs:group ref="List.class"/>
<xs:group ref="Block.class"/>
<xs:group ref="Misc.class"/>
</xs:choice>
</xs:group>

Thanks alot, this looks very promising!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top