Re: Redefinition of group, who's correct

Michael Kay <[email protected]> Wed, 20 Mar 2013 21:59:12 +0000
Newsgroups gmane.text.xml.schema.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------010509040306030209000908
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit


It has to be said that xs:redefine is underspecified in some respects. 
However, for this case the rule is fairly clear:

Attribute group definitions and model group definitions must be 
supersets or subsets of their original definitions, either by including 
exactly one reference to themselves or by containing only (possibly 
restricted) components which appear in a corresponding way in their 
<redefine>d selves.

In other words, a redefined group must be either a restriction or an 
extension of the original. Or more precisely,

6 Within the [children], for each <group> the appropriate case among the 
following must be true:
6.1 If it has a <group> among its contents at some level the ·actual 
value· of whose ref [attribute] is the same as the ·actual value· of its 
own name attribute plus target namespace, then all of the following must 
be true:
6.1.1 It must have exactly one such group.
6.1.2 The ·actual value· of both that group's minOccurs and maxOccurs 
[attribute] must be 1 (or ·absent·).
6.2 If it has no such self-reference, then all of the following must be 
true:
6.2.1 The ·actual value· of its own name attribute plus target namespace 
must successfully ·resolve· to a model group definition in I.
6.2.2 The {model group} of the model group definition which corresponds 
to it per XML Representation of Model Group Definition Schema Components 
(§3.7.2) must be a ·valid restriction· of the {model group} of that 
model group definition in I, as defined in Particle Valid (Restriction) 
(§3.9.6).

This example clearly satisfies 6.1.

In my view, however, it is unwise to rely heavily on xs:redefine. 
Schemas that use xs:redefine don't compose well with each other: when 
you combine a schema that uses xs:redefine with another schema, the 
meaning of the definitions in the second schema can change as a 
side-effect.

Michael Kay
Saxonica


On 20/03/2013 20:34, [email protected] wrote:
> XMLSpy has a totally different interpretation of the schema 1.0 spec 
> concerning xs:redefine.
> See e.g 
> http://lists.w3.org/Archives/Public/xmlschema-dev/2004Dec/0048.html
> I have a had contact with Altova (the developers of XMLSpy) several 
> times and their answer is something like "we are right and the rest of 
> the world is wrong ..."
> The CDISC standards make a lot usage of xs:redefine, reason the issue 
> came up in our working group.
> So we wrote a "white paper" for the FDA stating that XMLSpy is not a 
> suitable tool for validating CDISC-XML documents.
> With best regards,
> Jozef Aerts
> XML4Pharma
>
> > Michael Kay <[email protected]> hat am 20. März 2013 um 20:05 
> geschrieben:
> >
> >
> > Since oXygen allows a choice of schema processors, it would be 
> useful to
> > say which one you selected (or to try more than one).
> >
> > It would also be useful to tell us what XMLSpy says is wrong - what is
> > the error message?
> >
> > Michael Kay
> > Saxonica
> >
> > On 20/03/2013 17:56, Pierre Attar wrote:
> > > Hi,
> > >
> > > I have a problem using group redefinitions and validating both with
> > > XMLSpy (who complains) and Oxygen (who validates).
> > > My question : who is correct ? Where a I wrong ?
> > >
> > > Note: my schema are a lot more complex but I try to make a sample 
> (non
> > > realistic) in order to isolate my question.
> > >
> > > Here is the situation :
> > >
> > > base.xsd declares a group called essai :
> > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns="http://modeles.fr/modeles/reference"
> > > targetNamespace="http://modeles.fr/modeles/reference"
> > > elementFormDefault="qualified" attributeFormDefault="unqualified">
> > > <xs:element name="ENTER_NAME_OF_ROOT_ELEMENT_HERE">
> > > <xs:annotation>
> > > <xs:documentation>Comment describing your root
> > > element</xs:documentation>
> > > </xs:annotation>
> > > </xs:element>
> > > <xs:group name="essai">
> > > <xs:choice/>
> > > </xs:group>
> > > </xs:schema>
> > >
> > >
> > > other.xsd only includes base.xsd
> > >
> > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns="http://modeles.fr/modeles/reference"
> > > targetNamespace="http://modeles.fr/modeles/reference"
> > > elementFormDefault="qualified" attributeFormDefault="unqualified">
> > > <xs:include schemaLocation="base.xsd"/>
> > > </xs:schema>
> > >
> > >
> > > And now, redefine .xsd both redefine base.xsd and includes other.xsd
> > >
> > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns="http://modeles.fr/modeles/reference"
> > > targetNamespace="http://modeles.fr/modeles/reference"
> > > elementFormDefault="qualified" attributeFormDefault="unqualified">
> > > <xs:redefine schemaLocation="base.xsd">
> > > <xs:group name="essai">
> > > <xs:choice>
> > > <xs:group ref="essai"/>
> > > <xs:element name="test"/>
> > > </xs:choice>
> > > </xs:group>
> > > </xs:redefine>
> > > <xs:include schemaLocation="other.xsd"/>
> > > </xs:schema>
> > >
> > >
> > > At this time, XML spy complains but not oxygen 14.2. If I remove the
> > > include, no problem found.
> > >
> > > Any ideas ?
> > >
> > > Pierre
> > >
> > >
> > >
> >
> >


