Exemplo n.º 1
0
  /**
   * The SAX2 <code>startElement</code> method.
   *
   * <p>The catalog parser is selected based on the namespace of the first element encountered in
   * the catalog.
   */
  public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
      throws SAXException {

    if (abandonHope) {
      return;
    }

    if (saxParser == null) {
      String saxParserClass = getCatalogParser(namespaceURI, localName);

      if (saxParserClass == null) {
        abandonHope = true;
        if (namespaceURI == null) {
          debug.message(2, "No Catalog parser for " + localName);
        } else {
          debug.message(2, "No Catalog parser for " + "{" + namespaceURI + "}" + localName);
        }
        return;
      }

      try {
        saxParser =
            (SAXCatalogParser)
                Class.forName(
                        saxParserClass,
                        true,
                        loader != null ? loader : this.getClass().getClassLoader())
                    .newInstance();

        saxParser.setCatalog(catalog);
        saxParser.startDocument();
        saxParser.startElement(namespaceURI, localName, qName, atts);
      } catch (ClassNotFoundException cnfe) {
        saxParser = null;
        abandonHope = true;
        debug.message(2, cnfe.toString());
      } catch (InstantiationException ie) {
        saxParser = null;
        abandonHope = true;
        debug.message(2, ie.toString());
      } catch (IllegalAccessException iae) {
        saxParser = null;
        abandonHope = true;
        debug.message(2, iae.toString());
      } catch (ClassCastException cce) {
        saxParser = null;
        abandonHope = true;
        debug.message(2, cce.toString());
      }
    } else {
      saxParser.startElement(namespaceURI, localName, qName, atts);
    }
  }
Exemplo n.º 2
0
 /** The SAX <code>skippedentity</code> method. Does nothing. */
 public void skippedEntity(String name) throws SAXException {
   if (saxParser != null) {
     saxParser.skippedEntity(name);
   }
 }
Exemplo n.º 3
0
 /** The SAX <code>endPrefixMapping</code> method. Does nothing. */
 public void endPrefixMapping(String prefix) throws SAXException {
   if (saxParser != null) {
     saxParser.endPrefixMapping(prefix);
   }
 }
Exemplo n.º 4
0
 /** The SAX <code>startPrefixMapping</code> method. Does nothing. */
 public void startPrefixMapping(String prefix, String uri) throws SAXException {
   if (saxParser != null) {
     saxParser.startPrefixMapping(prefix, uri);
   }
 }
Exemplo n.º 5
0
 /** The SAX <code>processingInstruction</code> method. Does nothing. */
 public void processingInstruction(String target, String data) throws SAXException {
   if (saxParser != null) {
     saxParser.processingInstruction(target, data);
   }
 }
Exemplo n.º 6
0
 /** The SAX <code>ignorableWhitespace</code> method. Does nothing. */
 public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
   if (saxParser != null) {
     saxParser.ignorableWhitespace(ch, start, length);
   }
 }
Exemplo n.º 7
0
 /** The SAX <code>characters</code> method. Does nothing. */
 public void characters(char ch[], int start, int length) throws SAXException {
   if (saxParser != null) {
     saxParser.characters(ch, start, length);
   }
 }
Exemplo n.º 8
0
 /** The SAX2 <code>endElement</code> method. Does nothing. */
 public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
   if (saxParser != null) {
     saxParser.endElement(namespaceURI, localName, qName);
   }
 }
Exemplo n.º 9
0
 /** The SAX <code>endElement</code> method. Does nothing. */
 public void endElement(String name) throws SAXException {
   if (saxParser != null) {
     saxParser.endElement(name);
   }
 }
Exemplo n.º 10
0
  /**
   * The SAX <code>startElement</code> method.
   *
   * <p>The catalog parser is selected based on the namespace of the first element encountered in
   * the catalog.
   */
  public void startElement(String name, AttributeList atts) throws SAXException {

    if (abandonHope) {
      return;
    }

    if (saxParser == null) {
      String prefix = "";
      if (name.indexOf(':') > 0) {
        prefix = name.substring(0, name.indexOf(':'));
      }

      String localName = name;
      if (localName.indexOf(':') > 0) {
        localName = localName.substring(localName.indexOf(':') + 1);
      }

      String namespaceURI = null;
      if (prefix.equals("")) {
        namespaceURI = atts.getValue("xmlns");
      } else {
        namespaceURI = atts.getValue("xmlns:" + prefix);
      }

      String saxParserClass = getCatalogParser(namespaceURI, localName);

      if (saxParserClass == null) {
        abandonHope = true;
        if (namespaceURI == null) {
          debug.message(2, "No Catalog parser for " + name);
        } else {
          debug.message(2, "No Catalog parser for " + "{" + namespaceURI + "}" + name);
        }
        return;
      }

      try {
        saxParser =
            (SAXCatalogParser)
                Class.forName(
                        saxParserClass,
                        true,
                        loader != null ? loader : this.getClass().getClassLoader())
                    .newInstance();

        saxParser.setCatalog(catalog);
        saxParser.startDocument();
        saxParser.startElement(name, atts);
      } catch (ClassNotFoundException cnfe) {
        saxParser = null;
        abandonHope = true;
        debug.message(2, cnfe.toString());
      } catch (InstantiationException ie) {
        saxParser = null;
        abandonHope = true;
        debug.message(2, ie.toString());
      } catch (IllegalAccessException iae) {
        saxParser = null;
        abandonHope = true;
        debug.message(2, iae.toString());
      } catch (ClassCastException cce) {
        saxParser = null;
        abandonHope = true;
        debug.message(2, cce.toString());
      }
    } else {
      saxParser.startElement(name, atts);
    }
  }
Exemplo n.º 11
0
 /** The SAX <code>endDocument</code> method. Does nothing. */
 public void endDocument() throws SAXException {
   if (saxParser != null) {
     saxParser.endDocument();
   }
 }
Exemplo n.º 12
0
 /** The SAX <code>setDocumentLocator</code> method. Does nothing. */
 public void setDocumentLocator(Locator locator) {
   if (saxParser != null) {
     saxParser.setDocumentLocator(locator);
   }
 }