[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XML Schema complex type constraint question

  • From: Hermann Stamm-Wilbrandt <STAMMW@de.ibm.com>
  • To: "XML Developers List" <xml-dev@lists.xml.org>
  • Date: Fri, 10 Oct 2014 15:41:21 +0200

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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.