Пример #1
0
  public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
      throws SAXException {

    IslandSchema is = dispatcher.getSchemaProvider().getSchemaByNamespace(namespaceURI);
    if (is != null) {
      // find an island that has to be validated.
      // switch to the new IslandVerifier.
      IslandVerifier iv = is.createNewVerifier(namespaceURI, is.getElementDecls());
      dispatcher.switchVerifier(iv);
      iv.startElement(namespaceURI, localName, qName, atts);
      return;
    }

    boolean atLeastOneIsValid = false;

    for (int i = 0; i < exps.length; i++)
      if (exps[i] != null) {
        if (exps[i].getNameClass().accepts(namespaceURI, localName)) atLeastOneIsValid = true;
        else exps[i] = null; // this one is no longer valid.
      }

    if (!atLeastOneIsValid)
      // none is valid. report an error.
      dispatcher
          .getErrorHandler()
          .error(
              new SAXParseException(
                  Localizer.localize(ERR_UNEXPECTED_NAMESPACE, new Object[] {namespaceURI}),
                  locator));
  }
Пример #2
0
  /**
   * creates a choice expression of all exported rules in the given provider.
   *
   * <p>this expression is used as a pseudo content model of anyOtherElement.
   */
  private Expression createChoiceOfAllExportedRules(SchemaProvider provider) {
    Expression exp = Expression.nullSet;

    Iterator<?> itr = provider.iterateNamespace();
    while (itr.hasNext()) {
      String namespace = (String) itr.next();
      IslandSchema is = provider.getSchemaByNamespace(namespace);
      ElementDecl[] rules = is.getElementDecls();

      for (int j = 0; j < rules.length; j++)
        exp =
            module.pool.createChoice(
                exp, new ExternalElementExp(module.pool, namespace, rules[j].getName(), null));
    }

    return exp;
  }