RE: Is this valid schema??

I believe that is correct.  In general, you might have to define <PART> to
include both options.  So if it can have either an <A> or a <B> child,
define it to have A|B, and it works pretty well, but XML Schema 1.0 has no
mechanism for specifying co-occurrence constraints, so the hard case is
where it can look like:
<PART type="A"><A></PART> or <PART type="B"><B></PART> and the content
model depends on the attribute.  If these two kinds of <PART> elements
occur in different locations in your content model, you can still define
them locally.  But when they occur in the same place, you can't completely
specify that with XML Schema 1.0:
<RESULT><PART type="A"><A></PART><PART type="B"><B></PART></RESULT>

I think that the best you can do is defining <PART> to have an attribute
that can be either "A" or "B" and content that can be either <A> or <B>.
You can still use <unique> to make sure that each is only used once if
that's important to you.  But you allow cases like this:
<RESULT><PART type="A"><B></PART><PART type="B"><A></PART></RESULT>

Really, this is pretty good.  It seems like they're thinking of supporting
the increased functionality in the next version of Schemas.

Morris



Ayalew Kassahun <A.Kassahun@InfoRay.NL>@w3.org on 03/22/2001 07:09:05 AM

Sent by:  xmlschema-dev-request@w3.org


To:   xmlschema-dev@w3.org
cc:   Morris Matsa/Somers/IBM@IBMUS
Subject:  RE: Is this valid schema??



This solution works with simple cases like this but doesn't work if PART
has
child elements of different types?


> -----Original Message-----
> From: Morris Matsa [mailto:mmatsa@us.ibm.com]
> Sent: Tuesday, March 20, 2001 6:11 PM
> To: Ayalew Kassahun
> Cc: xmlschema-dev@w3.org; ht@cogsci.ed.ac.uk
> Subject: RE: Is this valid schema??
>
>
>
>
> The two <PART> elements can not have different types.  What I
> think you can
> do is specify the value of the PART element's NAME attribute to be an
> enumeration of "HEADER" and "CONTENT" so that those are the
> only allowed
> values, and then use a <unique> element (in the schema) to
> make sure that
> each only appears once in the <result> element.  Finally,
> your schema just
> says that a <result> must have two <part> elements, and each
> must have a
> unique attribute for the NAME attribute, which only has two
> possibilities.
>
> As far as I can tell, the only difference between this and
> your ideal is
> that HEADER and CONTENT can appear in either order.  If you
> want them in
> only one order, you can't do that with Schemas yet.  Just document it.
> Sorry.
>
> Morris
>
>
> Ayalew Kassahun <A.Kassahun@InfoRay.NL>@w3.org on 03/20/2001
> 11:42:18 AM
>
> Sent by:  xmlschema-dev-request@w3.org
>
>
> To:   xmlschema-dev@w3.org
> cc:   ht@cogsci.ed.ac.uk
> Subject:  RE: Is this valid schema??
>
>
>
> But that is exactly what I want to have (ok to same effect), how do I
> specify that?
> What I mean is I want to have
>   <RESPONSE>
>     <RESULT>
>      <PART NAME="HEADER">
>      <PART NAME="CONTENT">
>      <EXTRA>
>     </RESULT>
>   </RESPONSE>
>
> whereby the PART's (of which i have a long list) should
> always have the
> given attribute and attribute-value (fixed) and each occur only once.
>
> thanks in advance for any suggestions,
> ayalew

Received on Thursday, 22 March 2001 13:43:23 UTC