1 package com.icl.saxon.functions; 2 import com.icl.saxon.*; 3 import com.icl.saxon.expr.*; 4 5 import java.util.*; 6 7 8 public class Position extends Function { 9 10 13 14 public String getName() { 15 return "position"; 16 }; 17 18 22 23 public int getDataType() { 24 return Value.NUMBER; 25 } 26 27 30 31 public Expression simplify() throws XPathException { 32 checkArgumentCount(0, 0); 33 return this; 34 } 35 36 39 40 public double evaluateAsNumber(Context c) throws XPathException { 41 return (double)c.getContextPosition(); 42 } 43 44 47 48 public Value evaluate(Context c) throws XPathException { 49 return new NumericValue(evaluateAsNumber(c)); 50 } 51 52 55 56 public int getDependencies() { 57 return Context.POSITION; 58 } 59 60 63 64 public Expression reduce(int dep, Context c) throws XPathException { 65 if ((dep & Context.POSITION) != 0) { 66 return new NumericValue(c.getContextPosition()); 67 } else { 68 return this; 69 } 70 } 71 72 } 73 74 75 76 | Popular Tags |