--------------010509040306030209000908
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    It has to be said that xs:redefine is underspecified in some
    respects. However, for this case the rule is fairly clear:<br>
    <br>
    Attribute group definitions and model group definitions must be
    supersets or subsets of their original definitions, either by
    including exactly one reference to themselves or by containing only
    (possibly restricted) components which appear in a corresponding way
    in their &lt;redefine&gt;d selves.<br>
    <br>
    In other words, a redefined group must be either a restriction or an
    extension of the original. Or more precisely,<br>
    <br>
    6 Within the [children], for each &lt;group&gt; the appropriate case
    among the following must be true:<br>
    6.1 If it has a &lt;group&gt; among its contents at some level the
    ·actual value· of whose ref [attribute] is the same as the ·actual
    value· of its own name attribute plus target namespace, then all of
    the following must be true:<br>
    6.1.1 It must have exactly one such group.<br>
    6.1.2 The ·actual value· of both that group's minOccurs and
    maxOccurs [attribute] must be 1 (or ·absent·).<br>
    6.2 If it has no such self-reference, then all of the following must
    be true:<br>
    6.2.1 The ·actual value· of its own name attribute plus target
    namespace must successfully ·resolve· to a model group definition in
    I.<br>
    6.2.2 The {model group} of the model group definition which
    corresponds to it per XML Representation of Model Group Definition
    Schema Components (§3.7.2) must be a ·valid restriction· of the
    {model group} of that model group definition in I, as defined in
    Particle Valid (Restriction) (§3.9.6).<br>
    <br>
    This example clearly satisfies 6.1.<br>
    <br>
    In my view, however, it is unwise to rely heavily on xs:redefine.
    Schemas that use xs:redefine don't compose well with each other:
    when you combine a schema that uses xs:redefine with another schema,
    the meaning of the definitions in the second schema can change as a
    side-effect. <br>
    <br>
    Michael Kay<br>
    Saxonica<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 20/03/2013 20:34,
      <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a> wrote:<br>
    </div>
    <blockquote
      cite="mid:[email protected]"
      type="cite">
      <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
      <div> XMLSpy has a totally different interpretation of the schema
        1.0 spec concerning xs:redefine. </div>
      <div> See e.g <a moz-do-not-send="true"
