Commit Graph

43 Commits

Author SHA1 Message Date
Davide Brunato 6942be8ac9 Optimize qname_to_prefixed() and get_namespace() helpers
- use_empty optional argument added to qname_to_prefixed()
2019-10-23 09:47:49 +02:00
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 22fdcc9a5a Fix etree_to_string to avoid registering reserved prefixes 2019-10-12 11:23:31 +02:00
Davide Brunato d89a597c82 Update documentation and fix PEP8 errors 2019-10-11 13:44:10 +02:00
Davide Brunato b7b6fef418 Base modules refactoring for fix ElementTree import 2019-10-07 15:31:18 +02:00
Davide Brunato a4b1d8896b Add 'restriction' attribute to XsdGroup for simplify dynamic EDC checks 2019-09-13 07:32:57 +02:00
Davide Brunato 6c47e49971 Fixing W3C XSD 1.1 schema tests
- Add XSD 1.1 skip list in W3C test script
  - Regex: check unescaped double hyphens (--)
  - Check model extension allowed types
2019-08-23 08:48:02 +02:00
Davide Brunato 3db78707b1 Complete openContent and defaultOpenContent parsing 2019-07-12 18:22:11 +02:00
Davide Brunato 2de9756b73 Fix expected items on model checking
- Empty expected fixed in ModelVisitor.advance()
  - Better message for expected tags for XMLSchemaChildrenValidationError
2019-06-21 22:20:32 +02:00
Davide Brunato bed3888e5b Fix validator exceptions with lazy resource 2019-06-05 08:15:04 +02:00
Davide Brunato 001f47924f Clean import and include error handling 2019-05-03 23:04:51 +02:00
Davide Brunato e6fd152843 Fix simple restriction checking 2019-04-11 07:09:19 +02:00
Davide Brunato e6d8b4cf55 Add XMLSchemaModelError exception 2019-03-29 16:22:16 +01:00
Davide Brunato 63c95dbc18 Add schema_url and origin_url properties to XMLSchemaValidatorError
- New properties used in parse errors representation
2019-03-06 11:12:21 +01:00
Davide Brunato ff78b9a44a Add 'msg' property to XMLSchemaValidatorError 2019-03-05 17:53:49 +01:00
Davide Brunato bbbbbe0873 Add override tag and XMLSchema11._include_schema() 2019-02-08 23:28:49 +01:00
Davide Brunato 7cca3d386d Fix validator exceptions classes 2019-01-26 11:03:15 +01:00
Davide Brunato cec34eeea0 Refactor of etree.py module
- Remove SafeXMLParserError and use ElementTree.ParseError
  - PyElementTree safe APIs errors are re-raised as C mod ParseError
  - Simplify ElementTree API and XMLResource class
2019-01-25 17:55:32 +01:00
Davide Brunato 9d6b88baae Change copyright years info 2019-01-20 16:56:10 +01:00
Davide Brunato d07e5c9a0d Fix for issue #88
- The issue was related to recursive complexType
  - Added a test to XsdGroup.iter_components to skip iteration
    of inherited items of an XsdComplexType instance
  - XsdGroup.built refactored, adding also the same test added to
    XsdGroup.iter_components
2018-10-29 07:24:10 +01:00
Davide Brunato bd90cacc7a QNames refactoring
- Moved all QNames to the same module
  - Create module helpers.py that includes XSD parse utils and name
    manipulation helper functions
2018-10-08 23:47:18 +02:00
Davide Brunato a34033ee2f Improve matching and use unicode_literals
- Added names attribute for XSD declarations
2018-09-15 22:18:16 +02:00
Davide Brunato 8e8f53ecb9 Update validator exceptions and test modules
- Add test_helpers.py module
  - Refactoring of chidren validation error's reason build
  - Removed unused qname helper functions (split_*)
  - Fix case collection missing files (logger.error message)
2018-09-15 16:56:43 +02:00
Davide Brunato cc25612a08 Fix validation errors representation
- Added particle argument to XMLSchemaChildrenValidationError;
  - Removed iter_decode_children methods from XsdGroup, XsdElement
    and XsdAnyElement classes.
2018-09-12 07:14:32 +02:00
Davide Brunato fe3078a3c7 Implement a new iter_decode method based on XsdModelVisitor 2018-09-08 11:19:51 +02:00
Davide Brunato 96cb4b57af Refactoring of error and to etree_tostring serialization
- Added namespaces argument to etree_tostring helper method.
  - Refactored validator error string representation.
  - Moved namespaces argument at last position for methods validate
    and iter_errors of class ValidationMixin.
  - Fixed document validate API and added tests for it
