Skip to content

Commit

Permalink
Merge branch 'develop' for updating to release v1.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed May 5, 2019
2 parents 376e208 + 3f47092 commit d0ddbc4
Show file tree
Hide file tree
Showing 78 changed files with 4,680 additions and 1,876 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ build/
development/
test_cases/
!xmlschema/tests/test_cases/
!xmlschema/unicode_categories.json
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
CHANGELOG
*********

`v1.0.11`_ (2019-05-05)
=======================
* Added a script for running the W3C XSD test suite.
* Check restrictions and model groups UPA violations
* Model groups splitted between two modules for more focusing on models basics
* Added two new exceptions for model group errors
* More control on imported namespaces
* Added *use_meta* argument to schema classes
* Added *includes* list and *imports* dict to schema classes
* Many fixes for passing the W3C's tests for XSD 1.0 schemas
* Added a test for issue #105 and a fix for issue #103

`v1.0.10`_ (2019-02-25)
=======================
* Fixed Element type mismatch issue when apply *SafeXMLParser* to schema resources
Expand Down Expand Up @@ -226,3 +238,4 @@ v0.9.6 (2017-05-05)
.. _v1.0.8: https://github.com/brunato/xmlschema/compare/v1.0.7...v1.0.8
.. _v1.0.9: https://github.com/brunato/xmlschema/compare/v1.0.8...v1.0.9
.. _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
21 changes: 11 additions & 10 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,33 @@ Schema level API
.. autoattribute:: tag
.. autoattribute:: id
.. autoattribute:: version
.. autoattribute:: attribute_form_default
.. autoattribute:: element_form_default
.. autoattribute:: block_default
.. autoattribute:: final_default

.. autoattribute:: schema_location
.. autoattribute:: no_namespace_schema_location
.. autoattribute:: target_prefix
.. autoattribute:: default_namespace
.. autoattribute:: base_url
.. autoattribute:: root_elements
.. autoattribute:: builtin_types
.. autoattribute:: root_elements

.. automethod:: get_locations
.. automethod:: include_schema
.. automethod:: import_schema
.. automethod:: create_meta_schema
.. automethod:: create_schema
.. automethod:: create_any_content_group
.. automethod:: create_any_attribute_group

.. automethod:: get_locations
.. automethod:: include_schema
.. automethod:: import_schema
.. automethod:: resolve_qname
.. automethod:: iter_globals
.. automethod:: iter_components

.. automethod:: check_schema
.. automethod:: build
.. autoattribute:: built
.. autoattribute:: validation_attempted
.. autoattribute:: validity
.. autoattribute:: all_errors
.. automethod:: iter_components
.. automethod:: iter_globals

.. automethod:: get_converter
.. automethod:: validate
Expand Down Expand Up @@ -180,6 +179,8 @@ Errors and exceptions
.. autoexception:: xmlschema.XMLSchemaValidatorError
.. autoexception:: xmlschema.XMLSchemaNotBuiltError
.. autoexception:: xmlschema.XMLSchemaParseError
.. autoexception:: xmlschema.XMLSchemaModelError
.. autoexception:: xmlschema.XMLSchemaModelDepthError
.. autoexception:: xmlschema.XMLSchemaValidationError
.. autoexception:: xmlschema.XMLSchemaDecodeError
.. autoexception:: xmlschema.XMLSchemaEncodeError
Expand Down
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.10'
release = '1.0.11'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
14 changes: 14 additions & 0 deletions doc/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,17 @@ or:
.. code-block:: text
tox -- -x
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, actually
limited to XSD 1.0 schema 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
22 changes: 19 additions & 3 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ The global maps can be accessed through :attr:`XMLSchema.maps` attribute:
'{http://www.w3.org/1999/xlink}locator',
'{http://www.w3.org/1999/xlink}resource',
'{http://www.w3.org/1999/xlink}title',
'{http://www.w3.org/2001/XMLSchema-hasFacetAndProperty}hasFacet',
'{http://www.w3.org/2001/XMLSchema-hasFacetAndProperty}hasProperty',
'{http://www.w3.org/2001/XMLSchema}all']
'{http://www.w3.org/2001/XMLSchema}all',
'{http://www.w3.org/2001/XMLSchema}annotation',
'{http://www.w3.org/2001/XMLSchema}any']

