Skip to content

Commit

Permalink
Fix global simple type naming (issue #278)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed Dec 23, 2021
1 parent dab51b7 commit 9dd71b6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
CHANGELOG
*********

`v1.9.2`_ (2021-12-23)
======================
* Fix for global simple type naming (issue #278)

`v1.9.1`_ (2021-12-08)
======================
* Improve error reporting for encoded data (issue #275)
Expand Down Expand Up @@ -505,3 +509,4 @@ v0.9.6 (2017-05-05)
.. _v1.8.2: https://github.com/brunato/xmlschema/compare/v1.8.1...v1.8.2
.. _v1.9.0: https://github.com/brunato/xmlschema/compare/v1.8.2...v1.9.0
.. _v1.9.1: https://github.com/brunato/xmlschema/compare/v1.9.0...v1.9.1
.. _v1.9.2: https://github.com/brunato/xmlschema/compare/v1.9.1...v1.9.2
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
# The short X.Y version.
version = '1.9'
# The full version, including alpha/beta/rc tags.
release = '1.9.1'
release = '1.9.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
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-12-08'
softwareVersion: v1.9.1
releaseDate: '2021-12-23'
softwareVersion: v1.9.2
developmentStatus: stable
platforms:
- linux
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name='xmlschema',
version='1.9.1',
version='1.9.2',
packages=find_packages(include=['xmlschema', 'xmlschema.*']),
include_package_data=True,
entry_points={
Expand Down
2 changes: 1 addition & 1 deletion xmlschema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
XsdComponent, XsdType, XsdElement, XsdAttribute
)

__version__ = '1.9.1'
__version__ = '1.9.2'
__author__ = "Davide Brunato"
__contact__ = "brunato@sissa.it"
__copyright__ = "Copyright 2016-2021, SISSA"
Expand Down
3 changes: 1 addition & 2 deletions xmlschema/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,7 @@ def is_loaded(self) -> bool:
"""Returns `True` if the XML text of the data source is loaded."""
return self._text is not None

def iter(self, tag: Optional[str] = None,
nsmap: Union[None, List[Tuple[str, str]], MutableMapping[str, str]] = None) \
def iter(self, tag: Optional[str] = None, nsmap: Optional[NsmapType] = None) \
-> Iterator[ElementType]:
"""
XML resource tree iterator. The iteration of a lazy resource
Expand Down
10 changes: 5 additions & 5 deletions xmlschema/validators/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def simple_type_factory(self, elem: ElementType,
try:
child = elem[1]
except IndexError:
self.parse_error("(restriction | list | union) expected", elem)
schema.parse_error("(restriction | list | union) expected", elem)
return cast(XsdSimpleType, self.maps.types[XSD_ANY_SIMPLE_TYPE])

xsd_type: XsdSimpleType
Expand All @@ -802,21 +802,21 @@ def simple_type_factory(self, elem: ElementType,
elif child.tag == XSD_UNION:
xsd_type = self.xsd_union_class(child, schema, parent)
else:
self.parse_error("(restriction | list | union) expected", elem)
schema.parse_error("(restriction | list | union) expected", elem)
return cast(XsdSimpleType, self.maps.types[XSD_ANY_SIMPLE_TYPE])

if annotation is not None:
xsd_type._annotation = annotation

try:
xsd_type.name = get_qname(self.target_namespace, elem.attrib['name'])
xsd_type.name = get_qname(schema.target_namespace, elem.attrib['name'])
except KeyError:
if parent is None:
self.parse_error("missing attribute 'name' in a global simpleType", elem)
schema.parse_error("missing attribute 'name' in a global simpleType", elem)
xsd_type.name = 'nameless_%s' % str(id(xsd_type))
else:
if parent is not None:
self.parse_error("attribute 'name' not allowed for a local simpleType", elem)
schema.parse_error("attribute 'name' not allowed for a local simpleType", elem)
xsd_type.name = None

if 'final' in elem.attrib:
Expand Down

0 comments on commit 9dd71b6

Please sign in to comment.