XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
XML Schema complex type constraint question

XML Schema spec
section 3.4.3 Constraints on XML Representations of Complex Type
Definitions
http://www.w3.org/TR/xmlschema-1/#d0e7923

does specify in section 2.1
2 If the <simpleContent> alternative is chosen, all of the following must
be true:
2.1 The type definition ·resolved· to by the ·actual value· of the base
[attribute] must be one of the following:
2.1.1 a complex type definition whose {content type} is a simple type
definition;
2.1.2 only if the <restriction> alternative is also chosen, a complex type
definition whose {content type} is mixed and a particle which is
·emptiable·, as defined in Particle Emptiable (§3.9.6);
2.1.3 only if the <extension> alternative is also chosen, a simple type
definition.

I created simple sample Schemata for 2.1.2 and 2.1.3 which work fine with
xmllint, see below.
I was unable to create a Schema sample for 2.1.1.
Can somebody provide a 2.1.1 sample Schema?


$ xmllint --schema 2.1.2.xsd 11.xml
<?xml version="1.0"?>
<str>abbbbbbbbbb</str>
11.xml:1: element str: Schemas validity error : Element 'str':
'abbbbbbbbbb' is not a valid value of the local union type.
11.xml fails to validate
$
$ xmllint --schema 2.1.3.xsd 11.xml
<?xml version="1.0"?>
<str>abbbbbbbbbb</str>
11.xml:1: element str: Schemas validity error : Element 'str': [facet
'maxLength'] The value has a length of '11'; this exceeds the allowed
maximum length of '10'.
11.xml:1: element str: Schemas validity error : Element 'str':
'abbbbbbbbbb' is not a valid value of the atomic type 'str10e'.
11.xml fails to validate
$
$
$ cat 2.1.2.xsd
<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>
  <xsd:simpleType name="str10d">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value="10"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:complexType name="myType">
    <xsd:simpleContent>
      <!-- 2.1.2 base complex type (mixed, emptiable) -->
      <xsd:restriction base="xsd:anyType">
        <xsd:simpleType>
          <xsd:union memberTypes="str10d"/>
        </xsd:simpleType>
      </xsd:restriction>
    </xsd:simpleContent>
  </xsd:complexType>

  <xsd:element name="str" type="myType"/>

</xsd:schema>
$
$
$ cat 2.1.3.xsd
<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>
  <xsd:simpleType name="str10e">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value="10"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:complexType name="myComplexType">
    <xsd:simpleContent>
      <!-- 2.1.3 base simple type -->
      <xsd:extension base="str10e"/>
    </xsd:simpleContent>
  </xsd:complexType>

  <xsd:element name="str" type="myComplexType"/>

</xsd:schema>
$


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Level 3 support for XML Compiler team and Fixpack team lead
WebSphere DataPower SOA Appliances
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
https://twitter.com/HermannSW/
http://stamm-wilbrandt.de/GraphvizFiddle/
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS