Skip to content

Commit

Permalink
Merge branch 'develop' for updating to release v1.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed Aug 27, 2019
2 parents 40fd9d9 + 7b5a2b9 commit d442b6a
Show file tree
Hide file tree
Showing 78 changed files with 8,031 additions and 5,129 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*.json
.idea/
.tox/
.coverage
.coverage*
!.coveragerc
.ipynb_checkpoints/
doc/_*/
dist/
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CHANGELOG
*********

`v1.0.14`_ (2019-08-27)
=======================
* Added XSD 1.1 validator with class *XMLSchema11*
* Memory usage optimization with lazy build of the XSD 1.0 and 1.1 meta-schemas
* Added facilities for the encoding of unordered and collapsed content

`v1.0.13`_ (2019-06-19)
=======================
* Fix path normalization and tests for Windows platform
Expand Down Expand Up @@ -249,3 +255,4 @@ v0.9.6 (2017-05-05)
.. _v1.0.10: https://github.com/brunato/xmlschema/compare/v1.0.9...v1.0.10
.. _v1.0.11: https://github.com/brunato/xmlschema/compare/v1.0.10...v1.0.11
.. _v1.0.13: https://github.com/brunato/xmlschema/compare/v1.0.11...v1.0.13
.. _v1.0.14: https://github.com/brunato/xmlschema/compare/v1.0.13...v1.0.14
21 changes: 14 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ Features

This library includes the following features:

* Full XSD 1.0 support
* Full XSD 1.0 and XSD 1.1 support
* Building of XML schema objects from XSD files
* Validation of XML instances against XSD schemas
* Decoding of XML data into Python data and to JSON
* Encoding of Python data and JSON to XML
* Data decoding and encoding ruled by converter classes
* An XPath based API for finding schema's elements and attributes
* Support of XSD validation modes
* Support of XSD validation modes *strict*/*lax*/*skip*
* Remote attacks protection by default using an XMLParser that forbids entities

.. note::
Currently the XSD 1.1 validator is provided by class :class:`XMLSchema11` and
the default :class:`XMLSchema` class is still an alias of the XSD 1.0 validator,
the class :class:`XMLSchema10`. From version 1.1 of the package the default
validator will be linked to the XSD 1.1 validator, a version that will also
removes support for Python 2.7.


Installation
============
Expand Down Expand Up @@ -63,6 +70,11 @@ the file containing the schema as argument:
>>> import xmlschema
>>> my_schema = xmlschema.XMLSchema('xmlschema/tests/cases/examples/vehicles/vehicles.xsd')
.. note::
For XSD 1.1 schemas use the class :class:`XMLSchema11`, because the default class
:class:`XMLSchema` is still an alias of the XSD 1.0 validator class :class:`XMLSchema10`.
From next minor release (v1.1) the default class will become :class:`XMLSchema11`.

The schema can be used to validate XML documents:

.. code-block:: pycon
Expand Down Expand Up @@ -126,14 +138,9 @@ values that match to the data types declared by the schema:
'title': None,
'year': '1925'}]}
Roadmap
=======

* XSD 1.1
Authors
=======

Davide Brunato and others who have contributed with code or with sample cases.

License
Expand Down
152 changes: 133 additions & 19 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ Schema level API
----------------

.. class:: xmlschema.XMLSchema10
.. class:: xmlschema.XMLSchema11

The class for XSD v1.0 schema instances. It's generated by the meta-class :class:`XMLSchemaMeta`
and takes the same API of :class:`XMLSchemaBase`.
The classes for XSD v1.0 and v1.1 schema instances. They are both generated by the
meta-class :class:`XMLSchemaMeta` and take the same API of :class:`XMLSchemaBase`.

.. autoclass:: xmlschema.XMLSchema

Expand Down Expand Up @@ -56,6 +57,7 @@ Schema level API

.. automethod:: check_schema
.. automethod:: build
.. automethod:: clear
.. autoattribute:: built
.. autoattribute:: validation_attempted
.. autoattribute:: validity
Expand All @@ -76,26 +78,14 @@ Schema level API

.. automethod:: iter_encode

ElementTree and XPath API
-------------------------

.. autoclass:: xmlschema.ElementPathMixin

.. autoattribute:: tag
.. autoattribute:: attrib
.. automethod:: get
.. automethod:: iter
.. automethod:: iterchildren
.. automethod:: find
.. automethod:: findall
.. automethod:: iterfind


XSD globals maps API
--------------------
XSD global maps API
-------------------

.. autoclass:: xmlschema.XsdGlobals
:members: copy, register, iter_schemas, iter_globals, clear, build
:members: copy, register, iter_schemas, iter_globals, lookup_notation, lookup_type,
lookup_attribute, lookup_attribute_group, lookup_group, lookup_element, lookup,
clear, build, unbuilt, check


