use of org.apache.xpath.objects.XObject in project j2objc by google.
the class XPathExpressionImpl method eval.
private XObject eval(Object contextItem) throws javax.xml.transform.TransformerException {
org.apache.xpath.XPathContext xpathSupport = null;
// expressions.
if (functionResolver != null) {
JAXPExtensionsProvider jep = new JAXPExtensionsProvider(functionResolver, featureSecureProcessing);
xpathSupport = new org.apache.xpath.XPathContext(jep, false);
} else {
xpathSupport = new org.apache.xpath.XPathContext(false);
}
xpathSupport.setVarStack(new JAXPVariableStack(variableResolver));
XObject xobj = null;
Node contextNode = (Node) contextItem;
// dummy Document as Context Node
if (contextNode == null) {
contextNode = getDummyDocument();
}
xobj = xpath.execute(xpathSupport, contextNode, prefixResolver);
return xobj;
}
use of org.apache.xpath.objects.XObject in project j2objc by google.
the class Equals method bool.
/**
* Execute a binary operation by calling execute on each of the operands,
* and then calling the operate method on the derived class.
*
*
* @param xctxt The runtime execution context.
*
* @return The XObject result of the operation.
*
* @throws javax.xml.transform.TransformerException
*/
public boolean bool(XPathContext xctxt) throws javax.xml.transform.TransformerException {
XObject left = m_left.execute(xctxt, true);
XObject right = m_right.execute(xctxt, true);
boolean result = left.equals(right) ? true : false;
left.detach();
right.detach();
return result;
}
use of org.apache.xpath.objects.XObject in project j2objc by google.
the class Operation method execute.
/**
* Execute a binary operation by calling execute on each of the operands,
* and then calling the operate method on the derived class.
*
*
* @param xctxt The runtime execution context.
*
* @return The XObject result of the operation.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
XObject left = m_left.execute(xctxt, true);
XObject right = m_right.execute(xctxt, true);
XObject result = operate(left, right);
left.detach();
right.detach();
return result;
}
use of org.apache.xpath.objects.XObject in project j2objc by google.
the class Variable method execute.
/**
* Dereference the variable, and return the reference value. Note that lazy
* evaluation will occur. If a variable within scope is not found, a warning
* will be sent to the error listener, and an empty nodeset will be returned.
*
*
* @param xctxt The runtime execution context.
*
* @return The evaluated variable, or an empty nodeset if not found.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt, boolean destructiveOK) throws javax.xml.transform.TransformerException {
org.apache.xml.utils.PrefixResolver xprefixResolver = xctxt.getNamespaceContext();
XObject result;
// XObject result = xctxt.getVariable(m_qname);
if (m_fixUpWasCalled) {
if (m_isGlobal)
result = xctxt.getVarStack().getGlobalVariable(xctxt, m_index, destructiveOK);
else
result = xctxt.getVarStack().getLocalVariable(xctxt, m_index, destructiveOK);
} else {
result = xctxt.getVarStack().getVariableOrParam(xctxt, m_qname);
}
if (null == result) {
// This should now never happen...
warn(xctxt, XPATHErrorResources.WG_ILLEGAL_VARIABLE_REFERENCE, //"VariableReference given for variable out "+
new Object[] { m_qname.getLocalPart() });
// (new RuntimeException()).printStackTrace();
// error(xctxt, XPATHErrorResources.ER_COULDNOT_GET_VAR_NAMED,
// new Object[]{ m_qname.getLocalPart() }); //"Could not get variable named "+varName);
result = new XNodeSet(xctxt.getDTMManager());
}
return result;
// }
// else
// {
// // Hack city... big time. This is needed to evaluate xpaths from extensions,
// // pending some bright light going off in my head. Some sort of callback?
// synchronized(this)
// {
// org.apache.xalan.templates.ElemVariable vvar= getElemVariable();
// if(null != vvar)
// {
// m_index = vvar.getIndex();
// m_isGlobal = vvar.getIsTopLevel();
// m_fixUpWasCalled = true;
// return execute(xctxt);
// }
// }
// throw new javax.xml.transform.TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_VAR_NOT_RESOLVABLE, new Object[]{m_qname.toString()})); //"Variable not resolvable: "+m_qname);
// }
}
use of org.apache.xpath.objects.XObject in project j2objc by google.
the class FuncId method execute.
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
int context = xctxt.getCurrentNode();
DTM dtm = xctxt.getDTM(context);
int docContext = dtm.getDocument();
if (DTM.NULL == docContext)
error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
XObject arg = m_arg0.execute(xctxt);
int argType = arg.getType();
XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
NodeSetDTM nodeSet = nodes.mutableNodeset();
if (XObject.CLASS_NODESET == argType) {
DTMIterator ni = arg.iter();
StringVector usedrefs = null;
int pos = ni.nextNode();
while (DTM.NULL != pos) {
DTM ndtm = ni.getDTM(pos);
String refval = ndtm.getStringValue(pos).toString();
pos = ni.nextNode();
usedrefs = getNodesByID(xctxt, docContext, refval, usedrefs, nodeSet, DTM.NULL != pos);
}
// ni.detach();
} else if (XObject.CLASS_NULL == argType) {
return nodes;
} else {
String refval = arg.str();
getNodesByID(xctxt, docContext, refval, null, nodeSet, false);
}
return nodes;
}
Aggregations