- From: <Noah_Mendelsohn@lotus.com>
- Date: Wed, 4 Oct 2000 10:58:04 -0400
- To: "Joe Melton" <jmelton@cardinalsolutions.com>
- Cc: www-xml-schema-comments@w3.org
Joe Melton asks:
>> Is it legal for a parent node to have multiple child nodes with the
>> same reference type? Here is an example of what I am referring to.
>> CreditSurchargeDt and SecondaryCD occur twice in this sequence.
1) <group name="PCCREDITSURCHARGE">
2) <sequence minOccurs="0" maxOccurs="1">
3) <element ref="CreditSurchargeDt" minOccurs="0" maxOccurs="1"/>
4) <element ref="SecondaryCd" minOccurs="0" maxOccurs="1"/>
5) <element ref="CreditSurchargeDt" minOccurs="0" maxOccurs="1"/>
6) <element ref="DiscountSurchargeFactorCd"/>
7) <element ref="Amount" minOccurs="0" maxOccurs="1"/>
8) <element ref="IterationNumber" minOccurs="0" maxOccurs="1"/>
9) <element ref="SecondaryCd" minOccurs="0" maxOccurs="1"/>
10) </sequence>
11) </group>
The general answer is yes, such multiple occurrences are legal in a
sequence. You may be looking for an <all> group, in which duplicates are
not legal, sequence is not relavent to validation (though is still
significant in the XML infoset), and optionality (minOccurs="0"
maxOccurs="1") is allowed.
The detailed and perhaps surprising analysis of your example, if I've
eyeballed it right is that SecondaryCD is legal, CreditSurchargeDt is not.
Why? We have a constraint that content models support unambigous
attribution during validation. To keep the examples terse, I'll use DTD
syntax:
legal: A,A
legal: A,A?
not legal: A?, A?
not legal A?, B?, A?
Why? Consider the instance document:
<A/>
In the legal content models you always know that the <A/> matches the
first A. In the illegal ones it's ambiguous; the single <A/> could match
either of the optional A?'s. Your CreditSurchargeDt seems isomorphic to
the last illegal model, since both its occurrences are optional and
everything in between is optional.
legal: A?, B, A?
because if A comes before the required B, it matches the first one,
otherwise the second. I think this is the reason your SecondaryCD is OK,
because you have a non-optional DiscountSurchargeFactorCd (#6) between the
two references (#4 and #9).
I hope I have this right, and I hope this helps.
------------------------------------------------------------------------
Noah Mendelsohn Voice: 1-617-693-4036
Lotus Development Corp. Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------------
Received on Wednesday, 4 October 2000 11:02:29 UTC