Skip to content

Potentially incorrect default value for maxOccurs in XSD #395

@nerg4l

Description

@nerg4l

In EBMLSchema.xsd the default value for maxOccurs is defined as 1.

The specification says the following about maxOccurs:

[...] If the maxOccurs attribute is not present, then there is no upper bound for the permitted number of occurrences of this EBML Element within its Parent Element or within the EBML Document, depending on whether or not the EBMLParentPath of the EBML Element is empty.

The semantic meaning of maxOccurs within an EBML Schema is analogous to the meaning of maxOccurs within an XML Schema; when it is not present, it's similar to xml:maxOccurs="unbounded" in an XML Schema.

In my opinion the XSD definition could be misleading. I propose to define maxOccurs as a union type or define 0 as a special value.

In case maxOccurs is defined as a union type:

  • Schema change
      <xs:attribute name="maxOccurs" default="unbounded">
        <xs:simpleType>
          <xs:union> 
            <xs:simpleType> 
              <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
              </xs:restriction>
            </xs:simpleType> 
            <xs:simpleType> 
              <xs:restriction base="xs:string"> 
                <xs:enumeration value="unbounded"/> 
              </xs:restriction> 
            </xs:simpleType> 
          </xs:union>
        </xs:simpleType>
      </xs:attribute>
    
  • This change would let maxOccurs behave almost the same as the attribute with the same name in XML Schema.

In case 0 is defined as a special value:

  • Schema change
      <xs:attribute name="maxOccurs" default="0">
        <xs:simpleType>
          <xs:restriction base="xs:integer">
            <xs:minInclusive value="0"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    
  • The zero value has to be defined as a special value in the specification. From a logical perspective this could make sense because limiting the maximal occurrence to 0 is an invalid constraint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions