1 package net.sf.saxon.xpath; 2 3 import net.sf.saxon.expr.Expression; 4 import net.sf.saxon.functions.FunctionLibrary; 5 import net.sf.saxon.trans.XPathException; 6 7 import javax.xml.namespace.QName ; 8 import javax.xml.xpath.XPathFunction ; 9 import javax.xml.xpath.XPathFunctionResolver ; 10 11 15 16 public class XPathFunctionLibrary implements FunctionLibrary { 17 18 private XPathFunctionResolver resolver; 19 20 23 24 public XPathFunctionLibrary() { 25 } 26 27 31 32 public void setXPathFunctionResolver(XPathFunctionResolver resolver) { 33 this.resolver = resolver; 34 } 35 36 40 41 public XPathFunctionResolver getXPathFunctionResolver() { 42 return resolver; 43 } 44 45 56 57 public boolean isAvailable(int fingerprint, String uri, String local, int arity) { 58 return false; 59 } 60 61 75 76 public Expression bind(int nameCode, String uri, String local, Expression[] staticArgs) 77 throws XPathException { 78 if (resolver == null) { 79 return null; 80 } 81 QName name = new QName (uri, local); 82 XPathFunction function = resolver.resolveFunction(name, staticArgs.length); 83 if (function == null) { 84 return null; 85 } 86 XPathFunctionCall fc = new XPathFunctionCall(function); 87 fc.setArguments(staticArgs); 88 return fc; 89 } 90 91 98 99 public FunctionLibrary copy() { 100 XPathFunctionLibrary xfl = new XPathFunctionLibrary(); 101 xfl.resolver = resolver; 102 return xfl; 103 } 104 105 106 } 107 108 | Popular Tags |