Schema objects include methods for finding XSD elements and attributes in the schema.
Those are methods ot the ElementTree's API, so you can use an XPath expression for
Expand Down Expand Up @@ -528,3 +528,19 @@ For default this argument has value *'remote'* that means the protection on XML
applied only to data loaded from remote. Other values for this argument can be *'always'*
and *'never'*.


Limit on model groups checking
------------------------------

From release v1.0.11 the model groups of the schemas are checked against restriction violations
and *Unique Particle Attribution* violations.

To avoids XSD model recursion attacks a limit of ``MAX_MODEL_DEPTH = 15`` is set. If this limit
is exceeded an ``XMLSchemaModelDepthError`` is raised, the error is caught and a warning is generated.
If you need to set an higher limit for checking all your groups you can import the library and change
the value in the specific module that processes the model checks:

.. doctest::

>>> import xmlschema
>>> xmlschema.validators.models.MAX_MODEL_DEPTH = 20
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Requirements for setup a development environment for the xmlschema package.
setuptools
tox
elementpath~=1.1.5
elementpath~=1.1.7
lxml
memory_profiler
pathlib2 # For Py27 tests on resources
Expand Down
30 changes: 28 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,43 @@
#
# @author Davide Brunato <[email protected]>
#
import importlib
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install

with open("README.rst") as readme:
long_description = readme.read()


class DevelopCommand(develop):

def run(self):
develop.run(self)
print("Post-develop: create Unicode categories JSON file")
codepoints_module = importlib.import_module('xmlschema.codepoints')
codepoints_module.save_unicode_categories()


class InstallCommand(install):

def run(self):
install.run(self)
print("Post-install: create Unicode categories JSON file")
codepoints_module = importlib.import_module('xmlschema.codepoints')
codepoints_module.save_unicode_categories()


setup(
name='xmlschema',
version='1.0.10',
install_requires=['elementpath~=1.1.5'],
version='1.0.11',
install_requires=['elementpath~=1.1.7'],
packages=['xmlschema'],
include_package_data=True,
cmdclass={
'develop': DevelopCommand,
'install': InstallCommand
},
author='Davide Brunato',
author_email='[email protected]',
url='https://github.com/brunato/xmlschema',
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ toxworkdir = {homedir}/.tox/xmlschema
[testenv]
deps =
lxml
elementpath~=1.1.5
elementpath~=1.1.7
commands = python xmlschema/tests/test_all.py {posargs}

[testenv:py27]
deps =
lxml
elementpath~=1.1.5
elementpath~=1.1.7
pathlib2
commands = python xmlschema/tests/test_all.py {posargs}
10 changes: 6 additions & 4 deletions xmlschema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
from .documents import validate, to_dict, to_json, from_json

from .validators import (
XMLSchemaValidatorError, XMLSchemaParseError, XMLSchemaNotBuiltError, XMLSchemaValidationError,
XMLSchemaDecodeError, XMLSchemaEncodeError, XMLSchemaChildrenValidationError, XMLSchemaIncludeWarning,
XMLSchemaImportWarning, XsdGlobals, XMLSchemaBase, XMLSchema, XMLSchema10
XMLSchemaValidatorError, XMLSchemaParseError, XMLSchemaNotBuiltError, XMLSchemaModelError,
XMLSchemaModelDepthError, XMLSchemaValidationError, XMLSchemaDecodeError, XMLSchemaEncodeError,
XMLSchemaChildrenValidationError, XMLSchemaIncludeWarning, XMLSchemaImportWarning, XsdGlobals,
XMLSchemaBase, XMLSchema, XMLSchema10
)

__version__ = '1.0.10'
__version__ = '1.0.11'
__author__ = "Davide Brunato"
__contact__ = "[email protected]"
__copyright__ = "Copyright 2016-2019, SISSA"
Expand All @@ -40,6 +41,7 @@ def XMLSchema_v1_0(*args, **kwargs):
"and will be removed in 1.1 version", DeprecationWarning, stacklevel=2)
return XMLSchema10(*args, **kwargs)


def etree_get_namespaces(*args, **kwargs):
import warnings
warnings.warn("etree_get_namespaces() function name has been replaced by fetch_namespaces() "
Expand Down
Loading

0 comments on commit d0ddbc4

Please sign in to comment.