Fix '//' operator and text() function
- '//' without a left token has to start from the document root, like an absolute path.
This commit is contained in:
parent
e87bba0224
commit
04258f5c43
|
@ -2,6 +2,11 @@
|
|||
CHANGELOG
|
||||
*********
|
||||
|
||||
`v1.2.2`_ (TBD)
|
||||
===============
|
||||
* Fix descendant shortcut operator '//'
|
||||
* Fix text() function
|
||||
|
||||
`v1.2.1`_ (2019-08-30)
|
||||
======================
|
||||
* Hashable XSD datatypes classes
|
||||
|
@ -148,3 +153,4 @@ CHANGELOG
|
|||
.. _v1.1.9: https://github.com/brunato/elementpath/compare/v1.1.8...v1.1.9
|
||||
.. _v1.2.0: https://github.com/brunato/elementpath/compare/v1.1.9...v1.2.0
|
||||
.. _v1.2.1: https://github.com/brunato/elementpath/compare/v1.2.0...v1.2.1
|
||||
.. _v1.2.2: https://github.com/brunato/elementpath/compare/v1.2.1...v1.2.2
|
||||
|
|
|
@ -31,7 +31,7 @@ author = 'Davide Brunato'
|
|||
# The short X.Y version
|
||||
version = '1.2'
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '1.2.1'
|
||||
release = '1.2.2'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#
|
||||
# @author Davide Brunato <brunato@sissa.it>
|
||||
#
|
||||
__version__ = '1.2.1'
|
||||
__version__ = '1.2.2'
|
||||
__author__ = "Davide Brunato"
|
||||
__contact__ = "brunato@sissa.it"
|
||||
__copyright__ = "Copyright 2018-2019, SISSA"
|
||||
|
|
|
@ -724,6 +724,7 @@ def select(self, context=None):
|
|||
if context is None:
|
||||
return
|
||||
elif len(self) == 1:
|
||||
context.item = None
|
||||
for _ in context.iter_descendants(axis='descendant-or-self'):
|
||||
for result in self[0].select(context):
|
||||
yield result
|
||||
|
@ -972,9 +973,7 @@ def evaluate(self, context=None):
|
|||
def select(self, context=None):
|
||||
if context is not None:
|
||||
for item in context.iter_children_or_self():
|
||||
if item is None:
|
||||
yield context.root
|
||||
elif is_text_node(item):
|
||||
if is_text_node(item):
|
||||
yield item
|
||||
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -15,7 +15,7 @@ with open("README.rst") as readme:
|
|||
|
||||
setup(
|
||||
name='elementpath',
|
||||
version='1.2.1',
|
||||
version='1.2.2',
|
||||
packages=['elementpath'],
|
||||
author='Davide Brunato',
|
||||
author_email='brunato@sissa.it',
|
||||
|
|
|
@ -43,7 +43,9 @@ except ImportError:
|
|||
@unittest.skipIf(xmlschema is None, "xmlschema library required.")
|
||||
class XPath2ParserXMLSchemaTest(test_xpath2_parser.XPath2ParserTest):
|
||||
|
||||
schema = xmlschema.XMLSchema('''
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.schema = xmlschema.XMLSchema('''
|
||||
<!-- Dummy schema for testing proxy API -->
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xpath.test/ns">
|
||||
<xs:element name="test_element" type="xs:string"/>
|
||||
|
|
|
@ -464,7 +464,12 @@ class XPath1ParserTest(unittest.TestCase):
|
|||
self.check_select("text()", [], context) # Selects the children
|
||||
self.check_selector("node()", self.etree.XML('<author>Dickens</author>'), ['Dickens'])
|
||||
self.check_selector("text()", self.etree.XML('<author>Dickens</author>'), ['Dickens'])
|
||||
self.check_selector("//self::text()", self.etree.XML('<author>Dickens</author>'), ['Dickens'])
|
||||
|
||||
root = self.etree.XML('<author>Dickens</author>')
|
||||
if self.etree is not lxml_etree:
|
||||
# Skip lxml test because lxml's XPath doesn't include document root
|
||||
self.check_selector("//self::node()", root, [root, root, 'Dickens'])
|
||||
self.check_selector("//self::text()", root, ['Dickens'])
|
||||
|
||||
def test_node_set_id_function(self):
|
||||
# XPath 1.0 id() function: https://www.w3.org/TR/1999/REC-xpath-19991116/#function-id
|
||||
|
|
Loading…
Reference in New Issue