Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-xmlschema for 
openSUSE:Factory checked in at 2022-10-04 20:37:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-xmlschema (Old)
 and      /work/SRC/openSUSE:Factory/.python-xmlschema.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-xmlschema"

Tue Oct  4 20:37:16 2022 rev:18 rq:1007722 version:2.1.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-xmlschema/python-xmlschema.changes        
2022-10-01 17:42:53.209640709 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-xmlschema.new.2275/python-xmlschema.changes  
    2022-10-04 20:37:17.748879628 +0200
@@ -1,0 +2,7 @@
+Mon Oct  3 16:12:06 UTC 2022 - Dirk M??ller <[email protected]>
+
+- update to 2.1.1:
+  * Fix *schema_path* usage in `XMLSchemaBase.iter_errors()`
+  * Add *allow_empty* option to `XMLSchemaBase` validation API
+
+-------------------------------------------------------------------

Old:
----
  xmlschema-2.1.0.tar.gz

New:
----
  xmlschema-2.1.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-xmlschema.spec ++++++
--- /var/tmp/diff_new_pack.5Takv5/_old  2022-10-04 20:37:18.400880554 +0200
+++ /var/tmp/diff_new_pack.5Takv5/_new  2022-10-04 20:37:18.408880566 +0200
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %define skip_python2 1
 Name:           python-xmlschema
-Version:        2.1.0
+Version:        2.1.1
 Release:        0
 Summary:        An XML Schema validator and decoder
 License:        MIT

++++++ xmlschema-2.1.0.tar.gz -> xmlschema-2.1.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/CHANGELOG.rst 
new/xmlschema-2.1.1/CHANGELOG.rst
--- old/xmlschema-2.1.0/CHANGELOG.rst   2022-09-25 09:58:42.000000000 +0200
+++ new/xmlschema-2.1.1/CHANGELOG.rst   2022-10-01 15:42:01.000000000 +0200
@@ -2,6 +2,11 @@
 CHANGELOG
 *********
 
+`v2.1.1`_ (2022-10-01)
+======================
+* Fix *schema_path* usage in `XMLSchemaBase.iter_errors()`
+* Add *allow_empty* option to `XMLSchemaBase` validation API
+
 `v2.1.0`_ (2022-09-25)
 ======================
 * Add *to_etree()* to document API
@@ -585,3 +590,4 @@
 .. _v2.0.3: https://github.com/brunato/xmlschema/compare/v2.0.2...v2.0.3
 .. _v2.0.4: https://github.com/brunato/xmlschema/compare/v2.0.3...v2.0.4
 .. _v2.1.0: https://github.com/brunato/xmlschema/compare/v2.0.4...v2.1.0
+.. _v2.1.1: https://github.com/brunato/xmlschema/compare/v2.1.0...v2.1.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/PKG-INFO new/xmlschema-2.1.1/PKG-INFO
--- old/xmlschema-2.1.0/PKG-INFO        2022-09-25 10:00:21.177932000 +0200
+++ new/xmlschema-2.1.1/PKG-INFO        2022-10-01 19:02:18.985521600 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: xmlschema
-Version: 2.1.0
+Version: 2.1.1
 Summary: An XML Schema validator and decoder
 Home-page: https://github.com/sissaschool/xmlschema
 Author: Davide Brunato
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/doc/api.rst 
new/xmlschema-2.1.1/doc/api.rst
--- old/xmlschema-2.1.0/doc/api.rst     2022-09-25 09:58:42.000000000 +0200
+++ new/xmlschema-2.1.1/doc/api.rst     2022-10-01 15:42:01.000000000 +0200
@@ -93,7 +93,6 @@
     .. automethod:: iter_globals
     .. automethod:: iter_components
 
-    .. automethod:: check_schema
     .. automethod:: build
     .. automethod:: clear
     .. autoattribute:: built
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/doc/conf.py 
new/xmlschema-2.1.1/doc/conf.py
--- old/xmlschema-2.1.0/doc/conf.py     2022-09-25 09:58:42.000000000 +0200
+++ new/xmlschema-2.1.1/doc/conf.py     2022-10-01 15:42:01.000000000 +0200
@@ -79,9 +79,9 @@
 # built documents.
 #
 # The short X.Y version.
-version = '2.0'
+version = '2.1'
 # The full version, including alpha/beta/rc tags.
