1. package org.apache.xalan.templates;
  2. import javax.xml.transform.TransformerException;
  3. import org.apache.xpath.Expression;
  4. import org.apache.xpath.XPathContext;
  5. import org.apache.xpath.objects.XObject;
  6. /**
  7. * This is the same as XUnresolvedVariable, but it assumes that the
  8. * context is already set up. For use with psuedo variables.
  9. * Also, it holds an Expression object, instead of an ElemVariable.
  10. * It must only hold static context, since a single copy will be
  11. * held in the template.
  12. */
  13. public class XUnresolvedVariableSimple extends XObject
  14. {
  15. public XUnresolvedVariableSimple(ElemVariable obj)
  16. {
  17. super(obj);
  18. }
  19. /**
  20. * For support of literal objects in xpaths.
  21. *
  22. * @param xctxt The XPath execution context.
  23. *
  24. * @return This object.
  25. *
  26. * @throws javax.xml.transform.TransformerException
  27. */
  28. public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  29. {
  30. Expression expr = ((ElemVariable)m_obj).getSelect().getExpression();
  31. XObject xobj = expr.execute(xctxt);
  32. xobj.allowDetachToRelease(false);
  33. return xobj;
  34. }
  35. /**
  36. * Tell what kind of class this is.
  37. *
  38. * @return CLASS_UNRESOLVEDVARIABLE
  39. */
  40. public int getType()
  41. {
  42. return CLASS_UNRESOLVEDVARIABLE;
  43. }
  44. /**
  45. * Given a request type, return the equivalent string.
  46. * For diagnostic purposes.
  47. *
  48. * @return An informational string.
  49. */
  50. public String getTypeString()
  51. {
  52. return "XUnresolvedVariableSimple (" + object().getClass().getName() + ")";
  53. }
  54. }