1 /* 2 * Copyright 1999-2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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 com.sun.org.apache.xalan.internal.extensions; 20 21 import javax.xml.transform.ErrorListener; 22 23 import com.sun.org.apache.xpath.internal.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 /** 35 * Get the current context node. 36 * @return The current context node. 37 */ 38 public Node getContextNode(); 39 40 /** 41 * Get the current context node list. 42 * @return An iterator for the current context list, as 43 * defined in XSLT. 44 */ 45 public NodeIterator getContextNodes(); 46 47 /** 48 * Get the error listener. 49 * @return The registered error listener. 50 */ 51 public ErrorListener getErrorListener(); 52 53 /** 54 * Get the value of a node as a number. 55 * @param n Node to be converted to a number. May be null. 56 * @return value of n as a number. 57 */ 58 public double toNumber(Node n); 59 60 /** 61 * Get the value of a node as a string. 62 * @param n Node to be converted to a string. May be null. 63 * @return value of n as a string, or an empty string if n is null. 64 */ 65 public String toString(Node n); 66 67 /** 68 * Get a variable based on it's qualified name. 69 * 70 * @param qname The qualified name of the variable. 71 * 72 * @return The evaluated value of the variable. 73 * 74 * @throws javax.xml.transform.TransformerException 75 */ 76 public XObject getVariableOrParam(com.sun.org.apache.xml.internal.utils.QName qname) 77 throws javax.xml.transform.TransformerException; 78 79 /** 80 * Get the XPathContext that owns this ExpressionContext. 81 * 82 * Note: exslt:function requires the XPathContext to access 83 * the variable stack and TransformerImpl. 84 * 85 * @return The current XPathContext. 86 * @throws javax.xml.transform.TransformerException 87 */ 88 public com.sun.org.apache.xpath.internal.XPathContext getXPathContext() 89 throws javax.xml.transform.TransformerException; 90 91 } 92