Commit Graph

44 Commits

Author SHA1 Message Date
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 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 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 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 9d6b88baae Change copyright years info 2019-01-20 16:56:10 +01:00
Davide Brunato fd5b6c9230 Fix for issue #96 (import deprecation warning) 2018-12-23 17:48:24 +01:00
Davide Brunato c790838d13 Move XSD builtin QNames to qnames.py module 2018-10-08 15:32:50 +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 c79f70b3c4 Rename XsdComponent.match to XsdComponent.is_matching
- Add a new match() method that returns the matching component
2018-09-09 11:57:08 +02:00
Davide Brunato d72c16499b Fixes for handling of the default namespace and the XPath default namespace
- XMLResource.get_namespaces(): consider local root when adding
    another default namespace
  - Fix for XPath default namespace handling in ElementPathMixin
2018-09-02 17:00:11 +02:00
Davide Brunato f26f7307c5 Update docs to release
- Added ElementPathMixin with autoclass
2018-07-26 17:47:00 +02:00
Davide Brunato ce97d02638 XPath API cleaning
- Moved all ElementTree/XPath iter methods to ElementPathMixin
  - Moved XsdElement.match() method to XsdComponent
  - Added attribute qualified=True to XsdComponent
  - Optimized safe iteration methods (collecting only local elements)
2018-07-26 13:43:47 +02:00
Davide Brunato 6eebcc3515 Implement safe iteration methods
- Safe iteration iter method for XsdElement
  - Safe iteration methods for XPath (ElementPathContext class)
2018-07-26 11:15:29 +02:00
Davide Brunato 5c1214e950 Improving the iteration of schema elements and groups 2018-07-25 15:57:17 +02:00
Davide Brunato 4a811e3a99 Update ElementPathMixin
- Schema text property transformed to a get_text() to avoid ElementPathMixin
    override (the text property should be always None for schema components).
  - Add tail and get() to ElementPathMixin.
  - ElementPathMixin now is derived from collections.Sequence
  - XMLSchemaMeta now is derived from abc.ABCMeta
  - iter() and iterchildren(): name optional argument changed to tag
  - iter() rewritten for XMLSchema and XsdElement
2018-07-24 16:30:05 +02:00
Davide Brunato 4903848a4b Fix for issues #52 and #54
- Add a test for #54 in test_schemas.py
2018-04-03 21:44:06 +02:00
Davide Brunato fa796d2dcf Complete xpath module substitution, improve testing
- With elementpath-1.0.4 pass all tests
  - Check version alignment with test_package.py
2018-03-27 19:47:56 +02:00
Davide Brunato 14c4fbb61d Add elementpath to package requirements
- Changed XPath selectors for XSD key/unique/keyref constraints
  - Removed old code from xpath.py (only a class and an helper function
    have left in)
2018-03-27 11:02:14 +02:00
Davide Brunato cef2fa22ee Some bugfix
- Fix for issue #41, workaround for issue #44
  - Fix for built property for schema class
  - Fix for final attribute usage for complexType
2018-02-15 21:15:47 +01:00
Davide Brunato 95928bf5c2 Stop on developing XPath into xmlschema package
- The XPath code will be splitted to another package for an
    independent support and usage;
  - The new lib for XPath will be added as dependency.
2018-02-14 07:09:52 +01:00
Davide Brunato 73672773de Decoupling XPath from XsdComponent API (XSD element and attribute matching) 2018-02-04 09:18:43 +01:00
Davide Brunato 3c13777602 Fixing the name format of elements and attributes
- Local elements and attributes with form == 'unqualified' now
    have an unqualified name.
  - Attribute groups include both qualified and unqualified lookups
    for unqualified attributes.
2018-02-04 08:42:17 +01:00
Davide Brunato b4fb413caf Fix XPath default namespace for XSD 1.0
- For XSD 1.0 in an XPath expression the default namespace have to be
    mapped to no namespace (need to use a prefix for targetNamespace)
  - Due to this two test about XPath fail for XSD 1.0
2018-02-02 06:43:24 +01:00
Davide Brunato e92c42154f Start to add XSD 1.1 features
- Added xpathDefaultNamespace attribute parser method
  - Added validation='strict' argument to XsdBaseComponent
  - Moved _parse and _parse_error methods to XsdBaseComponent
  - XPathMixin renamed to ElementPathMixin
2018-01-27 16:44:27 +01:00
Davide Brunato ef0ec177f1 Divide XPath code from XSD constraints code
Module to constraints.py:

  - XPathSelector renamed to XsdSelector
  - Created a XsdFieldSelector subclass for parsing xs:field definitions
  - Added an XsdSelectorXPathParser created by xpath builder function

Module xpath.py:

  - Created 2 full lists for XPath1 and XPath2 (to complete)
  - Created the XPathSelector class
