Java Code Examples for org.apache.xpath.objects.XObject#allowDetachToRelease()

The following examples show how to use org.apache.xpath.objects.XObject#allowDetachToRelease() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElemWithParam.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Get the XObject representation of the variable.
 *
 * @param transformer non-null reference to the the current transform-time state.
 * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
 *
 * @return the XObject representation of the variable.
 *
 * @throws TransformerException
 */
public XObject getValue(TransformerImpl transformer, int sourceNode)
        throws TransformerException
{

  XObject var;
  XPathContext xctxt = transformer.getXPathContext();

  xctxt.pushCurrentNode(sourceNode);

  try
  {
    if (null != m_selectPattern)
    {
      var = m_selectPattern.execute(xctxt, sourceNode, this);

      var.allowDetachToRelease(false);
    }
    else if (null == getFirstChildElem())
    {
      var = XString.EMPTYSTRING;
    }
    else
    {

      // Use result tree fragment
      int df = transformer.transformToRTF(this);

      var = new XRTreeFrag(df, xctxt, this);
    }
  }
  finally
  {
    xctxt.popCurrentNode();
  }

  return var;
}
 
Example 2
Source File: FuncExtFunction.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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
{
  if (xctxt.isSecureProcessing())
    throw new javax.xml.transform.TransformerException(
      XPATHMessages.createXPATHMessage(
        XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
        new Object[] {toString()}));
    
  XObject result;
  Vector argVec = new Vector();
  int nArgs = m_argVec.size();

  for (int i = 0; i < nArgs; i++)
  {
    Expression arg = (Expression) m_argVec.elementAt(i);
    
    XObject xobj = arg.execute(xctxt);
    /*
     * Should cache the arguments for func:function
     */
    xobj.allowDetachToRelease(false); 
    argVec.addElement(xobj);
  }
  //dml
  ExtensionsProvider extProvider = (ExtensionsProvider)xctxt.getOwnerObject();
  Object val = extProvider.extFunction(this, argVec);

  if (null != val)
  {
    result = XObject.create(val, xctxt);
  }
  else
  {
    result = new XNull();
  }

  return result;
}
 
Example 3
Source File: ElemVariable.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * Get the XObject representation of the variable.
 *
 * @param transformer non-null reference to the the current transform-time state.
 * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
 *
 * @return the XObject representation of the variable.
 *
 * @throws TransformerException
 */
public XObject getValue(TransformerImpl transformer, int sourceNode)
        throws TransformerException
{

  XObject var;
  XPathContext xctxt = transformer.getXPathContext();

  xctxt.pushCurrentNode(sourceNode);
 
  try
  {
    if (null != m_selectPattern)
    {
      var = m_selectPattern.execute(xctxt, sourceNode, this);

      var.allowDetachToRelease(false);
    }
    else if (null == getFirstChildElem())
    {
      var = XString.EMPTYSTRING;
    }
    else
    {

      // Use result tree fragment.
      // Global variables may be deferred (see XUnresolvedVariable) and hence
      // need to be assigned to a different set of DTMs than local variables
      // so they aren't popped off the stack on return from a template.
      int df;

// Bugzilla 7118: A variable set via an RTF may create local
// variables during that computation. To keep them from overwriting
// variables at this level, push a new variable stack.
////// PROBLEM: This is provoking a variable-used-before-set
////// problem in parameters. Needs more study.
try
{
	//////////xctxt.getVarStack().link(0);
	if(m_parentNode instanceof Stylesheet) // Global variable
		df = transformer.transformToGlobalRTF(this);
	else
		df = transformer.transformToRTF(this);
  	}
finally{ 
	//////////////xctxt.getVarStack().unlink(); 
	}

      var = new XRTreeFrag(df, xctxt, this);
    }
  }
  finally
  {      
    xctxt.popCurrentNode();
  }

  return var;
}
 
Example 4
Source File: XUnresolvedVariableSimple.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * For support of literal objects in xpaths.
 *
 * @param xctxt The XPath execution context.
 *
 * @return This object.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
	Expression expr = ((ElemVariable)m_obj).getSelect().getExpression();
  XObject xobj = expr.execute(xctxt);
  xobj.allowDetachToRelease(false);
  return xobj;
}