Does libxml2 support XPath 2.0 or not?

99封情书 提交于 2019-12-30 06:11:20

问题


I've tried to use the XPath 2.0 exp //span/string(.) in libxml2, but it doesn't work.
So, my question is: does libxml2 support XPath 2.0 or not?


回答1:


As far as I know -- not. The prevailing majority of XPath 2.0 implementations are part of XSLT 2.0 processors or XQuery processors.




回答2:


According to this 2007 email from the maintainer of libxml2, libxml2 does not, and will not, support XPath 2.0.




回答3:


you might be interested in an XPath 2.0 extension to libxml2 - however, 2 caveats apply: it's work in progress and it's free for non-commercial use only.

hope this helps,

best regards, carsten

ps: i am neither affiliated with the guys working on libx nor have i any personal experience on using it or knowledge beyond the info from their website.




回答4:


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

the XML standard: http://www.w3.org/TR/REC-xml
Namespaces in XML: http://www.w3.org/TR/REC-xml-names/
XML Base: http://www.w3.org/TR/xmlbase/
RFC 2396 : Uniform Resource Identifiers http://www.ietf.org/rfc/rfc2396.txt
XML Path Language (XPath) 1.0: http://www.w3.org/TR/xpath
HTML4 parser: http://www.w3.org/TR/html401/
XML Pointer Language (XPointer) Version 1.0: http://www.w3.org/TR/xptr
XML Inclusions (XInclude) Version 1.0: http://www.w3.org/TR/xinclude/
ISO-8859-x encodings, as well as rfc2044 [UTF-8] and rfc2781 [UTF-16] Unicode encodings, and more if using iconv support
part of SGML Open Technical Resolution TR9401:1997
XML Catalogs Working Draft 06 August 2001: http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
Canonical XML Version 1.0: http://www.w3.org/TR/xml-c14n and the Exclusive XML Canonicalization CR draft http://www.w3.org/TR/xml-exc-c14n
Relax NG, ISO/IEC 19757-2:2003, http://www.oasis-open.org/committees/relax-ng/spec-20011203.html
W3C XML Schemas Part 2: Datatypes REC 02 May 2001
W3C xml:id Working Draft 7 April 2004

Since libxml2 supports XPath 1.0, the syntax is incorrect:

//span/string(.)

Should be:

string(//span/.)

For clarification, the string method is part of XPath 1.0 as well. For future reference:

  • libxml2 supports XPath 1.0

  • Objective-C supports XPath 2.0 via the nodesForXPath method of NSXMLNode in GNUStep/NextStep

The Cocoa implementation uses XPath 2.0, which is a World Wide Web Consortium recommendation.

References

  • NSXML Concepts: XML Glossary

  • NSXML Concepts: Querying an XML Document

  • NSXMLNode: nodesForXPath

  • GNUStep: NSXMLNode Class Documentation

  • GalaXquery

  • PsychoPathXPathProcessor

  • CoreServicesLayer

  • libxml, a.k.a. gnome-xml



来源:https://stackoverflow.com/questions/6586896/does-libxml2-support-xpath-2-0-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!