Re: Supporting incremental-definition of a type?

Mukul Gandhi <[email protected]> Tue, 19 Jun 2012 06:43:56 +0100
Newsgroups gmane.text.xml.schema.devel
Message-ID <CABuuzNPaj0g6opnnnpuJh6v8vz4cRfRMzACtJbamVxSzLEaGxw@mail.gmail.com>
On Mon, Jun 18, 2012 at 10:47 PM, Michael Kay <[email protected]> wrote:
> So if I have a type A and I want to define a type B that restricts A with an assertion, the simplest way is
> to define B as a "vacuous extension" of A. Non-obvious, but very useful.

Here's a simple schema example I came up with,

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

   <xs:element name="X">
          <xs:complexType>
	       <xs:complexContent>
		      <xs:extension base="T1">
			   <xs:sequence>
			        <xs:element name="y" type="xs:integer"/>
			   </xs:sequence>
			   <xs:assert test="x gt y"/>
		     </xs:extension>
		</xs:complexContent>
	  </xs:complexType>
   </xs:element>

   <xs:complexType name="T1">
         <xs:sequence>
	      <xs:element name="x" type="xs:integer"/>
	 </xs:sequence>
   </xs:complexType>

</xs:schema>

An assertion being a co-occurrence constraint, in this case for
example enforces a relational constraint between two sibling elements
(and to me, this doesn't produce a restriction effect between complex
types, but rather is an orthogonal constraint on top of extension).

Assertions (for example, during XSD type extensions) must be used
carefully though. If the intention is to only produce an XSD particle
extension affect (like what XSD 1.0 did), then using assertion
improperly in such cases may inject a restriction behavior.



-- 
Regards,
Mukul Gandhi