2018-01-27 00:01:11 +01:00
Davide Brunato e82e5be147 Create XPathParser classes with a metaclass
- XPathParser class renamed to XPathParserBase
  - Created XPathParserMeta class
2018-01-26 07:31:36 +01:00
Davide Brunato 203fc68643 Starting to write an XPath 2.0 parser
Modified the class XPathParser of module xpath.py:

  - Removed the parameter token_table, not used and not necessary;
  - Added a 'version' argument that can be 1 or 2 (default);
  - Added an 'exclude' argument to remove some tokens for a limited
    parsing, required in some cases.
2018-01-25 15:47:53 +01:00
Davide Brunato 491c83e272 Modify tests for extra schemas
- Argument --extra substituted with -s/--skip-extra that doesn't
    change the old behaviour
  - Fixed a typo for XsdSimpleType.check_facets() (min_inclusive)
  - Added a fix for lxml.etree._Comment parsing in XsdElement.iter_decode()
2018-01-17 08:31:27 +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 090af78c7a Key/Unique/Keyref identity constraints partially rewritten
* The `set_context` method has been removed because is not always
    applicable starting from schema;
  * Now all identity constraints paths are selected from instances;
  * XPath select functions now have a name related to the selection scope;
  * Added `etree_getpath` function in etree.py;
  * Added `maxunicode` checks in codepoints.py (issue #32, Python 2.7
    compiled without --enable-unicode=ucs4) for load only UCS-2 code points.
2017-12-28 08:28:27 +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
Davide Brunato 4a8b1b7d82 Fixed some bugs:
* resources.fetch_resource function now expect a single location
  * fixed identity constraint uniqueness check
  * fixed complexContent extension
  * fixed XsdComplexType.has_simple_content method
2017-10-12 07:05:53 +02:00
Davide Brunato 6e992aab09 Fixed some bugs, code cleaning:
* Fixes for bugs #14, #15, #16
  * Removed unused module xmlschema/etree.py
  * Added tests for URLs processing (test URL normalization)
  * Updated licence information (added "-2017")
2017-09-14 13:31:02 +02:00
Davide Brunato f5f6af04e1 Completed the context selection and validation with key/unique constraints,
including the keyref.
2017-09-13 16:08:22 +02:00
Davide Brunato 17b291783e Added a module for identity constraints:
* new file: xmlschema/components/constraints.py
  * parsed xs:unique, xs:key and xs:keyref and subcomponents
  * added '|' as reference delimiter in xpath.py tokenizer
  * improved XPathParser to check operator: the base class
    admits all operators, subclasses can restricts overriding
    NOT_ALLOWED_OPERATORS class attribute.
2017-09-12 18:16:41 +02:00
Davide Brunato b3dd07ae7f Implemented the XMLSchemaValidator base class for unifying
XMLSchema and XsdComponents with a common API.
2017-06-25 07:45:38 +02:00
Davide Brunato cf4e46f5be Implemented some converters for XML to JSON:
* Default converter (the format used by the package before)
  * Converters for JsonML, Parker, Badgerfish and Abdera conventions
  * Update of the documentation
2017-06-12 17:43:37 +02:00
Davide Brunato 2085fb1305 Added XML Schema annotations:
* Refactoring of modules for grouping QName functions and
    declarations (module xmlschema/qnames.py)
  * Created a module for namespaces declarations
    (xmlschema/namespaces.py)
  * Added a directory for model declaration tests
    (xmlschema/tests/examples/model/)
  * Added XsdAnnotation class as subclass of XsdBase
  * XsdBase class splitted and create XsdComponent class
    as the new parent class of XSD components
2017-05-23 16:45:10 +02:00
Davide Brunato e6b3383b0d Switch to version 0.9.7 with some improvements:
* Documentation extended
  * Docuemtation examples now are tested with doctest
  * Improved tests for XPath, validation and decoding
  * The collection.xsd example schema has been extended
  * Removed the exception XMLSchemaBaseValidatorError
  * Now XMLSchemaValidationError is the parent class of
    decode/encode exceptions
2017-05-21 11:27:00 +02:00
Davide Brunato d090df9fa3 Improved XPath parser and testing:
* Added test files for decoder (examples/decoder/*);
  * Added a variant of test schema vehicles.xsd (examples/vehicles/vehicles2.xsd);
  * Added XPath filter predicates;
  * Fixed empty dict decoding to None (issue #4).
2017-05-15 08:06:32 +02:00
Davide Brunato c01fa16a55 Added some ElementTree APIs and an XPath parser:
* Added iterfind, find and findall APIs to schema class for searching
    XSD element declarations using XPath;
  * Added xmlschema/xpath.py for parsing XPath;
  * Added namespace optional argument to iter_decode method, in order
    to map fully qualified names into names with prefixes when decoding.
2017-05-05 09:24:26 +02:00