[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] XML Schema complex type constraint question
- From: Hermann Stamm-Wilbrandt <STAMMW@de.ibm.com>
- To: Hermann Stamm-Wilbrandt <STAMMW@de.ibm.com>
- Date: Fri, 10 Oct 2014 17:00:33 +0200
Oops, found 2.1.1 sample in 2004 posting on xmlschema-dev:
http://lists.w3.org/Archives/Public/xmlschema-dev/2004Nov/0110.html
("{http://space}ProductNameType")
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
From: Hermann Stamm-Wilbrandt/Germany/IBM@IBMDE
To: "XML Developers List" <xml-dev@lists.xml.org>
Date: 10/10/2014 03:41 PM
Subject: [xml-dev] 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
_______________________________________________________________________
XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.
[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]