morbac / xmltools

XML Tools plugin for Notepad++
GNU General Public License v3.0
260 stars 57 forks source link

Add support for libxml2 #193

Open haja-fgabriel opened 1 year ago

haja-fgabriel commented 1 year ago

Related to issue #190. I have just discovered that MSXML (5.0 or 6.0; I'm quite unsure about the version XML Tools uses) does not have any function that extracts the line number of a single node without raising a parsing error. We could force an error to get the line and column numbers of a node, but this approach is not desirable.

What I propose instead is to switch to a library (and a parser) that adds the line and column numbers to nodes out of the box. We will figure out how could we manage this external dependency. @morbac what do you think?

Later edit: libxml2 does not support Unicode characters unfortunately, and MSXMLWrapper::xpathEvaluate expects that the XPath is a std::wstring. @morbac should we convert the XPath to UTF-8, as the data is read as regular chars anyway?

haja-fgabriel commented 1 year ago

We could implement instead a parser for evaluating XPaths in the current XML (especially considering the way MSXMLWrapper::xpathEvaluate currently works, by parsing the whole file), but implementing support for XPath (especially 2.0 and up) would be very complicated