Menu

#171 Clarify and document validation process

PyXB 1.3.0
accepted
None
Content model
major
PyXB 1.1.5
defect
2013-09-18
2012-11-03
No

Validation when parsing a document is controlled by RequireValidWhenParsing and _ParsingRequiresValid. In this case, validation is explicit and post-construction before returning the value to the caller.

Validation when constructing from a DOM node is equivalent to parsing.

Validation when constructing an instance through a constructor call not using a DOM node is mixed. Keyword initializers are placed into the corresponding attribute and element with no validation; the content model is ignored. Positional arguments are interpreted as element content and processed using the content model. Optionally non-determinism is resolved when the positional arguments have been completed. The partially executed content model is left incomplete.

Setting an element field directly is optionally (via _PerformValidation) "validated" in the sense that the value may be converted to be compatible with the element binding type. Occurrence constraints are not validated.

Setting an attribute field directly is validated for required, prohibited, and fixed, and the type is coerced to the attribute type, but value constraints are not enforced.

Discussion

  • Peter A. Bigot

    Peter A. Bigot - 2012-11-03
    • status changed from new to accepted

    Schema constraints on simpleTypeDefinition instances are validated when the instances are constructed, so in a sense attributes (and certain elements) are validated immediately when set.

     
  • Peter A. Bigot

    Peter A. Bigot - 2012-11-04

    When using positional arguments to provide element content for an element that is abstract, the value will be stored but if it is not already of a type that is consistent with the substitution group validation will fail. This is because the constructing element does not know what elements are members of the substitution group, so cannot coerce the value.

     
  • Peter A. Bigot

    Peter A. Bigot - 2012-11-04

    Replying to pabigot:

    When using positional arguments to provide element content for an element that is abstract, the value will be stored but if it is not already of a type that is consistent with the substitution group validation will fail. This is because the constructing element does not know what elements are members of the substitution group, so cannot coerce the value.

    That it could be stored was a bug and has been fixed. Such use now raises an AAE as it should.

     
  • Peter A. Bigot

    Peter A. Bigot - 2012-11-08
    • milestone changed from PyXB 1.2.0 to PyXB 1.2.1
     
  • Peter A. Bigot

    Peter A. Bigot - 2012-12-17
    • milestone changed from PyXB 1.2.1 to PyXB 1.2.2
     
  • Peter A. Bigot

    Peter A. Bigot - 2013-04-17
    • milestone changed from PyXB 1.2.2 to PyXB 1.2.3
     
  • Peter A. Bigot

    Peter A. Bigot - 2013-09-18
    • milestone changed from PyXB 1.2.3 to PyXB 1.3.0
     
MongoDB Logo MongoDB