Class XmlParser


  • public class XmlParser
    extends java.lang.Object
    Parse XML documents and return parse events through call-backs.

    You need to define a class implementing the XmlHandler interface: an object belonging to this class will receive the callbacks for the events. (As an alternative to implementing the full XmlHandler interface, you can simply extend the HandlerBase convenience class.)

    Usage (assuming that MyHandler is your implementation of the XmlHandler interface):

     XmlHandler handler = new MyHandler();
     XmlParser parser = new XmlParser();
     parser.setHandler(handler);
     try {
       parser.parse("http://www.host.com/doc.xml", null);
     } catch (Exception e) {
       [do something interesting]
     }
     

    Alternatively, you can use the standard SAX interfaces with the SAXDriver class as your entry point.

    Since:
    Ptolemy II 0.2
    Version:
    1.1
    Author:
    Copyright (c) 1997, 1998 by Microstar Software Ltd., Written by David Megginson <dmeggins@microstar.com>
    See Also:
    XmlHandler, HandlerBase
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlParser()
      Construct a new parser with no associated handler.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Enumeration declaredAttributes​(java.lang.String elname)
      Get the declared attributes for an element type.
      java.util.Enumeration declaredElements()
      Get the declared elements for an XML document.
      java.util.Enumeration declaredEntities()
      Get declared entities.
      java.util.Enumeration declaredNotations()
      Get declared notations.
      java.lang.String getAttributeDefaultValue​(java.lang.String name, java.lang.String aname)
      Retrieve the default value of a declared attribute.
      int getAttributeDefaultValueType​(java.lang.String name, java.lang.String aname)
      Retrieve the default value type of a declared attribute.
      java.lang.String getAttributeEnumeration​(java.lang.String name, java.lang.String aname)
      Retrieve the allowed values for an enumerated attribute type.
      java.lang.String getAttributeExpandedValue​(java.lang.String name, java.lang.String aname)
      Retrieve the expanded value of a declared attribute.
      int getAttributeType​(java.lang.String name, java.lang.String aname)
      Retrieve the declared type of an attribute.
      int getColumnNumber()
      Return the current column number.
      java.lang.String getCurrentElement()
      Return the current element.
      java.lang.String getElementContentModel​(java.lang.String name)
      Look up the content model of an element.
      int getElementContentType​(java.lang.String name)
      Look up the content type of an element.
      java.lang.String getEntityNotationName​(java.lang.String eName)
      Get the notation name associated with an NDATA entity.
      java.lang.String getEntityPublicId​(java.lang.String ename)
      Return an external entity's public identifier, if any.
      java.lang.String getEntitySystemId​(java.lang.String ename)
      Return an external entity's system identifier.
      int getEntityType​(java.lang.String ename)
      Find the type of an entity.
      java.lang.String getEntityValue​(java.lang.String ename)
      Return the value of an internal entity.
      int getLineNumber()
      Return the current line number.
      java.lang.String getNotationPublicId​(java.lang.String nname)
      Look up the public identifier for a notation.
      java.lang.String getNotationSystemId​(java.lang.String nname)
      Look up the system identifier for a notation.
      java.lang.String intern​(char[] ch, int start, int length)
      Create an internalised string from a character array.
      java.lang.String intern​(java.lang.String s)
      Return an internalised version of a string.
      void parse​(java.lang.String systemId, java.lang.String publicId, java.io.InputStream stream, java.lang.String encoding)
      Parse an XML document from a byte stream.
      void parse​(java.lang.String systemId, java.lang.String publicId, java.io.Reader reader)
      Parse an XML document from a character stream.
      void parse​(java.lang.String systemId, java.lang.String publicId, java.lang.String encoding)
      Parse an XML document from a URI.
      void setHandler​(XmlHandler handler)
      Set the handler that will receive parsing events.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait