Q:

Recursive XML Schema Type Validation fails when nested

I have two XML Schemas: computation.xsd, math.xsd, as follows:
computation.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://computation.eqec.org/schema"
xmlns:tns="http://computation.eqec.org/schema" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" blockDefault="#all">

<xs:element name="Computation" type="tns:ComputationType"
    abstract="true">
</xs:element>

<xs:element name="Set" type="tns:ComputationType"
    substitutionGroup="tns:Computation" />

<!-- <xs:complexType name="SetType"> <xs:complexContent> <xs:restriction 
    base="tns:ComputationType"> <xs:attribute name="class" use="required"> <xs:simpleType> 
    <xs:restriction base="xs:string"> <xs:enumeration value="org.eqec.computation.Set" 
    /> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:restriction> </xs:complexContent> 
    </xs:complexType> -->

<xs:complexType name="ComputationType">
    <xs:complexContent>
        <xs:extension base="tns:ComputationContentType">
            <xs:sequence>
                <xs:element name="Configuration" type="tns:ConfigurationType"
                    minOccurs="0" maxOccurs="1" />

            </xs:sequence>
            <!-- <xs:attribute name="class" type="xs:string" use="required" /> -->

        </xs:extension>
    </xs:complexContent>

</xs:complexType>

<xs:complexType name="ConfigurationType">
    <xs:sequence>
        <xs:element name="SupportedTypes">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="Type" minOccurs="0" maxOccurs="unbounded">
                        <xs:complexType>
                            <xs:attribute name="validityrange" type="xs:string"
                                use="required" />
                        </xs:complexType>
                    </xs:element>

                </xs:sequence>
                <xs:attribute name="complex" type="xs:boolean" />
            </xs:complexType>
        </xs:element>
        <xs:element name="OtherConfigs">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="Config1" minOccurs="0" maxOccurs="unbounded">
                        <xs:complexType>
                            <xs:attribute name="name" type="xs:string" use="required" />
                        </xs:complexType>
                    </xs:element>
                    <xs:element name="Config2" type="xs:string" minOccurs="1"
                        maxOccurs="1" />
                </xs:sequence>
                <xs:attribute name="name" type="xs:string" use="required" />
            </xs:complexType>
        </xs:element>
    </xs:sequence>
    <xs:attribute name="minArgs" type="xs:integer" use="required" />
    <xs:attribute name="maxArgs" type="xs:integer" use="required" />
    <xs:attribute name="repetative" type="xs:boolean" />
</xs:complexType>

<xs:complexType abstract="true" name="ComponentType">
    <xs:attribute name="name" type="xs:string" />
    <xs:attribute name="externalize" type="xs:boolean" />
    <xs:anyAttribute namespace="##any" processContents="lax" />
</xs:complexType>

<xs:complexType name="ValueType">

    <xs:complexContent>
        <xs:extension base="tns:ComponentType">
            <xs:group ref="tns:ObjectTypeChoice" />
            <xs:attribute name="ref" type="xs:string" />
        </xs:extension>
    </xs:complexContent>

</xs:complexType>

<xs:group name="ObjectTypeChoice">
    <xs:choice>
        <xs:element name="decimal" type="xs:decimal" minOccurs="0"
            maxOccurs="1" />
        <xs:element name="string" type="xs:string" minOccurs="0"
            maxOccurs="1" />
        <xs:element name="boolean" type="xs:boolean" minOccurs="0"
            maxOccurs="1" />
        <xs:element name="integer" type="xs:integer" minOccurs="0"
            maxOccurs="1" />
        <xs:element name="datetime" type="xs:dateTime" minOccurs="0"
            maxOccurs="1" />
        <xs:element name="base64binary" type="xs:base64Binary"
            minOccurs="0" maxOccurs="1" />
        <xs:any namespace="##other" processContents="lax" minOccurs="0"
            maxOccurs="1" />

    </xs:choice>
</xs:group>

<xs:complexType name="ComputationContentType" abstract="true">
    <xs:complexContent>
        <xs:extension base="tns:ComponentType">
            <xs:sequence>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element ref="tns:Computation" />

                    <xs:element name="Value" type="tns:ValueType" />
                    <xs:any namespace="##other" processContents="lax" />
                </xs:choice>
            </xs:sequence>
            <xs:attribute name="class" type="xs:string" use="required" />

        </xs:extension>
    </xs:complexContent>
</xs:complexType>
</xs:schema>

math.xsd:
<xs:schema targetNamespace="http://computation.eqec.org/schema/math"
xmlns:tns="http://computation.eqec.org/schema/math" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:op="http://computation.eqec.org/schema" elementFormDefault="qualified"
blockDefault="#all">
<xs:import namespace="http://computation.eqec.org/schema"
    schemaLocation="computation.xsd" />

<xs:element name="Add" type="op:ComputationType"
    substitutionGroup="op:Computation" />

<xs:element name="Subtract" type="op:ComputationType"
    substitutionGroup="op:Computation" />
<xs:element name="Multiply" type="op:ComputationType"
    substitutionGroup="op:Computation" />
<xs:element name="Devide" type="op:ComputationType"
    substitutionGroup="op:Computation" />

<xs:element name="Sqrt" type="op:ComputationType"
    substitutionGroup="op:Computation" />
<xs:element name="Square" type="op:ComputationType"
    substitutionGroup="op:Computation" />

</xs:schema>

If I validate the following XML instance
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Set xmlns="http://computation.eqec.org/schema" xmlns:ns2="http://computation.eqec.org/schema/math" class="org.eqec.computation.Set" name="valuesAndComputationCollection" externalize="false">
<Value name="three">
    <decimal>3.00000</decimal>
</Value>
<Value name="four">
    <decimal>4</decimal>
</Value>
<Set class="org.eqec.computation.Set" name="ComputationWithRefs" externalize="false">
    <Value ref="three"/>
    <Value ref="four"/>
</Set>
<ns2:Add class="org.eqec.computation.math.Add" name="threePlusFour" externalize="true">
    <Value name="tenPointOne">
        <decimal>10.1</decimal>
    </Value>
    <Value name="hundred">
        <decimal>100</decimal>
    </Value>
</ns2:Add>
<Value ref="threePlusFour"/>
</Set>

I get this Error:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'Set'. One of '{"http://
   computation.eqec.org/schema":Computation, "http://computation.eqec.org/schema":Value, WC[##other:"http://
   computation.eqec.org/schema"], "http://computation.eqec.org/schema":Configuration}' is expected.

However, when I validate the offending fragment only the validation succeeds without errors:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Set xmlns="http://computation.eqec.org/schema" xmlns:ns2="http://computation.eqec.org/schema/math" class="org.eqec.computation.Set" name="myset" externalize="true">
<Value ref="three"/>
<Value ref="four"/>
</Set>

How can I change my schemas, such that the long XML instance from above validates without error?

A:

I just found the solution: I had to remove the attribute blockDefault="#all" from the schema definitions, as it is defined as 

Optional. Specifies the default value of the block attribute on element and complexType elements in the target namespace. The block attribute prevents a complex type (or element) that has a specified type of derivation from being used in place of this complex type. This value can contain #all or a list that is a subset of extension, restriction, or substitution:

extension - prevents complex types derived by extension
restriction - prevents complex types derived by restriction
substitution - prevents substitution of elements
#all - prevents all derived complex types

