Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: why is it not possible to define a simple type as an extension in the range of values of another simple type (newbie question)

From: "Michael Kay" <mike@--------.--->
To: "'jorma kala'" <jjkk73@-----.--->, <xmlschema-dev@--.--->
Date: 7/14/2008 10:14:00 AM
The idea of type derivation is that derived types are substitutable for
their base types, so any assumptions that the document recipient makes based
on knowledge of the base type will not be invalidated if a derived type is
used. In that context, one might ask why derivation by extension is allowed
at all. The answer is that it only allows addition of extra child elements
at the end of the contents, and document recipients are not supposed to make
assumptions that such extra elements will not be there. One can question
whether extension should be allowed at all, but if it is allowed, it
certainly needs to be limited in what it can do.
 
Michael Kay
http://www.saxonica.com/


  _____  

From: xmlschema-dev-request@w... [mailto:xmlschema-dev-request@w...] On
Behalf Of jorma kala
Sent: 13 July 2008 12:19
To: xmlschema-dev@w...
Subject: why is it not possible to define a simple type as an extension in
the range of values of another simple type (newbie question)


I'm quite new to xml schemas.
I do not really understand why if it is possible to define a simple type as
a restriction on the range of values of another simple type, like this for
instance:

  <xsd:simpleType name="type1">
    <xsd:restriction base="xsd:integer">
      <xsd:minInclusive value="0"/>
      <xsd:maxInclusive value="100"/>
    </xsd:restriction>
  </xsd:simpleType>




  <xsd:simpleType name="type2">
    <xsd:restriction base="type1">
      <xsd:minInclusive value="10"/>
      <xsd:maxInclusive value="20"/>
    </xsd:restriction>
  </xsd:simpleType>

the reciprocal operation of defining a simple type as an extension on the
range of values of  another simple type is an error (at least I get an error
with the apache parser):

  <xsd:simpleType name="type1">
    <xsd:restriction base="xsd:integer">
      <xsd:minInclusive value="0"/>
      <xsd:maxInclusive value="100"/>
    </xsd:restriction>
  </xsd:simpleType>




  <xsd:simpleType name="type2">
    <xsd:extension base="type1">
      <xsd:minInclusive value="-100"/>
      <xsd:maxInclusive value="200"/>
    </xsd:extension >
  </xsd:simpleType>

thanks a lot.

jorma k





transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent