Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New major release v2.0 #319

Merged
merged 18 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test-xmlschema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ jobs:
- name: Lint with mypy if Python version != 3.7
if: ${{ matrix.python-version != '3.7' }}
run: |
pip install mypy==0.950 elementpath==2.5.1 lxml-stubs
pip install mypy==0.950 elementpath==3.0.0 lxml-stubs
mypy --show-error-codes --strict xmlschema
- name: Lint with mypy if Python version == 3.7
if: ${{ matrix.python-version == '3.7' }}
run: |
pip install mypy==0.961 elementpath==2.5.3 lxml-stubs
pip install mypy==0.961 elementpath==3.0.0 lxml-stubs
mypy --show-error-codes --no-warn-redundant-casts --no-warn-unused-ignores --strict xmlschema
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CHANGELOG
*********

`v2.0.0`_ (2022-07-18)
======================
* Refactor XPath interface for the full XPath node implementation of elementpath v3.0
* Fix BadgerFishConverter with mixed content (issue #315)
* Improve get() and set() of DataElement (issue #314)

`v1.11.3`_ (2022-06-24)
=======================
* Fix invalid element not detected with empty particle (issue #306)
Expand Down Expand Up @@ -543,3 +549,4 @@ v0.9.6 (2017-05-05)
.. _v1.11.1: https://github.com/brunato/xmlschema/compare/v1.11.0...v1.11.1
.. _v1.11.2: https://github.com/brunato/xmlschema/compare/v1.11.1...v1.11.2
.. _v1.11.3: https://github.com/brunato/xmlschema/compare/v1.11.2...v1.11.3
.. _v2.0.0: https://github.com/brunato/xmlschema/compare/v1.11.3...v2.0.0
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
# built documents.
#
# The short X.Y version.
version = '1.11'
version = '2.0'
# The full version, including alpha/beta/rc tags.
release = '1.11.3'
release = '2.0.0'

# 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: '2022-06-24'
softwareVersion: v1.11.3
releaseDate: '2022-07-18'
softwareVersion: v2.0.0
developmentStatus: stable
platforms:
- linux
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setuptools
tox
coverage
elementpath>=2.5.0, <3.0.0
elementpath>=3.0.0, <4.0.0
lxml
jinja2
memory_profiler
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name='xmlschema',
version='1.11.3',
version='2.0.0',
packages=find_packages(include=['xmlschema', 'xmlschema.*']),
include_package_data=True,
entry_points={
Expand All @@ -29,13 +29,13 @@
]
},
python_requires='>=3.7',
install_requires=['elementpath>=2.5.0, <3.0.0'],
install_requires=['elementpath>=3.0.0, <4.0.0'],
extras_require={
'codegen': ['elementpath>=2.5.0, <3.0.0', 'jinja2'],
'dev': ['tox', 'coverage', 'lxml', 'elementpath>=2.5.0, <3.0.0',
'codegen': ['elementpath>=3.0.0, <4.0.0', 'jinja2'],
'dev': ['tox', 'coverage', 'lxml', 'elementpath>=3.0.0, <4.0.0',
'memory_profiler', 'Sphinx', 'sphinx_rtd_theme', 'jinja2',
'flake8', 'mypy', 'lxml-stubs'],
'docs': ['elementpath>=2.5.0, <3.0.0', 'Sphinx', 'sphinx_rtd_theme', 'jinja2']
'docs': ['elementpath>=3.0.0, <4.0.0', 'Sphinx', 'sphinx_rtd_theme', 'jinja2']
},
author='Davide Brunato',
author_email='brunato@sissa.it',
Expand Down
54 changes: 0 additions & 54 deletions tests/check_etree_import.py

This file was deleted.

8 changes: 4 additions & 4 deletions tests/check_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def test_choice_type(value):
def import_package():
# Imports of packages used by xmlschema that
# have a significant memory usage impact.
import decimal
from urllib.error import URLError
import lxml.etree
import elementpath
import decimal # noqa
from urllib.error import URLError # noqa
import lxml.etree # noqa
import elementpath # noqa

import xmlschema
return xmlschema
Expand Down
2 changes: 0 additions & 2 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ def load_tests(loader, tests, pattern):
tests.addTests(loader.discover(start_dir=tests_dir, pattern=pattern))
return tests

tests.addTests(loader.discover(start_dir=tests_dir, pattern="test_etree.py"))
tests.addTests(loader.discover(start_dir=tests_dir, pattern="test_etree_import.py"))
tests.addTests(loader.discover(start_dir=tests_dir, pattern="test_helpers.py"))
tests.addTests(loader.discover(start_dir=tests_dir, pattern="test_namespaces.py"))
tests.addTests(loader.discover(start_dir=tests_dir, pattern="test_resources.py"))
Expand Down
1 change: 0 additions & 1 deletion tests/test_cases/examples/collection/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ class CollectionBinding(DataElement, metaclass=DataBindingMeta):

class PersonBinding(DataElement, metaclass=DataBindingMeta):
xsd_element = schema.elements['person']

15 changes: 15 additions & 0 deletions tests/test_cases/issues/issue_311/correct_no_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<ns0:kPartModel xmlns:ns0="http://www.ludd21.com/kPartModel" modelName="manysingulars" otherattribute="">
<ns0:kPartsPiece pieceName="pieceknit_layer1">
<ns0:kPartsList>
<ns0:castOnPartSeg nextsnum="1" partNumber="0">
<ns0:baseSeg start="9.73143 0.00000" end="17.73188 0.00000" />
</ns0:castOnPartSeg>
<ns0:joinPart nextsnum="3" previousnum="0 " partNumber="1" >
<ns0:baseSeg start="9.88173 -11.82912" end="25.27907 -11.82912" />
</ns0:joinPart>
<ns0:joinPart nextsnum="1" previousnum="0" partNumber="3">
<ns0:baseSeg start="9.98452 -19.91844" end="56.48310 -19.91844" />
</ns0:joinPart>
</ns0:kPartsList>
</ns0:kPartsPiece>
</ns0:kPartModel>
15 changes: 15 additions & 0 deletions tests/test_cases/issues/issue_311/incorrect_with_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<ns0:kPartModel xmlns:ns0="http://www.ludd21.com/kPartModel" modelName="manysingulars" otherattribute="">
<ns0:kPartsPiece pieceName="pieceknit_layer1">
<ns0:kPartsList>
<ns0:castOnPartSeg nextsnum="1 3" partNumber="0">
<ns0:baseSeg start="9.73143 0.00000" end="17.73188 0.00000" />
</ns0:castOnPartSeg>
<ns0:joinPart nextsnum="3" previousnum="0 " partNumber="1" >
<ns0:baseSeg start="9.88173 -11.82912" end="25.27907 -11.82912" />
</ns0:joinPart>
<ns0:joinPart nextsnum="1" previousnum="0" partNumber="3">
<ns0:baseSeg start="9.98452 -19.91844" end="56.48310 -19.91844" />
</ns0:joinPart>
</ns0:kPartsList>
</ns0:kPartsPiece>
</ns0:kPartModel>
122 changes: 122 additions & 0 deletions tests/test_cases/issues/issue_311/kPartModel_reduit_issue.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.1" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace = "http://www.ludd21.com/kPartModel"
xmlns = "http://www.ludd21.com/kPartModel"
elementFormDefault="qualified"
vc:minVersion = "1.1"
xpathDefaultNamespace="##targetNamespace"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
>

<xs:element name="kPartModel">
<xs:complexType>
<xs:sequence>
<xs:element ref="kPartsPiece" minOccurs="1" maxOccurs = "unbounded"/>
</xs:sequence>
<xs:attribute name="modelName" type="xs:NCName" use = "required"/>
<xs:attribute name= "otherattribute" type="xs:string" default = ""/>
</xs:complexType>

<!--piecename must be unique within kpModel-->
<xs:unique name= "kPartModel">
<xs:selector xpath="*"/>
<xs:field xpath= "@pieceName"/>
</xs:unique>
</xs:element>

<xs:element name="kPartsPiece">
<xs:complexType>
<xs:sequence>
<xs:element ref= "kPartsList"/>
</xs:sequence>
<xs:attribute name="pieceName" type="xs:NCName"/>
<!-- nextsnum must contain valid partNumbers -->
<xs:assert id = "test-previous" test = "every $x in data(kPartsList/*/@previousnum) satisfies some $part in kPartsList/* satisfies $part/@partNumber = $x"/>
<xs:assert id = "test-nexts" test = "every $x in data(kPartsList/*/@nextsnum) satisfies some $part in kPartsList/* satisfies $part/@partNumber = $x"/>
</xs:complexType>
<!-- @partNumber is unique across kPartsList -->
<xs:unique id = "unique-partNumber" name= "kPartsList">
<xs:selector xpath="*/*"/>
<xs:field xpath= "@partNumber"/>
</xs:unique>
</xs:element>

<xs:element name = "kPartsList" >
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs= "0" maxOccurs = "unbounded">
<xs:element ref = "castOnPartSeg" />
<xs:element ref = "castOnPartPoint" />
<xs:element ref = "joinPart"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="castOnPartPoint">
<xs:complexType>
<xs:sequence>
<xs:element ref ="basePoint"/>
</xs:sequence>
<xs:attribute name ="nextsnum" type = "kpRefsList" use = "required"/>
<xs:attribute name = "partNumber" type = "xs:nonNegativeInteger" use = "required"/>
</xs:complexType>
</xs:element>

<xs:element name="castOnPartSeg">
<xs:complexType>
<xs:sequence>
<xs:element ref ="baseSeg"/>
</xs:sequence>
<xs:attribute name = "nextsnum" type = "kpRefsList" use = "required"/>
<xs:attribute name = "partNumber" type = "xs:nonNegativeInteger" use = "required"/>
</xs:complexType>
</xs:element>

<xs:element name="joinPart">
<xs:complexType>
<xs:sequence>
<xs:element ref ="baseSeg"/>
</xs:sequence>
<xs:attribute name ="nextsnum" type = "kpRefsList" use = "required"/>
<xs:attribute name ="previousnum" type = "kpRefsList" use = "required"/>
<xs:attribute name = "partNumber" type = "xs:nonNegativeInteger" use = "required"/>
</xs:complexType>
</xs:element>

<xs:simpleType name = "kpRefsList">
<xs:list itemType= "xs:nonNegativeInteger"/>
</xs:simpleType>

<xs:element name = "basePoint">
<xs:complexType>
<xs:attribute name= "start" type = "point" use = "required"/>
</xs:complexType>
</xs:element>


<xs:element name = "baseSeg">
<xs:complexType>
<xs:attribute name= "start" type = "point" use = "required"/>
<xs:attribute name= "end" type = "point" use = "required"/>
<!--<xs:assert id = "test_base_horizontal" test = "@start[1] = @end[1]"/> -->
</xs:complexType>
</xs:element>


<xs:simpleType name= "point">
<xs:restriction>
<xs:simpleType>
<xs:list itemType = "decimal5digits"/>
</xs:simpleType>
<xs:length value = "2"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name ="decimal5digits">
<xs:restriction base = "xs:decimal">
<xs:fractionDigits value="5"/>
</xs:restriction>
</xs:simpleType>

</xs:schema>
1 change: 1 addition & 0 deletions tests/test_cases/issues/issue_315/issue_315-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<tst:e1 xmlns:tst="http://xmlschema.test/ns" a1="foo">bar</tst:e1>
1 change: 1 addition & 0 deletions tests/test_cases/issues/issue_315/issue_315-2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<tst:e1 xmlns:tst="http://xmlschema.test/ns" a1="foo"></tst:e1>
1 change: 1 addition & 0 deletions tests/test_cases/issues/issue_315/issue_315-3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<tst:e1 xmlns:tst="http://xmlschema.test/ns" a1="foo">bar<e2/></tst:e1>
1 change: 1 addition & 0 deletions tests/test_cases/issues/issue_315/issue_315-4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<tst:e1 xmlns:tst="http://xmlschema.test/ns" a1="foo"><e2/>bar<e2/></tst:e1>
1 change: 1 addition & 0 deletions tests/test_cases/issues/issue_315/issue_315-5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<tst:e1 xmlns:tst="http://xmlschema.test/ns" a1="foo"><e2/>bar</tst:e1>
16 changes: 16 additions & 0 deletions tests/test_cases/issues/issue_315/issue_315_mixed.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xmlschema.test/ns"
xmlns:tst="http://xmlschema.test/ns"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="e1" type="tst:t1"/>
<xs:complexType name="t1">
<xs:complexContent mixed="true">
<xs:restriction base="xs:anyType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="e2" type="xs:string"/>
</xs:choice>
<xs:attribute type="xs:string" name="a1"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
13 changes: 13 additions & 0 deletions tests/test_cases/issues/issue_315/issue_315_simple.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xmlschema.test/ns"
xmlns:tst="http://xmlschema.test/ns"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="e1" type="tst:t1"/>
<xs:complexType name="t1">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="a1"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
6 changes: 4 additions & 2 deletions tests/test_cases/testfiles
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,7 @@ issues/issue_298/issue_298-1.xml -L 'http://xmlschema.test/ns' issue_298.xsd
issues/issue_298/issue_298-2.xml -L 'http://xmlschema.test/ns' issue_298.xsd
issues/issue_306/issue_306.xsd
issues/issue_306/issue_306-alt.xsd
issues/issue_306/issue_306-valid.xml
issues/issue_306/issue_306-invalid.xml --errors=1
issues/issue_311/correct_no_list.xml --version=1.1 --validation-only \
-L 'http://www.ludd21.com/kPartModel' kPartModel_reduit_issue.xsd
issues/issue_311/incorrect_with_list.xml --version=1.1 --validation-only \
-L 'http://www.ludd21.com/kPartModel' kPartModel_reduit_issue.xsd
Loading