01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: /*
17: * $Id: ExpressionContext.java,v 1.8 2004/02/11 05:26:23 minchau Exp $
18: */
19: package org.apache.xalan.extensions;
20:
21: import javax.xml.transform.ErrorListener;
22:
23: import org.apache.xpath.objects.XObject;
24: import org.w3c.dom.Node;
25: import org.w3c.dom.traversal.NodeIterator;
26:
27: /**
28: * An object that implements this interface can supply
29: * information about the current XPath expression context.
30: */
31: public interface ExpressionContext {
32:
33: /**
34: * Get the current context node.
35: * @return The current context node.
36: */
37: public Node getContextNode();
38:
39: /**
40: * Get the current context node list.
41: * @return An iterator for the current context list, as
42: * defined in XSLT.
43: */
44: public NodeIterator getContextNodes();
45:
46: /**
47: * Get the error listener.
48: * @return The registered error listener.
49: */
50: public ErrorListener getErrorListener();
51:
52: /**
53: * Get the value of a node as a number.
54: * @param n Node to be converted to a number. May be null.
55: * @return value of n as a number.
56: */
57: public double toNumber(Node n);
58:
59: /**
60: * Get the value of a node as a string.
61: * @param n Node to be converted to a string. May be null.
62: * @return value of n as a string, or an empty string if n is null.
63: */
64: public String toString(Node n);
65:
66: /**
67: * Get a variable based on it's qualified name.
68: *
69: * @param qname The qualified name of the variable.
70: *
71: * @return The evaluated value of the variable.
72: *
73: * @throws javax.xml.transform.TransformerException
74: */
75: public XObject getVariableOrParam(org.apache.xml.utils.QName qname)
76: throws javax.xml.transform.TransformerException;
77:
78: /**
79: * Get the XPathContext that owns this ExpressionContext.
80: *
81: * Note: exslt:function requires the XPathContext to access
82: * the variable stack and TransformerImpl.
83: *
84: * @return The current XPathContext.
85: * @throws javax.xml.transform.TransformerException
86: */
87: public org.apache.xpath.XPathContext getXPathContext()
88: throws javax.xml.transform.TransformerException;
89:
90: }
|