1 package com.icl.saxon.functions; 2 import com.icl.saxon.*; 3 import com.icl.saxon.om.Namespace; 4 import com.icl.saxon.expr.*; 5 import com.icl.saxon.style.*; 6 7 import java.util.*; 8 9 10 public class ElementAvailable extends Function { 11 12 15 16 public String getName() { 17 return "element-available"; 18 }; 19 20 24 25 public int getDataType() { 26 return Value.BOOLEAN; 27 } 28 29 33 34 public Expression simplify() throws XPathException { 35 checkArgumentCount(1, 1); 36 argument[0] = argument[0].simplify(); 37 if (argument[0] instanceof Value) { 38 return evaluate(null); 39 } 40 return this; 41 } 42 43 46 47 public boolean evaluateAsBoolean(Context c) throws XPathException { 48 String qname = argument[0].evaluateAsString(c); 49 return getStaticContext().isElementAvailable(qname); 50 } 51 52 55 56 public Value evaluate(Context c) throws XPathException { 57 return new BooleanValue(evaluateAsBoolean(c)); 58 } 59 60 63 64 public int getDependencies() { 65 return argument[0].getDependencies(); 66 } 67 68 71 72 public Expression reduce(int dep, Context c) throws XPathException { 73 ElementAvailable f = new ElementAvailable(); 74 f.addArgument(argument[0].reduce(dep, c)); 75 f.setStaticContext(getStaticContext()); 76 return f.simplify(); 77 } 78 79 82 83 98 } 99 100 101 102 | Popular Tags |