Subject: | xsd:all will not allow minOccurs="0" elements |
group element <xsd:all> is not allowing minOccurs="0" elements unless they have alphabetical precedence.
Example:
<xsd:element name=test type="Test">
<xsd:complexType name="Test">
<xsd:all>
<xsd:element name="aString" type="xsd:string"/>
<xsd:element name="bString" type="xsd:string" minOccurs="0"/>
</xsd:all>
</xsd:complexType>
The following xml validates:
<test>
<aString>foobar</aString>
</test>
However this xml will fail:
<test>
<aString>foobar</aString>
<bString>foobar</bString>
</test>
Transposing minOccurs on the two elements:
<xsd:complexType name="Test">
<xsd:all>
<xsd:element name="aString" type="xsd:string" minOccurs="0"/>
<xsd:element name="bString" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
Causes both to validate successfully.
The attached patch to XML::Validator::Schema::ModelNode.pm fixes this.
253c253
< return $self->SUPER::_combine_final_parts([sort @$parts]);
---
> return $self->SUPER::_combine_final_parts([sort sort_parts @$parts]);
258c258
< return $self->SUPER::_combine_running_parts([sort @$parts]);
---
> return $self->SUPER::_combine_running_parts([sort sort_parts @$parts]);
277a278,283
> sub sort_parts {
> my( $a_element ) = $a =~ /<(.*?)\\>/;
> my( $b_element ) = $b =~ /<(.*?)\\>/;
> $a_element cmp $b_element;
> }
>