I want to redefine/restrict a complex type from the Oasis XML DSig schema.
xmldsig-core-schema.xsd
<complexType name="TransformType" mixed="true">
<choice minOccurs="0" maxOccurs="unbounded">
<any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
<element name="XPath" type="string"/>
</choice>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
I only want to allow one explicit element type from an ##other
namespace.
xmldsig-restricted.xsd
(1) This does work:
<xs:redefine schemaLocation="xmldsig-core-schema.xsd">
<xs:complexType name="TransformType">
<xs:complexContent>
<xs:restriction base="ds:TransformType">
<xs:choice minOccurs="1" maxOccurs="1"> <!--diff-->
<xs:element name="XPath" type="xs:string"/>
<!--<xs:any namespace="##other" processContents="lax"/>-->
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
(2) This does also work:
<xs:redefine schemaLocation="xmldsig-core-schema.xsd">
<xs:complexType name="TransformType">
<xs:complexContent>
<xs:restriction base="ds:TransformType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<!--<xs:element name="XPath" type="xs:string"/>-->
<xs:any namespace="##other" processContents="lax"/>
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
(3) This does NOT work:
<xs:redefine schemaLocation="xmldsig-core-schema.xsd">
<xs:complexType name="TransformType">
<xs:complexContent>
<xs:restriction base="ds:TransformType">
<xs:choice minOccurs="1" maxOccurs="1"> <!--diff-->
<!--<xs:element name="XPath" type="xs:string"/>-->
<xs:any namespace="##other" processContents="lax"/>
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
Error:
cos-particle-restrict.2: Forbidden particle restriction: 'choice:all,sequence,elt'.
(4) This (the desired definition) does also NOT work:
<xs:redefine schemaLocation="xmldsig-core-schema.xsd">
<xs:complexType name="TransformType">
<xs:complexContent>
<xs:restriction base="ds:TransformType">
<xs:choice minOccurs="1" maxOccurs="1"> <!--diff-->
<!--<xs:element name="XPath" type="xs:string"/>-->
<!--<xs:any namespace="##other" processContents="lax"/>-->
<xs:element name="InclusiveNamespaces" type="ec:InclusiveNamespaces"/> <!--diff-->
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
Error:
rcase-RecurseLax.2: There is not a complete functional mapping between the particles.
(1) shows that the restriction of choice
is OK
(2) shows that the usage of only the any
type is OK
(3) shows that there must be a special behavior when any
and choice
are combined, maybe regarding the namespaces?
(4) looks like the given element is not a subset of the any
type (which is not true)
The behavior of (3) is also implied by the original schema which has these comments for choice
and sequence
:
<choice minOccurs="0" maxOccurs="unbounded">
<any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
</choice>
<sequence>
<any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) external namespace -->
</sequence>
So what does this mean and how has the restriction to be defined?
EDIT
(2)/(3) The restriction is also OK, when setting choice
to either minOccurs=0 maxOccurs=1
or minOccurs=1 maxOccurs=unbounded
. But why is "exactly one" not a valid restriction of "any number"? Still, when not using an any
type, we have (1).