Esempio n. 1
0
  public void validate() throws XPathException {
    stackFrameMap = getConfiguration().makeSlotManager();
    checkTopLevel(null);

    // the check for duplicates is now done in the buildIndexes() method of XSLStylesheet
    if (match != null) {
      match = typeCheck("match", match);
      if (match.getNodeTest() instanceof EmptySequenceTest) {
        try {
          getConfiguration()
              .getErrorListener()
              .warning(new TransformerException("Match pattern cannot match any nodes", this));
        } catch (TransformerException e) {
          compileError(XPathException.makeXPathException(e));
        }
      }
    }

    // See if there are any required parameters.
    AxisIterator kids = iterateAxis(Axis.CHILD);
    while (true) {
      NodeInfo param = (NodeInfo) kids.next();
      if (param == null) {
        break;
      }
      if (param instanceof XSLParam && ((XSLParam) param).isRequiredParam()) {
        hasRequiredParams = true;
        break;
      }
    }
  }
  private static int findNodeIndex(NodeInfo node) {

    if (node.getParent() == null) return 0;

    final AxisIterator it = node.iterateAxis(Axis.PRECEDING_SIBLING);
    int result = 0;

    Item i = it.next();

    while (i != null) {
      result++;
      i = it.next();
    }

    return result;
  }