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