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:
10: /**
11: * Implement the XSLT current() function
12: */
13:
14: public class Current extends SystemFunction implements XSLTFunction {
15:
16: /**
17: * Get the static properties of this expression (other than its type). The result is
18: * bit-signficant. These properties are used for optimizations. In general, if
19: * property bit is set, it is true, but if it is unset, the value is unknown.
20: */
21:
22: public int computeSpecialProperties() {
23: return StaticProperty.CONTEXT_DOCUMENT_NODESET
24: | StaticProperty.SINGLE_DOCUMENT_NODESET
25: | StaticProperty.ORDERED_NODESET
26: | StaticProperty.NON_CREATIVE;
27: }
28:
29: /**
30: * preEvaluate: this method suppresses compile-time evaluation by doing nothing
31: * (because the value of the expression depends on the runtime context)
32: */
33:
34: public Expression preEvaluate(StaticContext env) {
35: return this ;
36: }
37:
38: /**
39: * Evaluate in a general context
40: */
41:
42: public Item evaluateItem(XPathContext c) throws XPathException {
43: throw new AssertionError(
44: "current() function should have been rewritten at compile time");
45: // We rely on the expression being statically rewritten so that current() is promoted to the top level.
46: //return c.getContextItem();
47: //return c.getCurrentStylesheetItem();
48: }
49:
50: /**
51: * Determine the dependencies
52: */
53:
54: public int getIntrinsicDependencies() {
55: return StaticProperty.DEPENDS_ON_CURRENT_ITEM;
56: }
57:
58: }
59:
60: //
61: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
62: // you may not use this file except in compliance with the License. You may obtain a copy of the
63: // License at http://www.mozilla.org/MPL/
64: //
65: // Software distributed under the License is distributed on an "AS IS" basis,
66: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
67: // See the License for the specific language governing rights and limitations under the License.
68: //
69: // The Original Code is: all this file.
70: //
71: // The Initial Developer of the Original Code is Michael H. Kay.
72: //
73: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
74: //
75: // Contributor(s): none.
76: //
|