2018-08-27 15:43:19 +02:00
Davide Brunato 88e8a191d3 Other fixes for XsdModelVisitor and added schema_elem property to components 2018-08-24 07:20:08 +02:00
Davide Brunato 12b50298cc Complete encoding using model visitor class
- Children validation errors use a dummy element for reproducing the
    instance (more clear and better printable than JSON conventions)
  - Fix for 'all' models visiting
  - Rewritten etree_tostring() helper function for implementing the
    reindentation of the serialized XML
  - Added tests for models validation
2018-08-22 07:06:03 +02:00
Davide Brunato 857ee59cbe Added new helper methods for validation errors generation 2018-08-11 13:09:12 +02:00
Davide Brunato 175d3a1ab3 Extension of validator error classes done
- Now all errors include reference to XML resource and namespaces
  - Added namespaces argument to iter_errors() and validate() methods
  - Modified etree_iterpath to map namespaces and to add position
    predicates for repeated tags
  - Added namespaces, relative and add_position to etree_getpath
  - XsdValidator._parse_error() renamed to parse_error
  - ValidationMixin._validation_error() renamed to validation_error
  - Added test for errors completeness
2018-08-07 21:45:30 +02:00
Davide Brunato cdb6e2035d Code cleaning for XSD attributes
- Substituting XMLSchemaValidationError with _validation_error()
2018-08-06 23:26:15 +02:00
Davide Brunato 1474bccc92 Complete validation error classes extension 2018-08-06 22:53:48 +02:00
Davide Brunato 73cbd12f58 Added source attribute to XMLSchemaValidatorError 2018-08-06 16:48:29 +02:00
Davide Brunato 85151fcdc4 Added XMLSchemaValidatorError exception 2018-08-06 14:53:35 +02:00
Davide Brunato 07e5409616 Unify parse errors management 2018-08-06 11:32:09 +02:00
Davide Brunato 80c200f651 Add is_etree_element helper function
- This is a more safer test for Element objects for this package, because it
    also checks that the argument is not an instance of ElementPathMixin class
  - Add tests for fetch_schema_locations and load_xml_resource functions
2018-07-13 22:40:35 +02:00
Davide Brunato 3e6ce18ae4 Rewritten includes and imports for schema initialization
- Now a warning message is sent to the logger for include or
    for namespace import errors
  - Add XMLSchemaImportWarning and XMLSchemaIncludeWarning
  - Add warning attribute to schemas for collecting the message
    strings about include and import warnings
  - URIDict class removed (faulty with empty fragment #)
  - Added --warning and --timeout to test factory arguments
  - Removed --network from test factory arguments
2018-07-07 11:25:00 +02:00
Davide Brunato 1f07570834 Include source line into validation error messages
- If instance element of an error has a sourceline attribute
    display it on message.
  - Fix XsdElement._validation_error() to fill with the instance
    element if the error.elem is None.
2018-05-18 07:18:16 +02:00
Davide Brunato db1821a229 Put a patch for issue #35 in XsdGroup.iter_decode
- Related to residual emptiable content parsing of a top level
    group of a sequence
  - The patch code have to be moved to XsdGroup
  - Added a case for the issue

Some refactoring to XsdComponent: target_namespace, namespace and maps
are trasformed to @property functions.

Update documentation for pass doctests.
2018-01-20 06:11:43 +01:00
Davide Brunato c31fc194d8 Update schema class
- now parses also WSDL-SOAP original schema

  xmlschema/schema.py module:
    - more XSD compiliant imports and includes
    - added 'locations' argument to schema class init
    - improved schema location hints
    - revised documentation with more autodoc
    - schema class code cleaning
    - schema class creation is now based on a metaclass

  xmlschema/resources.py module:
    - added iter_schema_location_hints
    - fetch_schema code cleaned
    - removed old functions for retrieving XSI attributes

  xmlschema/exceptions.py module:
    - added index and expected attributes to XMLSchemaChildrenValidationError

  Updated docs using more autodocs

  Added requirements-dev.txt
2018-01-12 16:38:25 +01:00
Davide Brunato 43d0c77eee Fixed bug #34, updated copyright information. 2018-01-08 09:15:09 +01:00
Davide Brunato 418b3898d3 Validators updated
- Added _validation_error() method to XsdComponent base class.
    This method unifies all error checks and continue on the basis
    of the validation mode value.
  - Now validator's iter_decode(), iter_decode_children() and
    iter_encode() methods raise at first error when strict validation
    mode is selected.
2018-01-07 18:59:39 +01:00
Davide Brunato 094caa146e Some refactoring and bug fixes.
- Fixed issues #28 and #29
  - Code cleaning
  - Created a "validators" subpackage that includes schemas, xsd global
    maps and all the XSD components
  - Added "prefixed_name" property to XsdComponent class
2017-12-15 15:56:07 +01:00