Thanks Mike and Andrew,
 
Finally with the following modification works  :

String strXpath = "math:pow(2,2)";
Processor proc =new Processor(true);
XPathCompiler xpath = proc.newXPathCompiler();
xpath.setLanguageVersion("3.0");
xpath.declareNamespace("math",
http://www.w3.org/2005/xpath-functions/math);

Best Regards,
Andrea
 
2013/3/6 Michael Kay <mike@saxonica.com>
I think there are two issues here.

Firstly, 3.0 functionality does need to be explicitly enabled. You can do that on the XPathCompiler: xpath.setLanguageVersion("3.0").

Secondly, the new math functions are in a special namespace (the only explanation I can offer for this is that it was designed by a committee). You need to use this namespace when calling the functions. In fact, the one up-side of the fact that they are in a special namespace is that a conformant 2.0 processor can offer these as extension functions, and I think therefore you can call them from Saxon without enabling 3.0, provided you get the namespace right.

Michael Kay
Saxonica




On 06/03/2013 11:48, Andrea Carlini wrote:
Hi,
 
I'm trying to test XPath 3.0 math functions but I'm getting the Unknown system function error:
  

String strXpath = "pow(2,2)";
Processor proc =

new Processor(false);
XPathCompiler xpath = proc.newXPathCompiler();
DocumentBuilder docBuild = proc.newDocumentBuilder();
docBuild.setLineNumbering(
true);
docBuild.setWhitespaceStrippingPolicy(WhitespaceStrippingPolicy.
ALL);
XdmNode source = docBuild.build (
new StreamSource( new StringReader (strXML)));
XPathSelector selector = xpath.compile(strXpath).load();
selector.setContextItem(source);
XdmValue result = selector.evaluate();
Returning :
net.sf.saxon.s9api.SaxonApiException: Unknown system function pow()
 
I'm using my licensed version of SaxonPE 9.4.
 
It seems that by default the compiler is using XPath 2.0, is there any settings to alter in order to use the 3.0 extensions ?
 
Thanks in advance and best regards.
Andrea


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help