zepheira / amara

Amara 2.0. Amara XML toolkit is an open-source collection of Python tools for XML processing, not just tools that happen to be written in Python, but tools built from the ground up to use Python idioms and take advantage of the many advantages of Python over other programming languages.
http://wiki.xml3k.org/Amara2
Apache License 2.0
23 stars 9 forks source link

XPath last() function fails #13

Open lmorillas opened 12 years ago

lmorillas commented 12 years ago

XPath last() function doesn't return the last item of a nodeset. When last() function is used in xpath expressions, the result is allways an empty nodeset.

See the test of the test suite:

xml file tests/xslt/borrowed/dh_20000530_01.xml

<nodes>
  <node>a</node>
  <node>b</node>
  <node>c</node>
</nodes>

amara code

 >>> doc = amara.parse('dh_20000530_01.xml')
 >>> doc.xml_select(u'/nodes/node[last()]')
 nodeset()
 >>> doc.xml_select(u'/nodes/node')
 nodeset([<amara.tree.element at 0x236c2d0: name u'node', 0 namespaces, 0 attributes, 1 children>, 
                <amara.tree.element at  0x236c4d0: name u'node', 0 namespaces, 0 attributes, 1 children>, 
                <amara.tree.element at 0x236c9d0: name u'node', 0 namespaces, 0 attributes, 1 children>])