Skip to content

Commit

Permalink
Update docs and release info
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed Apr 11, 2021
1 parent 70af02b commit a991642
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
CHANGELOG
*********

`v1.6.1`_ (2021-04-11)
======================
* Add multi-source initialization and add_schema() to schema class
* Add bytes strings to accepted XML sources (issue #238)

`v1.6.0`_ (2021-04-06)
======================
* XML data bindings and code generators are now considered stable
Expand Down Expand Up @@ -430,3 +435,4 @@ v0.9.6 (2017-05-05)
.. _v1.5.2: https://github.com/brunato/xmlschema/compare/v1.5.1...v1.5.2
.. _v1.5.3: https://github.com/brunato/xmlschema/compare/v1.5.2...v1.5.3
.. _v1.6.0: https://github.com/brunato/xmlschema/compare/v1.5.3...v1.6.0
.. _v1.6.1: https://github.com/brunato/xmlschema/compare/v1.6.0...v1.6.1
45 changes: 45 additions & 0 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,51 @@ reference directory path for other includes and imports:
>>> schema = xmlschema.XMLSchema(schema_file, base_url='tests/test_cases/examples/vehicles/')


Non standard options for schema instance creation
-------------------------------------------------

Other options for schema instance creation are available using non-standard
methods. Most cases require to use the *build* option to delay the schema
build after the loading of all schema resources. For example:

.. doctest::

>>> schema_file = open('tests/test_cases/examples/vehicles/vehicles.xsd')
>>> schema = xmlschema.XMLSchema(schema_file, build=False)
>>> _ = schema.include_schema('tests/test_cases/examples/vehicles/cars.xsd')
>>> _ = schema.include_schema('tests/test_cases/examples/vehicles/bikes.xsd')
>>> schema.build()

Another option, available from release v1.6.1, is to provide a list of schema sources,
particurlaly useful when sources have no locations associated:

.. doctest::

>>> sources = [open('tests/test_cases/examples/vehicles/vehicles.xsd'),
... open('tests/test_cases/examples/vehicles/cars.xsd'),
... open('tests/test_cases/examples/vehicles/bikes.xsd'),
... open('tests/test_cases/examples/vehicles/types.xsd')]
>>> schema = xmlschema.XMLSchema(sources)

or similarly to the previous example one can use the method :meth:`add_schema()`:

.. doctest::

>>> schema_file = open('tests/test_cases/examples/vehicles/vehicles.xsd')
>>> schema = xmlschema.XMLSchema(schema_file, build=False)
>>> _ = schema.add_schema(open('tests/test_cases/examples/vehicles/cars.xsd'))
>>> _ = schema.add_schema(open('tests/test_cases/examples/vehicles/bikes.xsd'))
>>> _ = schema.add_schema(open('tests/test_cases/examples/vehicles/types.xsd'))
>>> schema.build()


.. note::
Anyway the advice is to build intermediate XSD schemas intead for loading
all the schemas needed in a standard way, because XSD mechanisms of imports,
includes, redefines and overrides are usually supported when you submit your
schemas to other XSD validators.


Validation
==========

Expand Down
4 changes: 2 additions & 2 deletions publiccode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ publiccodeYmlVersion: '0.2'
name: xmlschema
url: 'https://github.com/sissaschool/xmlschema'
landingURL: 'https://github.com/sissaschool/xmlschema'
releaseDate: '2021-04-06'
softwareVersion: v1.6.0
releaseDate: '2021-04-11'
softwareVersion: v1.6.1
developmentStatus: stable
platforms:
- linux
Expand Down
2 changes: 1 addition & 1 deletion tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def test_xml_resource_from_url(self):
self.assertEqual(resource.source, self.vh_xml_file)
self.assertEqual(resource.root.tag, '{http://example.com/vehicles}vehicles')
self.check_url(resource.url, self.vh_xml_file)
self.assertTrue(resource.filepath.endswith(self.vh_xml_file))
self.assertTrue(resource.filepath.endswith('vehicles.xml'))
self.assertIsNone(resource.text)
with self.assertRaises(XMLResourceError) as ctx:
resource.load()
Expand Down

0 comments on commit a991642

Please sign in to comment.