W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2004

RE: Constraining a mixed type ?

From: <noah_mendelsohn@us.ibm.com>
Date: Sat, 17 Apr 2004 22:57:36 -0400
To: "Michael Kay" <mhk@mhk.me.uk>
Cc: "'Pierre Attar'" <attar@tireme.fr>, "'Bruno Chatel'" <bcha@chadocs.net>, xmlschema-dev@w3.org
Message-ID: <OF735ECF9E.8E7709D5-ON85256E79.004DF158@lotus.com>

Michael Kay writes:

> > I wonder if it is possible to define a constrain on a mixed 
> > content using XML Schemas. 
> 
> I don't think this is possible.
> 
> Michael Kay

Actually, a number of interesting constraints are possible.  The exact 
spec details are at [1] in the constraint named "Schema Component 
Constraint: Derivation Valid (Restriction, Complex)". 

Rather than explain this rigorously, I will try to give you the general 
spirit of the rules:

* The overall philosphy of validating mixed content is that when you see 
an instance like:

        123<X>abc</X>456<Y>def</Y>789

you ignore the character content and validate only the element content:

        <X>abc</X><Y>def</Y>

so if you have declared a sequence of X,Y this might well validate.

* Restriction of element content follows from this.  Let's imagine that 
your original model was actually (X,Y?).  From this you could derive a new 
mixed type allowing only the X which would validate:

        123<X>abc</X>456789

but not the original

        123<X>abc</X>456<Y>def</Y>789

* There is another twist.  If your base content model is like this (X?, 
Y?) then it's what the recommendation calls "emptiable", becaues all of 
its content is optional.  In that specific case you can not only derive a 
type with no element content, you can in fact derive a type with simple 
content.  Thusl, the restricted type could type the content as 
xsd:integer, for example, which would validate:

        123456789

I'm sure Henry will chime in if I've missed something, but I believe the 
above is how it works.

Noah

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

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------
Received on Saturday, 17 April 2004 23:00:09 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:11 UTC