title: Using XPath functions in libxml
body: <p>I am trying to evaluate certain XPath expressions with <a href="http://xmlsoft.org/index.html" rel="nofollow">libxml</a> 2.8.0 and am getting error messages with functions. It is not clear to me whether libxml implements the whole or a subset of the XPath specification. Is there any resource clearly identifying what is implemented and how to use it?</p>
  
  <p>In my specific case, one expression I am trying to evaluate is:</p>
  
  <pre><code>/TemporalInformation/RecipeInformation[fn:exists(./ActionToActionRelation[fn:contains(./@actionA,'cook') and fn:exists(./IngredientA[fn:contains(./@classes,'onion')])])]
  </code></pre>
  
  <p>I am using libxml through the XML::LibXML Perl module, but I have also tried my expression with <a href="http://www.xmlsoft.org/examples/#xpath1.c" rel="nofollow">the <code>xpath1.c</code> example</a> tool available from xmlsoft.org, and got the same error messages:</p>
  
  <pre><code>$ ./xpath-tester data/fk.xml "/TemporalInformation/RecipeInformation[fn:exists(.&gt; /ActionToActionRelation[fn:contains(./@actionA,'cook') and fn:exists(./IngredientA[fn:contains(./@classes,'onion')])])]" "fn=http://www.w3.org/2005/xpath-functions"
  xmlXPathCompOpEval: function contains not found
  XPath error : Unregistered function
  xmlXPathCompOpEval: function exists not found
  XPath error : Unregistered function
  XPath error : Invalid expression
  XPath error : Stack usage errror
  Error: unable to evaluate xpath expression "/TemporalInformation/RecipeInformation[fn:exists(./ActionToActionRelation[fn:contains(./@actionA,'cook') and fn:exists(./IngredientA[fn:contains(./@classes,'onion')])])]"
  Usage: ./xpath-tester &lt;xml-file&gt; &lt;xpath-expr&gt; [&lt;known-ns-list&gt;]
  where &lt;known-ns-list&gt; is a list of known namespaces
  in "&lt;prefix1&gt;=&lt;href1&gt; &lt;prefix2&gt;=href2&gt; ..." format
  </code></pre>
  
  <p>I have tried with and without the <code>fn</code> namespace, both with <code>xpath.c</code> and my Perl script, and got the same result.</p>