RE: Determining cardinality of a simple type

A lot depends on what you're after. It sounds suspiciously like you're
headed for co-occurrence constraints. But you might be ok with substitution
groups.

If you want your swingers element to contain exactly 4 and that they exactly
match your enumerations, there's no way you can establish and enforce that
in Schema. On the other hand, you could formulate a separate Schematron rule
that expressed both the cardinality constraints on swingers and any further
restriction (e.g., only one per enumeration value). Generating the
Schematron rules from the schema? How good are you at using XSLT to analyze
Schema files?

You might want to consider establishing bob, carol, ted, and alice as global
elements in the "swinger" substitution group and having swingers be
comprised of 4 abstract "swinger" elements. You still don't get around the
problem of counting the elements and establishing the cardinality
constraints, nor any added uniqueness constraints. I suppose that you could
achieve what you want by using a uniqueness constraint, but I'm pretty sure
that you couldn't achieve both the minimum and maximum cardinalities - just
the maximum. 

It sounds like you're treading around that difficult territory of trying to
get your schema to be extensible and self-constraining. That's way more than
can be achieved. And if you're able to get this little corner licked, I
strongly suspect that there are many other, harder problems that you must
solve. You'll end up either relying on some separate constraint facility to
impose your integrity checks, or even deferring your more sophisticated
model checking to your application(s). 

Did I get  it, or am I missing something big?

Mark



Mark Feblowitz                                   	
XML Architect
       [t]   617.715.7231                                     	
       [f]   617.495.0188
Frictionless Commerce Incorporated 	
       [e]  mfeblowitz@frictionless.com
       [w] http://www.frictionless.com
       [m] 400 Technology Square, 9th Floor
             Cambridge, MA 02139 
Open Applications Group Incorporated
       [e]  mfeblowitz@openapplications.org
       [w] http://www.openapplications.org 

 -----Original Message-----
From: 	Paul Erion [mailto:p_erion@yahoo.com] 
Sent:	Wednesday, July 24, 2002 3:04 PM
To:	xmlschema-dev@w3.org
Subject:	Determining cardinality of a simple type


Is it possible to derive the cardinality of a "simpleType" that I can
then apply to an element's minOccurs/maxOccurs attributes?

For example, the following simple type has a cardinality of 4 (I'm new
to schemas, so please feel free to correct me if I use any
schema-specific terms incorrectly)

  <xsd:simpleType  name="nameType">
    <xsd:restriction  base="xsd:string">
      <xsd:enumeration  value="bob" />
      <xsd:enumeration  value="carol" />
      <xsd:enumeration  value="ted" />
      <xsd:enumeration  value="alice" />
    </xsd:restriction>
  </xsd:simpleType>

and I would like to specify that the "swingers" element will have
exactly 4 "person" elements as children.

  <xsd:element  name="swingers">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="person" minOccurs="4" maxOccurs="4" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

but I'd like to somehow state that minOccurs/maxOccurs is equal to the
cardinality of "nameType" -- that is, without explicitly using '4'. 
This isn't a critical thing, but it would be nice if when I add another
value to "nameType", I don't have to remember to modify the
minOccurs/maxOccurs values.

Thanks,

:Paul

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

Received on Wednesday, 24 July 2002 16:59:55 UTC