Skip to content

Use xs:all instead of xs:sequence when element is not an array? #8

Open
@reepoi

Description

@reepoi

Using xs:all instead of xs:sequence improves the error messages of the PVCollada XML doc validator. xs:sequence and xs:all allow us to define XMLSchema element definitions with multiple fields, but they differ by how many times a field is allowed to appear and what order fields can appear in:

  • xs:sequence:
    • Using minOccurs and maxOccurs, fields can appear at least zero times.
    • The order of an element's fields in an XML document must match the order they appear in the XML schema's element definition.
  • xs:all:
    • Fields can only appear at most once.
    • The order of an element's fields is not enforced.

Here is their XMLSchema specification.

Element definitions that do not represent arrays of elements should use xs:all instead of xs:sequence. For example, the project element has fields that appear at most once (i.e., none of them have the attribute maxOccurs="unbounded"), so project can use xs:all. Making this change improves the error messages of the validator. When defining project with xs:sequence, the validator only reports the next missing field; however, when defining project with xs:all, the validator reports all the missing fields.

On the other hand, here is an observation that suggests xs:all should not be used -- xs:all is never used by the COLLADA schema.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions