01: package net.sf.saxon.functions;
02:
03: import net.sf.saxon.expr.Expression;
04: import net.sf.saxon.expr.StaticContext;
05: import net.sf.saxon.expr.StaticProperty;
06: import net.sf.saxon.expr.XPathContext;
07: import net.sf.saxon.om.Item;
08: import net.sf.saxon.trans.XPathException;
09: import net.sf.saxon.value.IntegerValue;
10:
11: public class Position extends SystemFunction {
12:
13: /**
14: * preEvaluate: this method suppresses compile-time evaluation by doing nothing
15: * (because the value of the expression depends on the runtime context)
16: */
17:
18: public Expression preEvaluate(StaticContext env) {
19: return this ;
20: }
21:
22: /**
23: * Evaluate in a general context
24: */
25:
26: public Item evaluateItem(XPathContext c) throws XPathException {
27: return new IntegerValue(c.getContextPosition());
28: }
29:
30: /**
31: * Determine the intrinsic dependencies
32: */
33:
34: public int getIntrinsicDependencies() {
35: return StaticProperty.DEPENDS_ON_POSITION;
36: }
37: }
38:
39: //
40: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
41: // you may not use this file except in compliance with the License. You may obtain a copy of the
42: // License at http://www.mozilla.org/MPL/
43: //
44: // Software distributed under the License is distributed on an "AS IS" basis,
45: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
46: // See the License for the specific language governing rights and limitations under the License.
47: //
48: // The Original Code is: all this file.
49: //
50: // The Initial Developer of the Original Code is Michael H. Kay.
51: //
52: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
53: //
54: // Contributor(s): none.
55: //
|