1 package net.sf.saxon.style; 2 3 import net.sf.saxon.expr.Expression; 4 import net.sf.saxon.expr.UserFunctionCall; 5 import net.sf.saxon.functions.FunctionLibrary; 6 import net.sf.saxon.trans.XPathException; 7 8 14 15 public class StylesheetFunctionLibrary implements FunctionLibrary { 16 17 private XSLStylesheet stylesheet; 18 private boolean overriding; 19 20 27 public StylesheetFunctionLibrary(XSLStylesheet sheet, boolean overriding) { 28 this.stylesheet = sheet; 29 this.overriding = overriding; 30 } 31 32 41 42 public boolean isAvailable(int fingerprint, String uri, String local, int arity) { 43 XSLFunction fn = stylesheet.getStylesheetFunction(fingerprint, arity); 44 return (fn != null); 45 } 46 47 65 66 public Expression bind(int nameCode, String uri, String local, Expression[] staticArgs) 67 throws XPathException { 68 int fingerprint = nameCode & 0xfffff; 69 XSLFunction fn = stylesheet.getStylesheetFunction(fingerprint, staticArgs.length); 70 if (fn==null) { 71 return null; 72 } 73 if (fn.isOverriding() != overriding) { 74 return null; 75 } 76 UserFunctionCall fc = new UserFunctionCall(); 77 fn.registerReference(fc); 78 fc.setFunctionNameCode(nameCode); 79 fc.setArguments(staticArgs); 80 fc.setConfirmed(true); 81 return fc; 82 } 83 84 91 92 public FunctionLibrary copy() { 93 return this; 94 } 95 96 } 97 | Popular Tags |