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. import javax.xml.transform.ErrorListener;
  21. import com.sun.org.apache.xpath.internal.objects.XObject;
  22. import org.w3c.dom.Node;
  23. import org.w3c.dom.traversal.NodeIterator;
  24. /**
  25. * An object that implements this interface can supply
  26. * information about the current XPath expression context.
  27. */
  28. public interface ExpressionContext
  29. {
  30. /**
  31. * Get the current context node.
  32. * @return The current context node.
  33. */
  34. public Node getContextNode();
  35. /**
  36. * Get the current context node list.
  37. * @return An iterator for the current context list, as
  38. * defined in XSLT.
  39. */
  40. public NodeIterator getContextNodes();
  41. /**
  42. * Get the error listener.
  43. * @return The registered error listener.
  44. */
  45. public ErrorListener getErrorListener();
  46. /**
  47. * Get the value of a node as a number.
  48. * @param n Node to be converted to a number. May be null.
  49. * @return value of n as a number.
  50. */
  51. public double toNumber(Node n);
  52. /**
  53. * Get the value of a node as a string.
  54. * @param n Node to be converted to a string. May be null.
  55. * @return value of n as a string, or an empty string if n is null.
  56. */
  57. public String toString(Node n);
  58. /**
  59. * Get a variable based on it's qualified name.
  60. *
  61. * @param qname The qualified name of the variable.
  62. *
  63. * @return The evaluated value of the variable.
  64. *
  65. * @throws javax.xml.transform.TransformerException
  66. */
  67. public XObject getVariableOrParam(com.sun.org.apache.xml.internal.utils.QName qname)
  68. throws javax.xml.transform.TransformerException;
  69. /**
  70. * Get the XPathContext that owns this ExpressionContext.
  71. *
  72. * Note: exslt:function requires the XPathContext to access
  73. * the variable stack and TransformerImpl.
  74. *
  75. * @return The current XPathContext.
  76. * @throws javax.xml.transform.TransformerException
  77. */
  78. public com.sun.org.apache.xpath.internal.XPathContext getXPathContext()
  79. throws javax.xml.transform.TransformerException;
  80. }