Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What version of XPath is implemented in XML::LibXML?

Does anybody know which version of the XPath specification has been implemented in XML::LibMXL?

Or more to the point, where can I find a description of the XPath functions that I can use in LibXML?

For example, I tried something like

$dcDOM->findvalue('//dc:identifier[contains(@xsi:type,"URI")]');

which seems to work fine, but

$dcDOM->findvalue('//dc:identifier[matches(@xsi:type,"URI")]');

does not.

From that one has to assume that it supports at most XPath 1.0 or some subset of 1.0/2.0 .

Is there a neat page where everything is listed and described?

like image 336
jackthehipster Avatar asked Oct 02 '14 14:10

jackthehipster


3 Answers

As you surmised from your probe, XML::LibXML supports XPath 1.0 (not 2.0).

Generally speaking, there is no way in XPath itself to ascertain the version other than through such probes. XSLT, on the other hand, provides system-property('xsl:version') for identifying version information.

Going the source heritage route: XML::LibXML is based on libxml2, which implements XPath 1.0, as stated right on the Libxml2 homepage:

Libxml2 implements a number of existing standards related to markup languages:

     XML Path Language (XPath) 1.0: http://www.w3.org/TR/xpath

You might ask Why doesn't libxml2 support XPath 2.0? or read an old post from maintainer Daniel Veillard that says that XPath 2.0 spec is "far too big and intrusive," but the bottom line remains: XML::LibXML supports XPath 1.0, not 2.0.

like image 128
kjhughes Avatar answered Oct 23 '22 04:10

kjhughes


XML::LibXML is an interface to libxml, so you would need to find out what version of that you have installed. How you do that depends on your OS, but you could check the version of xsltproc or xmllint, e.g.:

$ xsltproc --version
Using libxml 20900, libxslt 10128 and libexslt 817
xsltproc was compiled against libxml 20900, libxslt 10128 and libexslt 817
libxslt 10128 was compiled against libxml 20900
libexslt 817 was compiled against libxml 20900

So I've got libxml v2.2.9.

According to the source of all wisdom, Wikipedia, libxml2 only implements XPath 1.0.

like image 2
i alarmed alien Avatar answered Oct 23 '22 04:10

i alarmed alien


Ok, this is not the 100% answer, but according to https://stackoverflow.com/a/10655581/2740187 (from 2012) libxml only supports XPath 1.0, and the supported string functions are described here: http://www.w3.org/TR/xpath/#section-String-Functions.

like image 1
jackthehipster Avatar answered Oct 23 '22 05:10

jackthehipster