Does libxml2 support XPath 2.0 or not?

前端 未结 4 1081
梦毁少年i
梦毁少年i 2020-12-17 18:07

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

相关标签:
4条回答
  • 2020-12-17 18:21

    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

    0 讨论(0)
  • 2020-12-17 18:22

    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.

    0 讨论(0)
  • 2020-12-17 18:36

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

    0 讨论(0)
  • 2020-12-17 18:37

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

    0 讨论(0)
提交回复
热议问题