Skip to content

Commit

Permalink
Update version 3.0 info and docs
Browse files Browse the repository at this point in the history
  - Relax memory tests with lazy option to avoid some
    extemporary failures
  - Remove xmlns_processing_default='none' if XML data source is
    None (None can be a valid decoded value with the default
    converter, in any case this is irrelevant for the result)
  • Loading branch information
brunato committed Jan 7, 2024
1 parent 345b823 commit f581929
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 24 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.rst
Expand Up @@ -2,10 +2,10 @@
CHANGELOG
*********

`v3.0.0`_ (2023-XX-XX)
`v3.0.0`_ (2024-01-07)
======================
* XML declaration processing options
* Decode/validate with dynamic schema load
* XML declaration processing option *xmlns_processing* for converters
* Decode/validate from XML document with dynamic schema load
* XMLResource enhancement for a better XML resources processing
* Improve lazy resources iteration removing preceding elements (*thin_mode* option)
* Drop support for Python 3.7
Expand Down Expand Up @@ -654,3 +654,4 @@ v0.9.6 (2017-05-05)
.. _v2.4.0: https://github.com/brunato/xmlschema/compare/v2.3.1...v2.4.0
.. _v2.5.0: https://github.com/brunato/xmlschema/compare/v2.4.0...v2.5.0
.. _v2.5.1: https://github.com/brunato/xmlschema/compare/v2.5.0...v2.5.1
.. _v3.0.0: https://github.com/brunato/xmlschema/compare/v2.5.1...v3.0.0
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c), 2016-2022, SISSA (Scuola Internazionale Superiore di Studi Avanzati)
Copyright (c), 2016-2024, SISSA (Scuola Internazionale Superiore di Studi Avanzati)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
32 changes: 20 additions & 12 deletions doc/features.rst
Expand Up @@ -79,28 +79,36 @@ With version 3.0 the processing of namespace information of the XML document has
been improved, with the default of maintaining an exact namespace mapping between
the XML source and the decoded data.

For the decoding API the argument *xmlns_usage* has been added, in order to change
the usage mode of the XML namespace declarations of the document.
The feature is available both with the decoding and encoding API with the new converter
option *xmlns_processing*, that permits to change the processing mode of the namespace
declarations of the XML document.

The default of this option is *'exact'* which means that the loaded namespace declarations
always match the ones defined in the XML document. In this case the namespace map is
updated dynamically, adding and removing the XML declarations found in internal elements.
This choice provide the most accurate mapping of the namespace information of the XML
document.
The preferred mode is *'stacked'*, the mode that maintains a stack of namespace mapping
contexts, with the active context that always match the namespace declarations defined
in the XML document. In this case the namespace map is updated dynamically, adding and
removing the XML declarations found in internal elements. This choice provide the most
accurate mapping of the namespace information of the XML document.

Use the option value *'collapsed'* for loading all namespace declarations of the XML
source before decoding. In this case The declarations are merged into a static namespace
map, using alternative prefixes in case of collision. This is the legacy behaviour of
versions prior to 3 of the library.
Use the option value *'collapsed'* for loading all namespace declarations in a single
map. In this case the declarations are merged into the namespace map of the converter,
using alternative prefixes in case of collision.
This is the legacy behaviour of versions prior to 3 of the library.

With *'root-only'* only the namespace declarations of the XML document root are loaded.
In this case you are expected to provided the internal namespace information with
In this case you are expected to provide the internal namespace information with
*namespaces* argument.

Use *'none'* to not load any namespace declaration of the XML document. Use this
option if you don't want to map namespaces to prefixes or you want to provide a
fully custom namespace mapping.

For default *xmlns_processing* option is set automatically depending by the converter
class capability and the XML data source. The option is available also for
encoding with updated converter classes that can retrieve xmlns declarations from
decoded data (e.g. :class:`xmlschema.JsonMLConverter` or the default converter).
For decoding the default is set to *'stacked'* or *'collapsed'*, for encoding the
default can be also *'none'* if no namespace declaration can be retrieved from XML
data (e.g. :class:`xmlschema.ParkerConverter`).

Lazy validation
===============
Expand Down
4 changes: 2 additions & 2 deletions publiccode.yml
Expand Up @@ -6,8 +6,8 @@ publiccodeYmlVersion: '0.2'
name: xmlschema
url: 'https://github.com/sissaschool/xmlschema'
landingURL: 'https://github.com/sissaschool/xmlschema'
releaseDate: '2023-12-19'
softwareVersion: v2.5.1
releaseDate: '2024-01-07'
softwareVersion: v3.0.0
developmentStatus: stable
platforms:
- linux
Expand Down
6 changes: 3 additions & 3 deletions tests/test_memory.py
Expand Up @@ -27,7 +27,7 @@ class TestMemoryUsage(unittest.TestCase):

@staticmethod
def check_memory_profile(output):
"""Check the output of a memory memory profile run on a function."""
"""Check the output of a memory profile run on a function."""
mem_usage = []
func_num = 0
for line in output.split('\n'):
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_decode_memory_usage(self):
lazy_decode_mem = self.check_memory_profile(output)

self.assertLessEqual(decode_mem, 2.6)
self.assertLessEqual(lazy_decode_mem, 1.8)
self.assertLessEqual(lazy_decode_mem, 2.1)

def test_validate_memory_usage(self):
with tempfile.TemporaryDirectory() as dirname:
Expand All @@ -126,7 +126,7 @@ def test_validate_memory_usage(self):
lazy_validate_mem = self.check_memory_profile(output)

self.assertLess(validate_mem, 2.6)
self.assertLess(lazy_validate_mem, 1.8)
self.assertLess(lazy_validate_mem, 2.1)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion xmlschema/__init__.py
Expand Up @@ -35,7 +35,7 @@
__version__ = '3.0.0'
__author__ = "Davide Brunato"
__contact__ = "brunato@sissa.it"
__copyright__ = "Copyright 2016-2023, SISSA"
__copyright__ = "Copyright 2016-2024, SISSA"
__license__ = "MIT"
__status__ = "Production/Stable"

Expand Down
2 changes: 0 additions & 2 deletions xmlschema/converters/default.py
Expand Up @@ -194,8 +194,6 @@ def xmlns_processing_default(self) -> str:
return 'stacked'
else:
return 'collapsed'
elif self.source is None:
return 'none'
elif getattr(self.element_encode, 'stackable', False):
return 'stacked'
else:
Expand Down

0 comments on commit f581929

Please sign in to comment.