sissaschool / elementpath

XPath 1.0/2.0/3.0/3.1 parsers and selectors for ElementTree and lxml
MIT License
72 stars 20 forks source link

Error getting attribute names #35

Closed RabbitJackTrade closed 3 years ago

RabbitJackTrade commented 3 years ago

Given this xml: `<?xml version="1.0" encoding="utf-8"?>

some text T1 T1 T1 T1 T1 T2 T2 T2 T2 T2 ` and this code (most recent version of elementpath): `doc = etree.XML(lib.encode()) elementpath.select(doc,'//@*/local-name()')` or `elementpath.select(doc,'//@*/name()')` the output should have been: `attrib1 attrib2 isbn lang isbn lang` Instead I get `ElementPathTypeError: '/' operator at line 1, column 5: [err:XPTY0019] Intermediate step contains an atomic value`
brunato commented 3 years ago

Hi, it's a problem within the select() of wildcard token '' that erroneously resolves the attribute node to its value when is called the shortcut `@`. Found a similar error in another token. Maybe these are typos because in other parts the code is correct.

https://github.com/sissaschool/elementpath/blob/7ac39461b3e98ae98fc00e625d8391141899399e/elementpath/xpath1/xpath1_parser.py#L690-L696

RabbitJackTrade commented 3 years ago

Thanks, brunato. What, then, is the next step?

brunato commented 3 years ago

... fix available with release v2.1.4.

I close the issue, thank you for the reported case.