Пример #1
0
  /** Parse all direct children of the <xsl:stylesheet/> element. */
  public final void parseOwnChildren(Parser parser) {
    final SymbolTable stable = parser.getSymbolTable();
    final String excludePrefixes = getAttribute("exclude-result-prefixes");
    final String extensionPrefixes = getAttribute("extension-element-prefixes");

    // Exclude XSLT uri
    stable.pushExcludedNamespacesContext();
    stable.excludeURI(Constants.XSLT_URI);
    stable.excludeNamespaces(excludePrefixes);
    stable.excludeNamespaces(extensionPrefixes);

    final Vector contents = getContents();
    final int count = contents.size();

    // We have to scan the stylesheet element's top-level elements for
    // variables and/or parameters before we parse the other elements
    for (int i = 0; i < count; i++) {
      SyntaxTreeNode child = (SyntaxTreeNode) contents.elementAt(i);
      if ((child instanceof VariableBase) || (child instanceof NamespaceAlias)) {
        parser.getSymbolTable().setCurrentNode(child);
        child.parseContents(parser);
      }
    }

    // Now go through all the other top-level elements...
    for (int i = 0; i < count; i++) {
      SyntaxTreeNode child = (SyntaxTreeNode) contents.elementAt(i);
      if (!(child instanceof VariableBase) && !(child instanceof NamespaceAlias)) {
        parser.getSymbolTable().setCurrentNode(child);
        child.parseContents(parser);
      }

      // All template code should be compiled as methods if the
      // <xsl:apply-imports/> element was ever used in this stylesheet
      if (!_templateInlining && (child instanceof Template)) {
        Template template = (Template) child;
        String name = "template$dot$" + template.getPosition();
        template.setName(parser.getQName(name));
      }
    }

    stable.popExcludedNamespacesContext();
  }