Ejemplo n.º 1
0
 /**
  * Create a new location path iterator.
  *
  * @param compiler The Compiler which is creating this expression.
  * @param opPos The position of this iterator in the
  * @return New location path iterator.
  * @throws javax.xml.transform.TransformerException
  */
 protected LocPathIterator createDTMIterator(Compiler compiler, int opPos)
     throws javax.xml.transform.TransformerException {
   LocPathIterator lpi =
       (LocPathIterator)
           WalkerFactory.newDTMIterator(compiler, opPos, (compiler.getLocationPathDepth() <= 0));
   return lpi;
 }
Ejemplo n.º 2
0
  /**
   * Initialize the location path iterators. Recursive.
   *
   * @param compiler The Compiler which is creating this expression.
   * @param opPos The position of this iterator in the opcode list from the compiler.
   * @param count The insert position of the iterator.
   * @throws javax.xml.transform.TransformerException
   */
  protected void loadLocationPaths(Compiler compiler, int opPos, int count)
      throws javax.xml.transform.TransformerException {

    // TODO: Handle unwrapped FilterExpr
    int steptype = compiler.getOp(opPos);

    if (steptype == OpCodes.OP_LOCATIONPATH) {
      loadLocationPaths(compiler, compiler.getNextOpPos(opPos), count + 1);

      m_exprs[count] = createDTMIterator(compiler, opPos);
      m_exprs[count].exprSetParent(this);
    } else {

      // Have to check for unwrapped functions, which the LocPathIterator
      // doesn't handle.
      switch (steptype) {
        case OpCodes.OP_VARIABLE:
        case OpCodes.OP_EXTFUNCTION:
        case OpCodes.OP_FUNCTION:
        case OpCodes.OP_GROUP:
          loadLocationPaths(compiler, compiler.getNextOpPos(opPos), count + 1);

          WalkingIterator iter = new WalkingIterator(compiler.getNamespaceContext());
          iter.exprSetParent(this);

          if (compiler.getLocationPathDepth() <= 0) iter.setIsTopLevel(true);

          iter.m_firstWalker = new com.sun.org.apache.xpath.internal.axes.FilterExprWalker(iter);

          iter.m_firstWalker.init(compiler, opPos, steptype);

          m_exprs[count] = iter;
          break;
        default:
          m_exprs = new LocPathIterator[count];
      }
    }
  }