[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to use groups with mixed content models

  • From: Jeni Tennison <mail@j...>
  • To: Ben Ryan <b_ryan@c...>
  • Date: Wed, 04 Jul 2001 10:09:04 +0100

xsd group
Hi Ben,

> I am trying to use the following declarations to give me a content
> model that would be expressed as <!ELEMENT title
> (#PCDATA|emph|note|target|xref)*> in an XML DTD but I would like to
> use element groups to get the same benefits as parameter entities.

This does work (at least XSV), as long as you make one important
change: move the minOccurs and maxOccurs attributes from the xs:choice
in the model group definition onto the group reference. In other
words, your XML Schema should contain:

<xsd:element name="title">
  <xsd:annotation>
    <xsd:documentation>a descriptive title</xsd:documentation>
  </xsd:annotation>
  <xsd:complexType mixed="true">
    <!-- minOccurs and maxOccurs on model group reference -->
    <xsd:group ref="text-model" minOccurs="0" maxOccurs="unbounded" />
  </xsd:complexType>
</xsd:element>

<xsd:group name="text-model">
  <xsd:annotation>
    <xsd:documentation>the group of elements that are used inside a text
     or paragraph element</xsd:documentation>
  </xsd:annotation>
  <!-- minOccurs and maxOccurs removed from model group -->
  <xsd:choice>
    <xsd:element ref="emph"/>
    <xsd:element ref="note"/>
    <xsd:element ref="target"/>
    <xsd:element ref="xref"/>
    <xsd:any namespace="##other"/>
  </xsd:choice>
</xsd:group>

The why is a little clearer if you think about element declarations
vs. elements as particles. How many times an element is repeated (its
minOccurs and maxOccurs) isn't relevant on the *declaration*, it's
only relevant on the *particle*, when the element is referenced in the
model group.

In the same way, the model group definition doesn't declare the number
of times the model group occurs in another model group.  It's the
*reference* to that model group that holds that information.

Basically, don't put minOccurs or maxOccurs on xs:choice, xs:sequence
or xs:all if they occur as a child of xs:group - it will have no
effect. Instead, place those attributes on the model group reference.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.