.. _xml-schema-converters-api:
Expand All @@ -111,6 +101,7 @@ to JSON data <http://wiki.open311.org/JSON_and_XML_Conversion/>`_.

.. autoclass:: xmlschema.XMLSchemaConverter

.. autoattribute:: lossy
.. autoattribute:: lossless
.. autoattribute:: losslessly

Expand All @@ -121,6 +112,9 @@ to JSON data <http://wiki.open311.org/JSON_and_XML_Conversion/>`_.
.. automethod:: element_decode
.. automethod:: element_encode

.. automethod:: map_qname
.. automethod:: unmap_qname

.. autoclass:: xmlschema.UnorderedConverter

.. autoclass:: xmlschema.ParkerConverter
Expand Down Expand Up @@ -170,6 +164,125 @@ Resource access API
.. autofunction:: xmlschema.normalize_url




XSD components API
------------------

.. note::
For XSD components only methods included in the following documentation are considered
part of the stable API, the others are considered internals that can be changed without
forewarning.

XSD elements
^^^^^^^^^^^^
.. autoclass:: xmlschema.validators.Xsd11Element
.. autoclass:: xmlschema.validators.XsdElement

XSD attributes
^^^^^^^^^^^^^^
.. autoclass:: xmlschema.validators.Xsd11Attribute
.. autoclass:: xmlschema.validators.XsdAttribute

XSD types
^^^^^^^^^
.. autoclass:: xmlschema.validators.XsdType
:members: is_simple, is_complex, is_atomic, is_empty, is_emptiable, has_simple_content,
has_mixed_content, is_element_only
.. autoclass:: xmlschema.validators.Xsd11ComplexType
.. autoclass:: xmlschema.validators.XsdComplexType
.. autoclass:: xmlschema.validators.XsdSimpleType
.. autoclass:: xmlschema.validators.XsdAtomicBuiltin
.. autoclass:: xmlschema.validators.XsdList
.. autoclass:: xmlschema.validators.Xsd11Union
.. autoclass:: xmlschema.validators.XsdUnion
.. autoclass:: xmlschema.validators.Xsd11AtomicRestriction
.. autoclass:: xmlschema.validators.XsdAtomicRestriction

Attribute and model groups
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: xmlschema.validators.XsdAttributeGroup
.. autoclass:: xmlschema.validators.Xsd11Group
.. autoclass:: xmlschema.validators.XsdGroup

Wildcards
^^^^^^^^^
.. autoclass:: xmlschema.validators.Xsd11AnyElement
.. autoclass:: xmlschema.validators.XsdAnyElement
.. autoclass:: xmlschema.validators.Xsd11AnyAttribute
.. autoclass:: xmlschema.validators.XsdAnyAttribute
.. autoclass:: xmlschema.validators.XsdOpenContent
.. autoclass:: xmlschema.validators.XsdDefaultOpenContent

Identity constraints
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: xmlschema.validators.XsdIdentity
.. autoclass:: xmlschema.validators.XsdSelector
.. autoclass:: xmlschema.validators.XsdFieldSelector
.. autoclass:: xmlschema.validators.Xsd11Unique
.. autoclass:: xmlschema.validators.XsdUnique
.. autoclass:: xmlschema.validators.Xsd11Key
.. autoclass:: xmlschema.validators.XsdKey
.. autoclass:: xmlschema.validators.Xsd11Keyref
.. autoclass:: xmlschema.validators.XsdKeyref

Facets
^^^^^^
.. autoclass:: xmlschema.validators.XsdFacet
.. autoclass:: xmlschema.validators.XsdWhiteSpaceFacet
.. autoclass:: xmlschema.validators.XsdLengthFacet
.. autoclass:: xmlschema.validators.XsdMinLengthFacet
.. autoclass:: xmlschema.validators.XsdMaxLengthFacet
.. autoclass:: xmlschema.validators.XsdMinInclusiveFacet
.. autoclass:: xmlschema.validators.XsdMinExclusiveFacet
.. autoclass:: xmlschema.validators.XsdMaxInclusiveFacet
.. autoclass:: xmlschema.validators.XsdMaxExclusiveFacet
.. autoclass:: xmlschema.validators.XsdTotalDigitsFacet
.. autoclass:: xmlschema.validators.XsdFractionDigitsFacet
.. autoclass:: xmlschema.validators.XsdExplicitTimezoneFacet
.. autoclass:: xmlschema.validators.XsdAssertionFacet
.. autoclass:: xmlschema.validators.XsdEnumerationFacets
.. autoclass:: xmlschema.validators.XsdPatternFacets