href="http://lists.w3.org/Archives/Public/xmlschema-dev/2004Dec/0048.html">http://lists.w3.org/Archives/Public/xmlschema-dev/2004Dec/0048.html</a>
      </div>
      <div>   </div>
      <div> I have a had contact with Altova (the developers of XMLSpy)
        several times and their answer is something like "we are right
        and the rest of the world is wrong ..." </div>
      <div> The CDISC standards make a lot usage of xs:redefine, reason
        the issue came up in our working group. <br>
        So we wrote a "white paper" for the FDA stating that XMLSpy is
        not a suitable tool for validating CDISC-XML documents. </div>
      <div>   </div>
      <div> With best regards, </div>
      <div>   </div>
      <div> Jozef Aerts </div>
      <div> XML4Pharma </div>
      <div>   </div>
      <div>   </div>
      <div> <br>
        &gt; Michael Kay <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a> hat am 20. März 2013
        um 20:05 geschrieben: <br>
        &gt; <br>
        &gt; <br>
        &gt; Since oXygen allows a choice of schema processors, it would
        be useful to <br>
        &gt; say which one you selected (or to try more than one). <br>
        &gt; <br>
        &gt; It would also be useful to tell us what XMLSpy says is
        wrong - what is <br>
        &gt; the error message? <br>
        &gt; <br>
        &gt; Michael Kay <br>
        &gt; Saxonica <br>
        &gt; <br>
        &gt; On 20/03/2013 17:56, Pierre Attar wrote: <br>
        &gt; &gt; Hi, <br>
        &gt; &gt; <br>
        &gt; &gt; I have a problem using group redefinitions and
        validating both with <br>
        &gt; &gt; XMLSpy (who complains) and Oxygen (who validates). <br>
        &gt; &gt; My question : who is correct ? Where a I wrong ? <br>
        &gt; &gt; <br>
        &gt; &gt; Note: my schema are a lot more complex but I try to
        make a sample (non <br>
        &gt; &gt; realistic) in order to isolate my question. <br>
        &gt; &gt; <br>
        &gt; &gt; Here is the situation : <br>
        &gt; &gt; <br>
        &gt; &gt; base.xsd declares a group called essai : <br>
        &gt; &gt; &lt;xs:schema
        xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> <br>
        &gt; &gt; xmlns=<a class="moz-txt-link-rfc2396E" href="http://modeles.fr/modeles/reference">"http://modeles.fr/modeles/reference"</a> <br>
        &gt; &gt; targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://modeles.fr/modeles/reference">"http://modeles.fr/modeles/reference"</a>
        <br>
        &gt; &gt; elementFormDefault="qualified"
        attributeFormDefault="unqualified"&gt; <br>
        &gt; &gt; &lt;xs:element
        name="ENTER_NAME_OF_ROOT_ELEMENT_HERE"&gt; <br>
        &gt; &gt; &lt;xs:annotation&gt; <br>
        &gt; &gt; &lt;xs:documentation&gt;Comment describing your root <br>
        &gt; &gt; element&lt;/xs:documentation&gt; <br>
        &gt; &gt; &lt;/xs:annotation&gt; <br>
        &gt; &gt; &lt;/xs:element&gt; <br>
        &gt; &gt; &lt;xs:group name="essai"&gt; <br>
        &gt; &gt; &lt;xs:choice/&gt; <br>
        &gt; &gt; &lt;/xs:group&gt; <br>
        &gt; &gt; &lt;/xs:schema&gt; <br>
        &gt; &gt; <br>
        &gt; &gt; <br>
        &gt; &gt; other.xsd only includes base.xsd <br>
        &gt; &gt; <br>
        &gt; &gt; &lt;xs:schema
        xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> <br>
        &gt; &gt; xmlns=<a class="moz-txt-link-rfc2396E" href="http://modeles.fr/modeles/reference">"http://modeles.fr/modeles/reference"</a> <br>
        &gt; &gt; targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://modeles.fr/modeles/reference">"http://modeles.fr/modeles/reference"</a>
        <br>
        &gt; &gt; elementFormDefault="qualified"
        attributeFormDefault="unqualified"&gt; <br>
        &gt; &gt; &lt;xs:include schemaLocation="base.xsd"/&gt; <br>
        &gt; &gt; &lt;/xs:schema&gt; <br>
        &gt; &gt; <br>
        &gt; &gt; <br>
        &gt; &gt; And now, redefine .xsd both redefine base.xsd and
        includes other.xsd <br>
        &gt; &gt; <br>
        &gt; &gt; &lt;xs:schema
        xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a> <br>
        &gt; &gt; xmlns=<a class="moz-txt-link-rfc2396E" href="http://modeles.fr/modeles/reference">"http://modeles.fr/modeles/reference"</a> <br>
        &gt; &gt; targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://modeles.fr/modeles/reference">"http://modeles.fr/modeles/reference"</a>
        <br>
        &gt; &gt; elementFormDefault="qualified"
        attributeFormDefault="unqualified"&gt; <br>
        &gt; &gt; &lt;xs:redefine schemaLocation="base.xsd"&gt; <br>
        &gt; &gt; &lt;xs:group name="essai"&gt; <br>
        &gt; &gt; &lt;xs:choice&gt; <br>
        &gt; &gt; &lt;xs:group ref="essai"/&gt; <br>
        &gt; &gt; &lt;xs:element name="test"/&gt; <br>
        &gt; &gt; &lt;/xs:choice&gt; <br>
        &gt; &gt; &lt;/xs:group&gt; <br>
        &gt; &gt; &lt;/xs:redefine&gt; <br>
        &gt; &gt; &lt;xs:include schemaLocation="other.xsd"/&gt; <br>
        &gt; &gt; &lt;/xs:schema&gt; <br>
        &gt; &gt; <br>
        &gt; &gt; <br>
        &gt; &gt; At this time, XML spy complains but not oxygen 14.2.
        If I remove the <br>
        &gt; &gt; include, no problem found. <br>
        &gt; &gt; <br>
        &gt; &gt; Any ideas ? <br>
        &gt; &gt; <br>
        &gt; &gt; Pierre <br>
        &gt; &gt; <br>
        &gt; &gt; <br>
        &gt; &gt; <br>
        &gt; <br>
        &gt; </div>
    </blockquote>
    <br>
  </body>
</html>

--------------010509040306030209000908--