From a991642d1e5ad3f03fcb28461c5bf600a69e92ab Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Sun, 11 Apr 2021 22:18:49 +0200 Subject: [PATCH] Update docs and release info --- CHANGELOG.rst | 6 ++++++ doc/usage.rst | 45 +++++++++++++++++++++++++++++++++++++++++ publiccode.yml | 4 ++-- tests/test_resources.py | 2 +- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9aac4e5d..4c1a1d1c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 @@ -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 diff --git a/doc/usage.rst b/doc/usage.rst index 142fb39a..f6df2deb 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -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 ========== diff --git a/publiccode.yml b/publiccode.yml index 89934036..7ccdb412 100644 --- a/publiccode.yml +++ b/publiccode.yml @@ -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 diff --git a/tests/test_resources.py b/tests/test_resources.py index 35f35812..bb86d389 100644 --- a/tests/test_resources.py +++ b/tests/test_resources.py @@ -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()