Other XSD components
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: xmlschema.validators.XsdAssert
.. autoclass:: xmlschema.validators.XsdAlternative
.. autoclass:: xmlschema.validators.XsdNotation
.. autoclass:: xmlschema.validators.XsdAnnotation

XSD Validation API
^^^^^^^^^^^^^^^^^^
This API is implemented for XSD schemas, elements, attributes, types, attribute
groups and model groups.

.. autoclass:: xmlschema.validators.ValidationMixin

.. automethod:: is_valid
.. automethod:: validate
.. automethod:: decode
.. automethod:: iter_decode
.. automethod:: iter_encode
.. automethod:: iter_errors
.. automethod:: encode
.. automethod:: iter_encode

ElementTree and XPath API
^^^^^^^^^^^^^^^^^^^^^^^^^
This API is implemented for XSD schemas, elements and complexType's assertions.

.. autoclass:: xmlschema.ElementPathMixin

.. autoattribute:: tag
.. autoattribute:: attrib
.. automethod:: get
.. automethod:: iter
.. automethod:: iterchildren
.. automethod:: find
.. automethod:: findall
.. automethod:: iterfind


.. _errors-and-exceptions:

Errors and exceptions
Expand All @@ -190,3 +303,4 @@ Errors and exceptions

.. autoexception:: xmlschema.XMLSchemaIncludeWarning
.. autoexception:: xmlschema.XMLSchemaImportWarning
.. autoexception:: xmlschema.XMLSchemaTypeTableWarning
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0.13'
release = '1.0.14'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 0 additions & 5 deletions doc/notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,3 @@ Support

The project is hosted on GitHub, refer to the `xmlschema's project page <https://github.com/brunato/xmlschema>`_
for source code and for an issue tracker.

Roadmap
-------

* XSD 1.1
28 changes: 24 additions & 4 deletions doc/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ subdirectory. There are several test scripts, each one for a different topic:
Tests about XML/XSD resources access

**test_schemas.py**
Tests about parsing of XSD Schemas
Tests about parsing of XSD schemas and components

**test_validators.py**
Tests regarding XML data validation/decoding/encoding
Expand Down Expand Up @@ -142,15 +142,35 @@ Testing with the W3C XML Schema 1.1 test suite
----------------------------------------------

From release v1.0.11, using the script *test_w3c_suite.py*, you can run also tests based on the
`W3C XML Schema 1.1 test suite <https://github.com/w3c/xsdtests>`_. To run these tests, currently
limited to XSD 1.0 schema tests, clone the W3C repo on the project's parent directory and than
run the script:
`W3C XML Schema 1.1 test suite <https://github.com/w3c/xsdtests>`_. To run these tests clone the
W3C repo on the project's parent directory and than run the script:

.. code-block:: text
git clone https://github.com/w3c/xsdtests.git
python xmlschema/xmlschema/tests/test_w3c_suite.py
You can also provides additional options for select a different set of tests:

**--xml**
Add tests for instances, skipped for default.

**--xsd10**
Run only XSD 1.0 tests.

**--xsd11**
Run only XSD 1.1 tests.

**--valid**
Run only tests signed as *valid*.

**--invalid**
Run only tests signed as *invalid*.

**[NUM [NUM ...]]**
Run only the cases that match a list of progressive numbers, associated
to the test classes by the script.


Testing other schemas and instances
-----------------------------------
Expand Down
12 changes: 10 additions & 2 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Import the library in your code with::

import xmlschema

The module initialization builds the XSD meta-schemas and of the dictionary
containing the code points of the Unicode categories.
The module initialization builds the dictionary containing the code points of
the Unicode categories.


Create a schema instance
Expand Down Expand Up @@ -553,3 +553,11 @@ From release v1.0.12 the document validation and decoding API has an optional ar
that can be changed to True for operating with a lazy :class:`XMLResource`. The lazy mode can be
useful for validating and decoding big XML data files. This is still an experimental feature that
will be refined and integrated in future versions.


XSD 1.0 and 1.1 support
-----------------------
From release v1.0.14 XSD 1.1 support has been added to the library through the class
:class:`XMLSchema11`. You have to use this class for XSD 1.1 schemas instead the default
class :class:`XMLSchema` that is still linked to XSD 1.0 validator :class:`XMLSchema10`.
From next minor release (v1.1) the default class will become :class:`XMLSchema11`.
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setuptools
tox
coverage
elementpath~=1.1.7
elementpath~=1.2.0
lxml
memory_profiler
pathlib2 # For Py27 tests on resources
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def run(self):

setup(
name='xmlschema',
version='1.0.13',
install_requires=['elementpath~=1.1.7'],
version='1.0.14',
install_requires=['elementpath~=1.2.0'],
packages=['xmlschema'],
include_package_data=True,
cmdclass={
Expand Down
Loading

0 comments on commit d442b6a

Please sign in to comment.