From: Adam R. <ad...@ex...> - 2018-10-03 07:20:31
|
The name type is not used for all operations. It is only *sometimes* used when we need to know the type of the node. So you cannot rely on it always being set correctly. On Wed, 12 Sep 2018 at 01:49, Stanislav <st...@gm...> wrote: > Hi guys, > > Stanislav here (I am new to this list). > It started with this: > * [Exist-open] Are more elaborate xpath expressions allowed in Lucene's > index config <text match='...'/> > <https://sourceforge.net/p/exist/mailman/message/36392026/>* > > Then I went to clone, build and then debug/trace exist, > and it turned out NodePath and QName are not suited to handle 'more > elaborate xpath expressions' > > I started modifying them (locally). > I introduced (a minimalist) change - namely that QName should honor its > nameType which could be any of { UNKNOWN, ELEMENT, ATTRIBUTE } > and changed QName.compareTo() and .equals() methods to compare also this > field. > Alas, this prevented exist from normal startup as line 214 of > ConfigurationImpl.java consists of: > > Node attr = attrs.getNamedItem("key"); > > which in turn invokes NamedNodeMapImpl.getNamedItem(): > > @Override > public Node getNamedItem(final String name) { > try { > return getNamedItem(new QName(name)); > } catch (final QName.IllegalQNameException e) { > throw new DOMException(DOMException.INVALID_CHARACTER_ERR, "Invalid name"); > } > } > > And the problem is the newly created new QName(name) has its nameType set > (by default) to ELEMENT, > while the one stored in the map is of nameType ATTRIBUTE -- and the newly > modified QName.equals() method discerns between those two, as their > nameType(s) are different. > > I am not sure what would be the right question in this situation, so I > will try with: > How come? > > Kindly, > /Stanislav > > > > > _______________________________________________ > Exist-development mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-development > -- Adam Retter eXist Core Developer { United Kingdom / United States } ad...@ex... |