W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2001

RE: Substitution Groups and NonDeterminism

From: Kanaskie, Kurt A (Kurt) <kkanaskie@lucent.com>
Date: Fri, 7 Dec 2001 16:28:46 -0500 (EST)
Message-ID: <2E12619580C0D1118C6400805F9F4C950C53C040@nj7460exch001u.ho.lucent.com>
To: "Xmlschema-Dev (E-mail)" <xmlschema-dev@w3.org>

Yes this appears to be a shortcoming on the use of substitution groups.
Substitution groups are a generalization pattern and a generalization
generally :) does not apply to all special cases. Your example is a case in
point, you're trying to define a baseline content model that allows any
Partner from the group, but later requires the ShipToPartner. This creates
the ambiguous content model where ShipToPartner is optional in the group,
but required later. Although this model technically works, an XML instance
still validates, it is bad design. A better approach would be to put the
required ShipToPartner before the optional Partner group. I realize this may
not be possible in the case when the containing element is extended, since
Schema extensions only get tacked on the end.

Another approach which doesn't use substitution groups, is to list all of
the possible Partners (SoldToPartner, ShipFromPartner, etc) as optional (in
a choice group if only one is allowed) in the original design. Then to make
one of the optional partners required use the Schema restriction or redesign
mechanism. Of course this may introduce other issues and side effects.

Kurt Kanaskie
Lucent Technologies
(610) 778-1069

 -----Original Message-----
From: 	Mark Feblowitz [mailto:mfeblowitz@frictionless.com] 
Sent:	Friday, December 07, 2001 3:42 PM
To:	Xmlschema-Dev (E-mail)
Subject:	Substitution Groups and NonDeterminism

I believe I've encountered a problem with using Substitution Groups in a
particular way and wanted to verify that my understanding is correct:

I'd like to have a Substitution Group containing things of type Partner, and
to reference the abstract head in an element content definition:

<xs:element name="Partner" type="Partner" abstract="true"/>
<xs:element name="ShipToPartner" type="Partner"
<xs:element name="ShipFromPartner" type="Partner"
<xs:element name="BillToPartner" type="Partner"

<xs:element name="TaxWitholdingExempt" type="TaxWitholdingExempt"
<xs:element ref="Partner" maxOccurs="unbounded"/>
<xs:element name="AttachmentReference" type="AttachmentReference"

I later would like to extend the element that references the Partner element
and append a ShipToPartner element. 

<xs:element name="TaxWitholdingExempt" type="TaxWitholdingExempt"
<xs:element ref="Partner" maxOccurs="unbounded"/>
<xs:element name="AttachmentReference" type="AttachmentReference"
<xs:element ref="ShipToPartner"/>

This appears to create a nondeterminism because a ShipToPartner could match
either the general reference in the Substitution Group or the specific one
at the end (past the generic reference). 

Am I correct that, if I have a Substitution Group as element content that I
cannot place any of its members as succeeding siblings without triggering a
nondeterminism? Is there a way around this (that doesn't force the
succeeding sibling down into some further nested content)?

Mark Feblowitz                                   [t] 617.715.7231
Frictionless Commerce Incorporated     [f] 617.495.0188 
XML Architect                                     [e]
400 Technology Square, 9th Floor 
Cambridge, MA 02139 
Received on Saturday, 8 December 2001 15:34:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:56 UTC