001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 /* 019 * $Id: ExpressionContext.java 468637 2006-10-28 06:51:02Z minchau $ 020 */ 021 package org.apache.xalan.extensions; 022 023 import javax.xml.transform.ErrorListener; 024 025 import org.apache.xpath.objects.XObject; 026 import org.w3c.dom.Node; 027 import org.w3c.dom.traversal.NodeIterator; 028 029 /** 030 * An object that implements this interface can supply 031 * information about the current XPath expression context. 032 */ 033 public interface ExpressionContext 034 { 035 036 /** 037 * Get the current context node. 038 * @return The current context node. 039 */ 040 public Node getContextNode(); 041 042 /** 043 * Get the current context node list. 044 * @return An iterator for the current context list, as 045 * defined in XSLT. 046 */ 047 public NodeIterator getContextNodes(); 048 049 /** 050 * Get the error listener. 051 * @return The registered error listener. 052 */ 053 public ErrorListener getErrorListener(); 054 055 /** 056 * Get the value of a node as a number. 057 * @param n Node to be converted to a number. May be null. 058 * @return value of n as a number. 059 */ 060 public double toNumber(Node n); 061 062 /** 063 * Get the value of a node as a string. 064 * @param n Node to be converted to a string. May be null. 065 * @return value of n as a string, or an empty string if n is null. 066 */ 067 public String toString(Node n); 068 069 /** 070 * Get a variable based on it's qualified name. 071 * 072 * @param qname The qualified name of the variable. 073 * 074 * @return The evaluated value of the variable. 075 * 076 * @throws javax.xml.transform.TransformerException 077 */ 078 public XObject getVariableOrParam(org.apache.xml.utils.QName qname) 079 throws javax.xml.transform.TransformerException; 080 081 /** 082 * Get the XPathContext that owns this ExpressionContext. 083 * 084 * Note: exslt:function requires the XPathContext to access 085 * the variable stack and TransformerImpl. 086 * 087 * @return The current XPathContext. 088 * @throws javax.xml.transform.TransformerException 089 */ 090 public org.apache.xpath.XPathContext getXPathContext() 091 throws javax.xml.transform.TransformerException; 092 093 }