1

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).

phoeller
  • 58
  • 1
  • 10
  • I have upvoted your question because you have explained a complex issue very clearly. However, I am not qualified to answer it - that will probably require somebody who is associated with the W3C XML Schema working group. – kimbert Jun 22 '20 at 16:34

1 Answers1

0

Found a partial answer...

(4) was resolved by removing an import of another schema document I wrote. I wanted to make restricting redefinitions of several targetNamespaces in multiple files and chain them together. I assume that how I did it was not a legal composition of schema documents and it resulted in some kind of circular dependency referencing(?). I re-created the document standalone and it works just the way I wrote it.

However, the main question shown in (3) still remains (see EDIT).

phoeller
  • 58
  • 1
  • 10