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