Commit Graph

161 Commits

Author SHA1 Message Date
Davide Brunato 249e555659 Improve content model encoding
- Update iter_collapsed_content() to perform a model conforming
    reordering.
2019-10-13 21:42:41 +02:00
Davide Brunato a79a5583ae Fix datetime types validation on encoding
- Add is_datetime() to XSD types classes
2019-10-11 13:26:17 +02:00
Davide Brunato 997c59c837 Fix locations argument usage
- Used to import other namespaces explicitly (as disposed by
    "xsi:schemaLocation" in an XML instance).
  - It's not propagated to included/imported schemas anymore.
2019-10-10 20:35:45 +02:00
Davide Brunato 75664150e6 Improve XPath bindings
- Extend ElementPathMixin with instance _xpath_parser
  - Add xpath_tokens dictionary to schema objects
  - Fix serialization removing xpath_tokens classes
2019-10-09 15:03:50 +02:00
Davide Brunato 690a172502 Add logging for schema initialization and building
- Add loglevel argument to schema init
  - Fallback location (for XLink and XHTML) moved at the
    end of import tentatives (full fix for issue #137)
  - Fix TestGlobalMaps after the remove of XLink from base schemas
2019-10-08 11:30:36 +02:00
Davide Brunato 433970cf72 Add FALLBACK_LOCATIONS to schema class
- XLink namespace removed from base schemas
  - Fallback locations dictionary added for XLink
    and XHTML namespaces
  - Fix for issue #137 (local mode)
2019-10-07 22:18:08 +02:00
Davide Brunato b7b6fef418 Base modules refactoring for fix ElementTree import 2019-10-07 15:31:18 +02:00
Davide Brunato 844ddec3ba Fix assertions
- Add custom parser for assertion facet (without position() and last()).
  - Move parser initialization to XsdAssert.parse_xpath_test() because
    all the components must be defined.
2019-10-01 06:44:31 +02:00
Davide Brunato b6c6e2ac8f Change get_context() in document module
- Now the optional schema argument is a fallbak in case
    the schema path is not found into XML resource.
2019-09-23 17:29:08 +02:00
Davide Brunato 8d56d128ca Add XSD 1.1 inheritable check on XML instance validation
- Add substitutes to dynamic checks
2019-09-23 09:26:31 +02:00
Davide Brunato b1663c5550 Add root_type property to XsdType
- Atomic's property primitive_type transformed to attribute
  - Optimized base_type assignement
2019-09-21 10:47:11 +02:00
Davide Brunato 0480e4bee8 Add is_override() to XsdComponent for XSD 1.1 schemas
- Change is_global() from property to function
2019-09-19 06:37:42 +02:00
Davide Brunato 07070ad714 Fix W3C instance tests
- Add iter_substitutes() to Xsd11Element to fix upa.xsd/upa2.xsd
    tests with instances. Now for XsdElement the abstract substitutes
    are simply ignored by iter_substitutes().
2019-09-11 18:43:13 +02:00
Davide Brunato c35f86d681 Add IDREF checking and fix ID collecting
- ID are not counted for XML document root
  - IDREF checked with adding a key with 0 value if missing
    (TODO: Add a validation error instance or a reference)
2019-09-06 11:37:30 +02:00
Davide Brunato c530fda102 Fix openContent validation ad regex character group parsing
- Put interleave mode after model match for precedence
  - Fix regex parsing of character group ending with '-'
  - Fix complexType mixed content extension
2019-09-06 06:42:34 +02:00
Davide Brunato 747036aad4 Fix for issue #127 and other W3C XML tests
- Added data_value() method to XsdElement and XsdAttribute()
  - Rename identity constraints dictionaries to 'identities'
  - Fix XSD 1.1 wilcards
2019-08-25 22:51:00 +02:00
Davide Brunato 9e58e99e01 Add XSD 1.1 support and XSD components API to documentation 2019-08-19 13:52:30 +02:00
Davide Brunato 7a0dbf9afc Fix other XSD 1.1 parsing errors for wilcards 2019-08-17 09:36:24 +02:00
Davide Brunato 3ff9e8b010 Add openContent override to include notQName
- Replace list_builtins.xsd with xsd11-extra.xsd
2019-08-10 23:59:38 +02:00
Davide Brunato f8ad4d975c Code cleaning: remove get_xml_bool_attribute() helper function 2019-08-09 12:45:11 +02:00
Davide Brunato 52d1e1bb8e Close XSD 1.1 development
- Still some W3C and local tests to be fixed
  - Fix min/max facets derivation (decode with primitive type)
2019-08-05 17:57:34 +02:00
Davide Brunato 4661c1e0bf Complete versioning filter for XSD 1.1+
- etree_pruning() renamed to prune_etree
  - version_check() now is used only as selector for prune_etree()
    at schema initialization
2019-08-03 05:50:18 +02:00
Davide Brunato 3d38e87d2e Clean iter_decode and iter_encode arguments for XSD components 2019-08-02 16:19:55 +02:00
Davide Brunato 3f99689197 Add etree_pruning(elem, selector) helper function 2019-08-01 23:56:13 +02:00
Davide Brunato f2a30baf32 Fix XSD 1.1 bugs with W3C XML Schema suite 2019-08-01 17:16:12 +02:00
Davide Brunato df5c454b24 Add minimal schema for versioning namespace
- Added XMLSchemaNamespaceError for namespace related errors
  - version_check moved to schema class
  - resolve_qname() now raises KeyError if namespace prefix is not found
  - resolve_qname() now raises XMLSchemaNamespaceError if a namespace
    is mapped with a prefix but is not loaded by an import
2019-08-01 07:03:03 +02:00
Davide Brunato 6e90de7b4c Add Version Control namespace attributes
- Added xsd_version property to XSD components
  - Add version_check() helper to XsdValidator base class
2019-07-31 14:19:02 +02:00
Davide Brunato d4bb951a45 Improve schema checks
- Checked and improved 'built' properties for XSD components:
      * Simple types, attributes and attribute group are now built
        withoug cheching on base types.
      * Don't check global subcomponents: the scope of built is to
        assure that local parts are built.
  - Split global maps checks from build phase:
      * XsdGlobals._check_schema substituted by check() method with
        two opional arguments. The new methos is useful also to check
        global maps also after schema building.
  - Added validator=None argument to parse_error() method
2019-07-30 14:52:51 +02:00
Davide Brunato 3d33424541 Refactor and clean reference and name attributes parsing
- Add an helper method _parse_reference()
  - Removed ref property, replaced by attribute
2019-07-29 16:01:48 +02:00
Davide Brunato 035be87572 Complete XSD 1.1 wildcards (xs:any and xs:anyAttribute) 2019-07-23 16:02:17 +02:00
Davide Brunato 35089f9354 Add tests for XSD any wildcards
- Update docs with XSD 1.1 validator support
  - Fix: XsdAnyElement substituted with BUILDERS.any_element_class
    in shared 1.0/1.1 code
2019-07-13 09:47:59 +02:00
Davide Brunato 3db78707b1 Complete openContent and defaultOpenContent parsing 2019-07-12 18:22:11 +02:00
Davide Brunato cb3754f503 Transform meta-schema validation errors to parse errors
- In XMLSchema.__init__() the errors generated by check_schema()
    are now raised or transformed to parse errors
  - Only parse errors are generated during schema building
  - More compact errors that omit meta-schema parts
2019-07-12 11:21:35 +02:00
Davide Brunato 87cc74fc44 Added unordered and collapsed encoding modes
- Keep UnorderedConverter class as the default converter for
    encoding unordered data
  - Added 'unordered=False' option to iter_encode's arguments
  - Added iter_unordered_content() and iter_collapsed_content()
    to ModelVisitor class
2019-07-11 09:43:12 +02:00
Davide Brunato 7d20e8eff1 Add tests for meta-schema and add XMLSchema11 to package base
- Build meta-schema when is used for validation/decode/encode
    or the builtin-types() accessor is used
  - Add clear() method to XMLSchema base class
2019-06-27 10:48:25 +02:00
Davide Brunato bdf09fa181 Memory optimizations
- Meta schema lazy build: reduce memory usage for meta-schema if
    only one schema class is used between XMLSchema10 and XMLSchema11
  - Improve import_package() in check_memory.py
2019-06-26 15:51:16 +02:00
Davide Brunato 281a426ec4 Code optimization on parse helpers
- Remove iter_xsd_components() and has_hsd_components() helpers
    replaced by filter() and any() calls
2019-06-26 07:27:18 +02:00
Davide Brunato 0018e38d85 Add experimental full lazy validation
- Full lazy validation for XMLSchema.validate() and iter_errors(),
    passing lazy=True and no path.
2019-06-19 10:06:01 +02:00
Davide Brunato 061d72c5c6 Update decode/encode methods for schemas
- Split decode()/encode() for components and for schemas
  - Removed to_dict and to_etree for XSD components
  - Updated fetch_schema_locations() to build XMLResource instance
2019-06-18 17:20:13 +02:00
Davide Brunato 788135c4c5 Update document APIs
- Added arguments for building XMLResource from xml_document
2019-06-13 16:22:48 +02:00
Davide Brunato fe521dcaf4 Uniformating iter_decode/iter_encode arguments for XSD components
- Move optional argument 'converter' to keyword arguments
  - Adjust filler parameter usage in XsdAttributeGroup.iter_decode
2019-06-08 09:43:15 +02:00
Davide Brunato 318f5391ec Add optional arguments to XMLSchema.iter_decode()
- Added 'filler' callback function
  - Added 'fill_missing' boolean option
2019-06-07 19:41:19 +02:00
Davide Brunato 5d04d7e68a Implementing lazy validation
- Added XMLResource.iterfind() for XPath iteration of a resource;
  - Validator API refactored: remove path argument from iter_errors()
    of components, add validate, is_valid, iter_errors to XMLSchema
    class with additional arguments path and schema_path.
  - Fix test case patterns.xml (now find also duplicated IDs)
2019-06-05 07:01:53 +02:00
Davide Brunato 3d4c5f3fab Fix issue #107 2019-05-13 11:57:23 +02:00
Davide Brunato 001f47924f Clean import and include error handling 2019-05-03 23:04:51 +02:00
Davide Brunato 9d984e3648 Change schema includes list to dictionary 2019-05-01 10:02:04 +02:00
Davide Brunato 22dbd7256c Add XsdList.is_derived() and XSD 1.0 invalid rule to choice restriction 2019-04-29 22:43:41 +02:00
Davide Brunato b36472bd6d Fix tests for a new release
- W3C test script cleaned
  - Fix attribute wildcard extension: new method extend_namespace()
  - Generate an error if schema has the attribute targetNamespace=''
  - Fix complexType redefinition checks
  - Fix UPA violation checking
2019-04-29 11:44:15 +02:00
Davide Brunato c4385f4559 Fixes for bad schemas checks 2019-04-27 19:41:26 +02:00
Davide Brunato 36fda82d10 Remove schema source error re-raising 2019-04-24 19:37:22 +02:00