W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2012

Re: Example of an identity constraint that is not applied to substitution elements?

From: Mukul Gandhi <gandhi.mukul@gmail.com>
Date: Tue, 19 Jun 2012 21:16:45 +0100
Message-ID: <CABuuzNNEAer9uLp0_4rsBJL3CRph070eUS+NMdfDaZnTgPC8iQ@mail.gmail.com>
To: "Costello, Roger L." <costello@mitre.org>
Cc: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hi Roger,
   Here's an example that illustrates this scenario,

XSD schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <xs:element name="X">
         <xs:complexType>
	      <xs:sequence>
		   <xs:element ref="Y" maxOccurs="unbounded"/>
	      </xs:sequence>
	 </xs:complexType>
   </xs:element>

   <xs:element name="Y" type="T1">
        <xs:key name="PK">
	     <xs:selector xpath="a"/>
             <xs:field xpath="."/>
	</xs:key>
   </xs:element>

   <xs:element name="S1" type="T1" substitutionGroup="Y"/>

   <xs:complexType name="T1">
       <xs:sequence>
	    <xs:element name="a" type="xs:string" maxOccurs="unbounded"/>
       </xs:sequence>
   </xs:complexType>

</xs:schema>

The above schema would cause following XML document to be assessed as
'invalid' (since the value "a1" occurs more than once within the first
"Y" element),

<X>
    <Y>
       <a>a1</a>
       <a>a1</a>
       <a>a3</a>
    </Y>
    <Y>
       <a>a1</a>
       <a>a2</a>
       <a>a3</a>
    </Y>
</X>

But the following XML document would be assessed as 'valid', when
validated by the same schema above,

<X>
    <S1>
        <a>a1</a>
        <a>a1</a>
        <a>a3</a>
    </S1>
    <Y>
       <a>a1</a>
       <a>a2</a>
       <a>a3</a>
    </Y>
</X>

(since now the element "S1" is substituted for first "Y", but identity
constraints of substitution group HEAD are not enforced)

On Mon, Jun 18, 2012 at 10:14 PM, Costello, Roger L. <costello@mitre.org> wrote:
> Hi Mukul,
>
> I agree with your analysis.
>
> In section 2.2.4.4 of the Structures specification it says:
>
>    ... elements substitutable for E are required to
>    have types derived from T, but are not required
>    to enforce the identity constraints ... of E.
>
> Is it possible to construct an element that has identity constraints and has substitutable elements, and the identity constraints are not enforced on the substitution elements?
>
> If not, what is the point of that statement in the specification?
>
> /Roger
>




-- 
Regards,
Mukul Gandhi
Received on Tuesday, 19 June 2012 20:17:34 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:20 UTC