Re: Deriving a simple type from a complex type

Simon,

> Is it possible to constrain the character content of a
> mixed complex type to be one of the built-in simple types?

If you had asked three days ago I would point you to
http://lists.w3.org/Archives/Public/xmlschema-dev/2001Jan/0127.html which I
guess is still relevant with the proposed recommendation released on the
16th of this month.  Nevertheless I looked through the new spec:

My first thought no, though I must admit I am little confused-- I found:

  "A mixed {content type} validates elements whose element [children] (i.e.
specifically ignoring
  other [children] such as character information items) conform to the
supplied content model." [1]

  "Schema Component Constraint: Derivation Valid (Extension)...
  1.4.2.2.2.1 Both {content type}s must be mixed or both must be
element-only." [2]

I picked out these references which seem to agree with my initial thought.
However section 5 of
"Schema Component Constraint: Derivation Valid (Restriction, Complex)" [2]
tripped me up a little. Based on this section I would guess that you could
have a complexType which if "emptiable" would work if you could apply both
the restriction derivation from the complexType and the simpleType-- which I
can't find explicit wording for but I don't think is allowed.  It seems that
you can reduce it to simpleContent:

 <xs:complexType name="fooType" mixed="true">
  <xs:element name="baz" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
 </xs:complexType>
 <xs:complexType name="barType">
  <xs:simpleContent>
   <xs:restriction base="fooType"/>
  </xs:simpleContent>
 </xs:complexType>

because it is emptiable-- but I am not sure how you would (or if you could)
apply a simpleType thereafter.  So I am sticking with my no...

Good Luck,
Jeff Rafter

[1] http://www.w3.org/TR/xmlschema-1/#Complex_Type_Definition_details
[2] http://www.w3.org/TR/xmlschema-1/#coss-ct

Received on Monday, 19 March 2001 03:12:04 UTC