-release = '2.1.0'
+release = '2.1.1'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/doc/usage.rst 
new/xmlschema-2.1.1/doc/usage.rst
--- old/xmlschema-2.1.0/doc/usage.rst   2022-09-25 09:58:42.000000000 +0200
+++ new/xmlschema-2.1.1/doc/usage.rst   2022-10-01 15:42:01.000000000 +0200
@@ -595,4 +595,88 @@
     XMLSchema10(name='vehicles.xsd', namespace='http://example.com/vehicles')
 
 This class can be used to derive specialized schema-related classes.
-See :ref:`wsdl11-documents` section for an application example.
\ No newline at end of file
+See :ref:`wsdl11-documents` section for an application example.
+
+
+Meta-schemas and XSD sources
+============================
+
+Schema classes :class:`xmlschema.XMLSchema10` and 
:class:`xmlschema.XMLSchema11`
+have built-in meta-schema instances, related to the XSD namespace, that can be 
used
+directly to validate XSD sources without build a new schema:
+
+.. doctest::
+
+    >>> from xmlschema import XMLSchema
+    >>> 
XMLSchema.meta_schema.validate('tests/test_cases/examples/vehicles/vehicles.xsd')
+    >>> 
XMLSchema.meta_schema.validate('tests/test_cases/examples/vehicles/invalid.xsd')
+    Traceback (most recent call last):
+    ...
+    ...
+    xmlschema.validators.exceptions.XMLSchemaValidationError: failed 
validating ...
+
+    Reason: use of attribute 'name' is prohibited
+
+    Schema:
+
+      <xs:restriction xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
base="xs:complexType">
+       <xs:sequence>
+        <xs:element ref="xs:annotation" minOccurs="0" />
+        <xs:group ref="xs:complexTypeModel" />
+       </xs:sequence>
+       <xs:attribute name="name" use="prohibited" />
+       <xs:attribute name="abstract" use="prohibited" />
+       <xs:attribute name="final" use="prohibited" />
+       <xs:attribute name="block" use="prohibited" />
+       <xs:anyAttribute namespace="##other" processContents="lax" />
+      </xs:restriction>
+
+    Instance:
+
+      <xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
name="vehiclesType">
+        <xs:sequence>
+          <xs:element ref="vh:cars" />
+          <xs:element ref="vh:bikes" />
+        </xs:sequence>
+      </xs:complexType>
+
+    Path: /xs:schema/xs:element/xs:complexType
+
+
+Furthermore also decode and encode methods can be applied on XSD files or 
sources:
+
+.. doctest::
+
+    >>> from xmlschema import XMLSchema
+    >>> obj = 
XMLSchema.meta_schema.decode('tests/test_cases/examples/vehicles/vehicles.xsd')
+    >>> from pprint import pprint
+    >>> pprint(obj)
+    {'@attributeFormDefault': 'unqualified',
+     '@blockDefault': [],
+     '@elementFormDefault': 'qualified',
+     '@finalDefault': [],
+     '@targetNamespace': 'http://example.com/vehicles',
+     '@xmlns:xs': 'http://www.w3.org/2001/XMLSchema',
+     'xs:attribute': {'@name': 'step', '@type': 'xs:positiveInteger'},
+     'xs:element': {'@abstract': False,
+                    '@name': 'vehicles',
+                    '@nillable': False,
+                    'xs:complexType': {'@mixed': False,
+                                       'xs:sequence': {'@maxOccurs': 1,
+                                                       '@minOccurs': 1,
+                                                       'xs:element': 
[{'@maxOccurs': 1,
+                                                                       
'@minOccurs': 1,
+                                                                       
'@nillable': False,
+                                                                       '@ref': 
'vh:cars'},
+                                                                      
{'@maxOccurs': 1,
+                                                                       
'@minOccurs': 1,
+                                                                       
'@nillable': False,
+                                                                       '@ref': 
'vh:bikes'}]}}},
+     'xs:include': [{'@schemaLocation': 'cars.xsd'},
+                    {'@schemaLocation': 'bikes.xsd'}]}
+
+.. note::
+    Building a new schema for XSD namespace could be not trivial because other 
schemas are
+    required for base namespaces (e.g. XML namespace 
'http://www.w3.org/XML/1998/namespace').
+    This is particularly true for XSD 1.1 because the XSD meta-schema lacks of 
built-in
+    list types definitions, so a patch schema is required.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/setup.py new/xmlschema-2.1.1/setup.py
--- old/xmlschema-2.1.0/setup.py        2022-09-25 09:58:42.000000000 +0200
+++ new/xmlschema-2.1.1/setup.py        2022-10-01 15:42:01.000000000 +0200
@@ -18,7 +18,7 @@
 
 setup(
     name='xmlschema',
-    version='2.1.0',
+    version='2.1.1',
     packages=find_packages(include=['xmlschema*']),
     package_data={
         'xmlschema': ['py.typed', 'locale/**/*.mo', 'locale/**/*.po', 
'schemas/*/*.xsd'],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/xmlschema-2.1.0/tests/test_cases/examples/vehicles/invalid.xsd 
new/xmlschema-2.1.1/tests/test_cases/examples/vehicles/invalid.xsd
--- old/xmlschema-2.1.0/tests/test_cases/examples/vehicles/invalid.xsd  
1970-01-01 01:00:00.000000000 +0100
+++ new/xmlschema-2.1.1/tests/test_cases/examples/vehicles/invalid.xsd  
2022-10-01 15:42:01.000000000 +0200
@@ -0,0 +1,20 @@
+<xs:schema
+  xmlns:xs="http://www.w3.org/2001/XMLSchema";
+  xmlns:vh="http://example.com/vehicles";
+  targetNamespace="http://example.com/vehicles";
+  elementFormDefault="qualified">
+
+  <xs:include schemaLocation="cars.xsd"/>
+  <xs:include schemaLocation="bikes.xsd"/>
+
+  <xs:element name="vehicles">
+    <xs:complexType name="vehiclesType"> <!-- name attr not allowed! -->
+      <xs:sequence>
+        <xs:element ref="vh:cars" />
+        <xs:element ref="vh:bikes" />
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:attribute type="xs:positiveInteger" name="step"/>
+</xs:schema>
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/tests/validation/test_validation.py 
new/xmlschema-2.1.1/tests/validation/test_validation.py
--- old/xmlschema-2.1.0/tests/validation/test_validation.py     2022-08-28 
11:32:05.000000000 +0200
+++ new/xmlschema-2.1.1/tests/validation/test_validation.py     2022-10-01 
15:42:01.000000000 +0200
@@ -135,7 +135,7 @@
         self.assertTrue(xsd_element.is_valid(root[1], max_depth=1))
         self.assertFalse(xsd_element.is_valid(root[1], max_depth=2))
 
-    def test_extra_validator(self):
+    def test_extra_validator_argument(self):
         # Related to issue 227
 
         def bikes_validator(elem, xsd_element_):
@@ -168,6 +168,43 @@
             self.vh_schema.validate(self.vh_xml_file, 
extra_validator=bikes_validator)
         self.assertIn('Reason: not an Harley-Davidson', str(ec.exception))
 
+    def test_path_argument(self):
+        schema = 
xmlschema.XMLSchema(self.casepath('examples/vehicles/vehicles.xsd'))
+
+        self.assertTrue(schema.is_valid(self.vh_xml_file, path='*'))
+        self.assertTrue(schema.is_valid(self.vh_xml_file, path='/vh:vehicles'))
+        self.assertTrue(schema.is_valid(self.vh_xml_file, 
path='/vh:vehicles/vh:cars'))
+        self.assertTrue(schema.is_valid(self.vh_xml_file, path='vh:cars'))
+        self.assertTrue(schema.is_valid(self.vh_xml_file, 
path='/vh:vehicles/vh:cars/vh:car'))
+        self.assertTrue(schema.is_valid(self.vh_xml_file, path='.//vh:car'))
+
+        self.assertTrue(schema.is_valid(self.vh_xml_file, path='xs:vehicles'))
+        self.assertFalse(
+            schema.is_valid(self.vh_xml_file, path='xs:vehicles', 
allow_empty=False)
+        )
+
+    def test_schema_path_argument__issue_326(self):
+        schema = 
xmlschema.XMLSchema(self.casepath('examples/vehicles/vehicles.xsd'))
+        document = ElementTree.parse(self.vh_xml_file)
+
+        entries = document.findall('vh:cars', {'vh': 
'http://example.com/vehicles'})
+        self.assertListEqual(entries, [document.getroot()[0]])
+        for entry in entries:
+            self.assertTrue(schema.is_valid(
+                entry,
+                schema_path='/vh:vehicles/vh:cars',
+                namespaces={'vh': 'http://example.com/vehicles'}
+            ))
+
+        entries = document.findall('vh:cars/vh:car', {'vh': 
'http://example.com/vehicles'})
+        self.assertListEqual(entries, list(document.getroot()[0][:]))
+        for entry in entries:
+            self.assertTrue(schema.is_valid(
+                entry,
+                schema_path='.//vh:cars/vh:car',
+                namespaces={'vh': 'http://example.com/vehicles'}
+            ))
+
     def test_issue_064(self):
         self.check_validity(self.st_schema, '<name xmlns="ns"></name>', False)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/tests/validators/test_schemas.py 
new/xmlschema-2.1.1/tests/validators/test_schemas.py
--- old/xmlschema-2.1.0/tests/validators/test_schemas.py        2022-09-08 
12:16:11.000000000 +0200
+++ new/xmlschema-2.1.1/tests/validators/test_schemas.py        2022-10-01 
15:42:01.000000000 +0200
@@ -24,8 +24,7 @@
 import xmlschema
 from xmlschema import XMLSchemaParseError, XMLSchemaIncludeWarning, 
XMLSchemaImportWarning
 from xmlschema.names import XML_NAMESPACE, LOCATION_HINTS, SCHEMAS_DIR, 
XSD_ELEMENT, XSI_TYPE
-from xmlschema.validators import XMLSchemaBase, XMLSchema10, XMLSchema11, \
-    XsdGlobals, Xsd11Attribute
+from xmlschema.validators import XMLSchemaBase, XMLSchema10, XMLSchema11, 
XsdGlobals
 from xmlschema.testing import SKIP_REMOTE_TESTS, XsdValidatorTestCase
 from xmlschema.validators.schemas import logger
 
@@ -832,24 +831,19 @@
             pickle.dumps(schema)
         self.assertIn("Can't pickle", str(ec.exception))
 
-    def test_old_subclassing_attribute(self):
+    def test_deprecated_check_schema_method(self):
 
         with warnings.catch_warnings(record=True) as ctx:
             warnings.simplefilter("always")
 
-            class OldXMLSchema10(XMLSchema10):
-                BUILDERS = {
-                    'attribute_class': Xsd11Attribute,
-                }
+            self.schema_class.check_schema(self.vh_schema)
 
             self.assertEqual(len(ctx), 1, "Expected one import warning")
-            self.assertIn("'BUILDERS' will be removed in v2.0", 
str(ctx[0].message))
+            self.assertIn("check_schema() class method will be removed in 
v3.0",
+                          str(ctx[0].message))
 
-        self.assertIs(OldXMLSchema10.xsd_attribute_class, Xsd11Attribute)
-
-        name = OldXMLSchema10.meta_schema.__class__.__name__
-        self.assertEqual(name, 'MetaXMLSchema10')
-        self.assertNotIn(name, globals())
+        with self.assertRaises(RuntimeError):
+            self.schema_class.meta_schema.check_schema(self.vh_schema)
 
     def test_default_namespace_mapping__issue_266(self):
         schema_file = self.casepath('issues/issue_266/issue_266b-1.xsd')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/tox.ini new/xmlschema-2.1.1/tox.ini
--- old/xmlschema-2.1.0/tox.ini 2022-08-12 16:17:37.000000000 +0200
+++ new/xmlschema-2.1.1/tox.ini 2022-10-01 15:42:01.000000000 +0200
@@ -44,7 +44,7 @@
 
 [testenv:mypy-py37]
 deps =
-    mypy==0.971
+    mypy==0.981
     elementpath==3.0.1
     lxml-stubs
     jinja2
@@ -53,7 +53,7 @@
 
 [testenv:mypy-py{38,39,310,311}]
 deps =
-    mypy==0.971
+    mypy==0.981
     elementpath==3.0.1
     lxml-stubs
     jinja2
@@ -74,7 +74,7 @@
     elementpath>=3.0.0, <4.0.0
     lxml
     jinja2
-    mypy==0.971
+    mypy==0.981
     lxml-stubs
 commands =
     pytest tests -ra
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/xmlschema/__init__.py 
new/xmlschema-2.1.1/xmlschema/__init__.py
--- old/xmlschema-2.1.0/xmlschema/__init__.py   2022-09-25 09:58:42.000000000 
+0200
+++ new/xmlschema-2.1.1/xmlschema/__init__.py   2022-10-01 15:42:01.000000000 
+0200
@@ -31,7 +31,7 @@
     XsdComponent, XsdType, XsdElement, XsdAttribute
 )
 
-__version__ = '2.1.0'
+__version__ = '2.1.1'
 __author__ = "Davide Brunato"
 __contact__ = "[email protected]"
 __copyright__ = "Copyright 2016-2022, SISSA"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/xmlschema/validators/facets.py 
new/xmlschema-2.1.1/xmlschema/validators/facets.py
--- old/xmlschema-2.1.0/xmlschema/validators/facets.py  2022-07-18 
16:19:15.000000000 +0200
+++ new/xmlschema-2.1.1/xmlschema/validators/facets.py  2022-10-01 
18:27:11.000000000 +0200
@@ -754,14 +754,16 @@
 
 
 # noinspection PyUnusedLocal
[email protected](XsdAssertionXPathParser.function('last', 
nargs=0))
-def evaluate_last(self, context=None):  # type: ignore[no-untyped-def]
[email protected](  # type: ignore[no-untyped-def]
+    XsdAssertionXPathParser.function('last', nargs=0))
+def evaluate_last(self, context=None):
     raise self.missing_context("context item size is undefined")
 
 
 # noinspection PyUnusedLocal
[email protected](XsdAssertionXPathParser.function('position', 
nargs=0))
-def evaluate_position(self, context=None):  # type: ignore[no-untyped-def]
[email protected](  # type: ignore[no-untyped-def]
+    XsdAssertionXPathParser.function('position', nargs=0))
+def evaluate_position(self, context=None):
     raise self.missing_context("context item position is undefined")
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/xmlschema/validators/schemas.py 
new/xmlschema-2.1.1/xmlschema/validators/schemas.py
--- old/xmlschema-2.1.0/xmlschema/validators/schemas.py 2022-09-25 
09:58:42.000000000 +0200
+++ new/xmlschema-2.1.1/xmlschema/validators/schemas.py 2022-10-01 
15:42:01.000000000 +0200
@@ -106,23 +106,6 @@
         assert bases, "a base class is mandatory"
         base_class = bases[0]
 
-        # For backward compatibility (will be removed in v2.0)
-        if 'BUILDERS' in dict_:
-            msg = "'BUILDERS' will be removed in v2.0, provide the appropriate 
" \
-                  "attributes instead (e.g. xsd_element_class = Xsd11Element)"
-            warnings.warn(msg, DeprecationWarning, stacklevel=1)
-
-            for k, v in dict_['BUILDERS'].items():
-                if k == 'simple_type_factory':
-                    dict_['simple_type_factory'] = staticmethod(v)
-                    continue
-
-                attr_name = 'xsd_{}'.format(k)
-                if not hasattr(base_class, attr_name):
-                    continue
-                elif getattr(base_class, attr_name) is not v:
-                    dict_[attr_name] = v
-
         if isinstance(dict_.get('meta_schema'), str):
             # Build a new meta-schema class and register it into module's 
globals
             meta_schema_file: str = dict_.pop('meta_schema')
@@ -989,8 +972,10 @@
         """
         if cls.meta_schema is None:
             raise XMLSchemaRuntimeError(_("meta-schema unavailable for %r") % 
cls)
-        elif not cls.meta_schema.maps.types:
-            cls.meta_schema.maps.build()
+
+        msg = f"check_schema() class method will be removed in v3.0, use " \
+              f"{cls.__name__}.meta_schema instead for validating XSD data."
+        warnings.warn(msg, DeprecationWarning, stacklevel=1)
 
         for error in cls.meta_schema.iter_errors(schema.source, 
namespaces=namespaces):
             raise error
@@ -1688,7 +1673,8 @@
                  use_defaults: bool = True,
                  namespaces: Optional[NamespacesType] = None,
                  max_depth: Optional[int] = None,
-                 extra_validator: Optional[ExtraValidatorType] = None) -> None:
+                 extra_validator: Optional[ExtraValidatorType] = None,
+                 allow_empty: bool = True) -> None:
         """
         Validates an XML data against the XSD schema/component instance.
 
@@ -1709,10 +1695,12 @@
         element, with the XML element as 1st argument and the corresponding 
XSD \
         element as 2nd argument. It can be also a generator function and has 
to \
         raise/yield :exc:`XMLSchemaValidationError` exceptions.
+        :param allow_empty: for default providing a path argument empty 
selections \
+        of XML data are allowed. Provide `False` to generate a validation 
error.
         :raises: :exc:`XMLSchemaValidationError` if the XML data instance is 
invalid.
         """
-        for error in self.iter_errors(source, path, schema_path, use_defaults,
-                                      namespaces, max_depth, extra_validator):
+        for error in self.iter_errors(source, path, schema_path, use_defaults, 
namespaces,
+                                      max_depth, extra_validator, allow_empty):
             raise error
 
     def is_valid(self, source: Union[XMLSourceType, XMLResource],
@@ -1721,13 +1709,14 @@
                  use_defaults: bool = True,
                  namespaces: Optional[NamespacesType] = None,
                  max_depth: Optional[int] = None,
-                 extra_validator: Optional[ExtraValidatorType] = None) -> bool:
+                 extra_validator: Optional[ExtraValidatorType] = None,
+                 allow_empty: bool = True) -> bool:
         """
         Like :meth:`validate` except that does not raise an exception but 
returns
         ``True`` if the XML data instance is valid, ``False`` if it is invalid.
         """
-        error = next(self.iter_errors(source, path, schema_path, use_defaults,
-                                      namespaces, max_depth, extra_validator), 
None)
+        error = next(self.iter_errors(source, path, schema_path, use_defaults, 
namespaces,
+                                      max_depth, extra_validator, 
allow_empty), None)
         return error is None
 
     def iter_errors(self, source: Union[XMLSourceType, XMLResource],
@@ -1736,7 +1725,8 @@
                     use_defaults: bool = True,
                     namespaces: Optional[NamespacesType] = None,
                     max_depth: Optional[int] = None,
-                    extra_validator: Optional[ExtraValidatorType] = None) \
+                    extra_validator: Optional[ExtraValidatorType] = None,
+                    allow_empty: bool = True) \
             -> Iterator[XMLSchemaValidationError]:
         """
         Creates an iterator for the errors generated by the validation of an 
XML data against
@@ -1784,9 +1774,9 @@
         else:
             selector = resource.iter_depth(mode=3, nsmap=namespaces, 
ancestors=ancestors)
 
+        elem: Optional[Element] = None
         for elem in selector:
             if elem is resource.root:
-                xsd_element = schema.get_element(elem.tag, 
namespaces=namespaces)
                 if resource.lazy_depth:
                     kwargs['level'] = 0
                     kwargs['identities'] = {}
@@ -1809,8 +1799,7 @@
 
                     prev_ancestors = ancestors[:]
 
-                xsd_element = schema.get_element(elem.tag, schema_path, 
namespaces)
-
+            xsd_element = schema.get_element(elem.tag, schema_path, namespaces)
             if xsd_element is None:
                 if XSI_TYPE in elem.attrib:
                     xsd_element = self.create_element(name=elem.tag)
@@ -1826,6 +1815,12 @@
                     yield result
                 else:
                     del result
+        else:
+            if elem is None and not allow_empty:
+                assert path is not None
+                reason = _("the provided path selects nothing to validate")
+                yield schema.validation_error('lax', reason, None, resource, 
namespaces)
+                return
 
         if kwargs['identities'] is not identities:
             identity: XsdIdentity
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/xmlschema.egg-info/PKG-INFO 
new/xmlschema-2.1.1/xmlschema.egg-info/PKG-INFO
--- old/xmlschema-2.1.0/xmlschema.egg-info/PKG-INFO     2022-09-25 
10:00:21.000000000 +0200
+++ new/xmlschema-2.1.1/xmlschema.egg-info/PKG-INFO     2022-10-01 
19:02:18.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: xmlschema
-Version: 2.1.0
+Version: 2.1.1
 Summary: An XML Schema validator and decoder
 Home-page: https://github.com/sissaschool/xmlschema
 Author: Davide Brunato
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xmlschema-2.1.0/xmlschema.egg-info/SOURCES.txt 
new/xmlschema-2.1.1/xmlschema.egg-info/SOURCES.txt
--- old/xmlschema-2.1.0/xmlschema.egg-info/SOURCES.txt  2022-09-25 
10:00:21.000000000 +0200
+++ new/xmlschema-2.1.1/xmlschema.egg-info/SOURCES.txt  2022-10-01 
19:02:18.000000000 +0200
@@ -67,6 +67,7 @@
 tests/test_cases/examples/stockquote/stockquoteservice.wsdl
 tests/test_cases/examples/vehicles/bikes.xsd
 tests/test_cases/examples/vehicles/cars.xsd
+tests/test_cases/examples/vehicles/invalid.xsd
 tests/test_cases/examples/vehicles/types.xsd
 tests/test_cases/examples/vehicles/vehicles-1_error.json
 tests/test_cases/examples/vehicles/vehicles-1_error.xml

Reply via email to