Some string comparisson does not work inside an xpath expression

Bug #1785022 reported by Daniel Brosnan Blázquez on 2018-08-02
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Undecided
Unassigned

Bug Description

When trying to compare two strings with an operator different than "=" the xpath does not evaluate properly, giving 0 results for structures which contain nodes that would be valid for the comparison expression. For example:
Given the following content of an xml
<nodes>
 <a>test</a>
 <b>test1</b>
</nodes>

and the following python code (attached for better access):
# Import python utilities
import argparse

# Import xml parser
from lxml import etree

if __name__ == "__main__":

    xml = etree.XML("<nodes><a>test</a><b>test1</b></nodes>")
    xpath_xml = etree.XPathEvaluator(xml)

    # Testing = operator
    test = xpath_xml("/nodes/child::*[text() = 'test']")

    assert len(test) == 1

    # Testing = operator
    test = xpath_xml("/nodes/child::*[text() = 'test1']")

    assert len(test) == 1

    # Testing > operator
    test = xpath_xml("/nodes/child::*[text() > 'test']")

    assert len(test) == 1

The python code fails to get the b node when the comparison is ">".

Is this a bug? or it is just not supported?
Note that the xpath evaluator does not raise any error.

Here the information requested for the investigation:
$ python3 lxml_info.py
Python : sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)
lxml.etree : (3, 3, 3, 0)
libxml used : (2, 9, 1)
libxml compiled : (2, 9, 1)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)

Thanks for you support.
Best regards.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers