XObject
.
*
* @throws javax.xml.transform.TransformerException if a runtime exception
* occurs.
*/
public XObject execute(XPathContext xctxt, int currentNode)
throws javax.xml.transform.TransformerException
{
// For now, the current node is already pushed.
return execute(xctxt);
}
/**
* Execute an expression in the XPath runtime context, and return the
* result of the expression.
*
*
* @param xctxt The XPath runtime context.
* @param currentNode The currentNode.
* @param dtm The DTM of the current node.
* @param expType The expanded type ID of the current node.
*
* @return The result of the expression in the form of a XObject
.
*
* @throws javax.xml.transform.TransformerException if a runtime exception
* occurs.
*/
public XObject execute(
XPathContext xctxt, int currentNode, DTM dtm, int expType)
throws javax.xml.transform.TransformerException
{
// For now, the current node is already pushed.
return execute(xctxt);
}
/**
* Execute an expression in the XPath runtime context, and return the
* result of the expression.
*
*
* @param xctxt The XPath runtime context.
*
* @return The result of the expression in the form of a XObject
.
*
* @throws javax.xml.transform.TransformerException if a runtime exception
* occurs.
*/
public abstract XObject execute(XPathContext xctxt)
throws javax.xml.transform.TransformerException;
/**
* Execute an expression in the XPath runtime context, and return the
* result of the expression, but tell that a "safe" object doesn't have
* to be returned. The default implementation just calls execute(xctxt).
*
*
* @param xctxt The XPath runtime context.
* @param destructiveOK true if a "safe" object doesn't need to be returned.
*
* @return The result of the expression in the form of a XObject
.
*
* @throws javax.xml.transform.TransformerException if a runtime exception
* occurs.
*/
public XObject execute(XPathContext xctxt, boolean destructiveOK)
throws javax.xml.transform.TransformerException
{
return execute(xctxt);
}
/**
* Evaluate expression to a number.
*
*
* @param xctxt The XPath runtime context.
* @return The expression evaluated as a double.
*
* @throws javax.xml.transform.TransformerException
*/
public double num(XPathContext xctxt)
throws javax.xml.transform.TransformerException
{
return execute(xctxt).num();
}
/**
* Evaluate expression to a boolean.
*
*
* @param xctxt The XPath runtime context.
* @return false
*
* @throws javax.xml.transform.TransformerException
*/
public boolean bool(XPathContext xctxt)
throws javax.xml.transform.TransformerException
{
return execute(xctxt).bool();
}
/**
* Cast result object to a string.
*
*
* @param xctxt The XPath runtime context.
* @return The string this wraps or the empty string if null
*
* @throws javax.xml.transform.TransformerException
*/
public XMLString xstr(XPathContext xctxt)
throws javax.xml.transform.TransformerException
{
return execute(xctxt).xstr();
}
/**
* Tell if the expression is a nodeset expression. In other words, tell
* if you can execute {@link #asNode(XPathContext) asNode} without an exception.
* @return true if the expression can be represented as a nodeset.
*/
public boolean isNodesetExpr()
{
return false;
}
/**
* Return the first node out of the nodeset, if this expression is
* a nodeset expression.
* @param xctxt The XPath runtime context.
* @return the first node out of the nodeset, or DTM.NULL.
*
* @throws javax.xml.transform.TransformerException
*/
public int asNode(XPathContext xctxt)
throws javax.xml.transform.TransformerException
{
DTMIterator iter = execute(xctxt).iter();
return iter.nextNode();
}
/**
* Given an select expression and a context, evaluate the XPath
* and return the resulting iterator.
*
* @param xctxt The execution context.
* @param contextNode The node that "." expresses.
*
*
* @return A valid DTMIterator.
* @throws TransformerException thrown if the active ProblemListener decides
* the error condition is severe enough to halt processing.
*
* @throws javax.xml.transform.TransformerException
* @xsl.usage experimental
*/
public DTMIterator asIterator(XPathContext xctxt, int contextNode)
throws javax.xml.transform.TransformerException
{
try
{
xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
return execute(xctxt).iter();
}
finally
{
xctxt.popCurrentNodeAndExpression();
}
}
/**
* Given an select expression and a context, evaluate the XPath
* and return the resulting iterator, but do not clone.
*
* @param xctxt The execution context.
* @param contextNode The node that "." expresses.
*
*
* @return A valid DTMIterator.
* @throws TransformerException thrown if the active ProblemListener decides
* the error condition is severe enough to halt processing.
*
* @throws javax.xml.transform.TransformerException
* @xsl.usage experimental
*/
public DTMIterator asIteratorRaw(XPathContext xctxt, int contextNode)
throws javax.xml.transform.TransformerException
{
try
{
xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
XNodeSet nodeset = (XNodeSet)execute(xctxt);
return nodeset.iterRaw();
}
finally
{
xctxt.popCurrentNodeAndExpression();
}
}
/**
* Execute an expression in the XPath runtime context, and return the
* result of the expression.
*
*
* @param xctxt The XPath runtime context.
* NEEDSDOC @param handler
*
* @return The result of the expression in the form of a XObject
.
*
* @throws javax.xml.transform.TransformerException if a runtime exception
* occurs.
* @throws org.xml.sax.SAXException
*/
public void executeCharsToContentHandler(
XPathContext xctxt, ContentHandler handler)
throws javax.xml.transform.TransformerException,
org.xml.sax.SAXException
{
XObject obj = execute(xctxt);
obj.dispatchCharactersEvents(handler);
obj.detach();
}
/**
* Tell if this expression returns a stable number that will not change during
* iterations within the expression. This is used to determine if a proximity
* position predicate can indicate that no more searching has to occur.
*
*
* @return true if the expression represents a stable number.
*/
public boolean isStableNumber()
{
return false;
}
/**
* This function is used to fixup variables from QNames to stack frame
* indexes at stylesheet build time.
* @param vars List of QNames that correspond to variables. This list
* should be searched backwards for the first qualified name that
* corresponds to the variable reference qname. The position of the
* QName in the vector from the start of the vector will be its position
* in the stack frame (but variables above the globalsTop value will need
* to be offset to the current stack frame).
* NEEDSDOC @param globalsSize
*/
public abstract void fixupVariables(ListThe return value is the public identifier of the document * entity or of the external parsed entity in which the markup that * triggered the event appears.
* * @return A string containing the public identifier, or * null if none is available. * @see #getSystemId */ public String getPublicId() { if(null == m_parent) return null; return m_parent.getPublicId(); } /** * Return the system identifier for the current document event. * *The return value is the system identifier of the document * entity or of the external parsed entity in which the markup that * triggered the event appears.
* *If the system identifier is a URL, the parser must resolve it * fully before passing it to the application.
* * @return A string containing the system identifier, or null * if none is available. * @see #getPublicId */ public String getSystemId() { if(null == m_parent) return null; return m_parent.getSystemId(); } /** * Return the line number where the current document event ends. * *Warning: The return value from the method * is intended only as an approximation for the sake of error * reporting; it is not intended to provide sufficient information * to edit the character content of the original XML document.
* *The return value is an approximation of the line number * in the document entity or external parsed entity where the * markup that triggered the event appears.
* * @return The line number, or -1 if none is available. * @see #getColumnNumber */ public int getLineNumber() { if(null == m_parent) return 0; return m_parent.getLineNumber(); } /** * Return the character position where the current document event ends. * *Warning: The return value from the method * is intended only as an approximation for the sake of error * reporting; it is not intended to provide sufficient information * to edit the character content of the original XML document.
* *The return value is an approximation of the column number * in the document entity or external parsed entity where the * markup that triggered the event appears.
* * @return The column number, or -1 if none is available. * @see #getLineNumber */ public int getColumnNumber() { if(null == m_parent) return 0; return m_parent.getColumnNumber(); } }