Esempio n. 1
0
  /**
   * This method is called when a new attribute of an XML element is encountered.
   *
   * @param key the key (name) of the attribute
   * @param nsPrefix the prefix used to identify the namespace
   * @param nsSystemID the system ID associated with the namespace
   * @param value the value of the attribute
   * @param type the type of the attribute ("CDATA" if unknown)
   * @throws java.lang.Exception If an exception occurred while processing the event.
   */
  public void addAttribute(
      String key, String nsPrefix, String nsSystemID, String value, String type) throws Exception {
    XMLElement top = (XMLElement) this.stack.peek();

    if (top.hasAttribute(key)) {
      throw new XMLParseException(
          top.getSystemID(), top.getLineNr(), "Duplicate attribute: " + key);
    }

    top.setAttribute(key, value);
  }
Esempio n. 2
0
 public static void main(String args[]) throws Exception {
   XMLElement elt = new XMLElement("FOO");
   elt.setAttribute(null, "good");
   XMLWriter writer = new XMLWriter(System.out);
   writer.write(elt);
 }