By default, the parser is created as a validating parser only if xerces is present. This can be configured by setting the "org.mortbay.xml.XmlParser.Validating" system property.
| Modifier and Type | Class and Description |
|---|---|
| public static class | XmlParser.Attribute
XML Attribute. |
| private class | |
| public static class | XmlParser.Node
XML Node. |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private Map | |
| private Stack | |
| private SAXParser | |
| private Map | |
| private String | |
| private Object |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | addContentHandler(String
Tag local or q name. trigger, ContentHandler SAX ContentHandler observer)Add a ContentHandler. |
| public String | |
| public String | |
| public synchronized XmlParser. | |
| public synchronized XmlParser. | |
| public synchronized XmlParser. | |
| public synchronized XmlParser. | |
| public synchronized void | |
| public void | |
| public void |
| _dtd | back to summary |
|---|---|
| private String _dtd | |
| _observerMap | back to summary |
|---|---|
| private Map<K, V> _observerMap | |
| _observers | back to summary |
|---|---|
| private Stack<E> _observers | |
| _parser | back to summary |
|---|---|
| private SAXParser _parser | |
| _redirectMap | back to summary |
|---|---|
| private Map<K, V> _redirectMap | |
| _xpath | back to summary |
|---|---|
| private String _xpath | |
| _xpaths | back to summary |
|---|---|
| private Object _xpaths | |
| XmlParser | back to summary |
|---|---|
| public XmlParser() Construct | |
| XmlParser | back to summary |
|---|---|
| public XmlParser(boolean validating) Constructor. | |
| addContentHandler | back to summary |
|---|---|
| public synchronized void addContentHandler(String trigger, ContentHandler observer) Add a ContentHandler. Add an additional _content handler that is triggered on a tag name. SAX events are passed to the ContentHandler provided from a matching start element to the corresponding end element. Only a single _content handler can be registered against each tag.
| |
| getDTD | back to summary |
|---|---|
| public String getDTD() | |
| getXpath | back to summary |
|---|---|
public String getXpath()
| |
| parse | back to summary |
|---|---|
| public synchronized XmlParser. | |
| parse | back to summary |
|---|---|
| public synchronized XmlParser. Parse String URL. | |
| parse | back to summary |
|---|---|
| public synchronized XmlParser. Parse File. | |
| parse | back to summary |
|---|---|
| public synchronized XmlParser. Parse InputStream. | |
| redirectEntity | back to summary |
|---|---|
| public synchronized void redirectEntity(String name, URL entity) | |
| setValidating | back to summary |
|---|---|
| public void setValidating(boolean validating) | |
| setXpath | back to summary |
|---|---|
| public void setXpath(String xpath) Set an XPath A very simple subset of xpath is supported to select a partial tree. Currently only path like "/node1/nodeA | /node1/nodeB" are supported.
| |
| Attribute | back to summary |
|---|---|
| pack-priv Attribute(String n, String v) | |
| getName | back to summary |
|---|---|
| public String getName() | |
| getValue | back to summary |
|---|---|
| public String getValue() | |
| Modifier and Type | Field and Description |
|---|---|
| private XmlParser. | |
| pack-priv SAXParseException | |
| private XmlParser. | |
| pack-priv XmlParser. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | characters(char[]
The characters. buf, int The start position in the character array. offset, int The number of characters to use from the
character array. len)Overrides org. Implements org. |
| pack-priv void | |
| public void | endElement(String
The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed. uri, String The local name (without prefix), or the
empty string if Namespace processing is not being
performed. localName, String The qualified name (with prefix), or the
empty string if qualified names are not available. qName)Overrides org. Implements org. |
| public void | error(SAXParseException
The error information encoded as an exception. ex)Overrides org. Implements org. |
| public void | fatalError(SAXParseException
The error information encoded as an exception. ex)Overrides org. Implements org. |
| private String | |
| public void | ignorableWhitespace(char[]
The whitespace characters. buf, int The start position in the character array. offset, int The number of characters to use from the
character array. len)Overrides org. Implements org. |
| public InputSource | resolveEntity(String
The public identifier, or null if none is
available. pid, String The system identifier provided in the XML
document. sid)Overrides org. Implements org. |
| public void | startElement(String
The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed. uri, String The local name (without prefix), or the
empty string if Namespace processing is not being
performed. localName, String The qualified name (with prefix), or the
empty string if qualified names are not available. qName, Attributes The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object. attrs)Overrides org. Implements org. |
| public void | warning(SAXParseException
The warning information encoded as an exception. ex)Overrides org. Implements org. |
| _context | back to summary |
|---|---|
| private XmlParser. | |
| _error | back to summary |
|---|---|
| pack-priv SAXParseException _error | |
| _noop | back to summary |
|---|---|
| private XmlParser. | |
| _top | back to summary |
|---|---|
| pack-priv XmlParser. | |
| Handler | back to summary |
|---|---|
| pack-priv Handler() | |
| characters | back to summary |
|---|---|
| public void characters(char[] buf, int offset, int len) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of character data inside an element. By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).
| |
| clear | back to summary |
|---|---|
| pack-priv void clear() | |
| endElement | back to summary |
|---|---|
| public void endElement(String uri, String localName, String qName) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the end of an element. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
| |
| error | back to summary |
|---|---|
| public void error(SAXParseException ex) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of a recoverable parser error. The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each error, such as inserting the message in a log file or printing it to the console.
| |
| fatalError | back to summary |
|---|---|
| public void fatalError(SAXParseException ex) throws SAXException Overrides org. Implements org. Doc from org. Report a fatal XML parsing error. The default implementation throws a SAXParseException. Application writers may override this method in a subclass if they need to take specific actions for each fatal error (such as collecting all of the errors into a single report): in any case, the application must stop all regular processing when this method is invoked, since the document is no longer reliable, and the parser may no longer report parsing events.
| |
| getLocationString | back to summary |
|---|---|
| private String getLocationString(SAXParseException ex) | |
| ignorableWhitespace | back to summary |
|---|---|
| public void ignorableWhitespace(char[] buf, int offset, int len) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of ignorable whitespace in element content. By default, do nothing. Application writers may override this method to take specific actions for each chunk of ignorable whitespace (such as adding data to a node or buffer, or printing it to a file).
| |
| resolveEntity | back to summary |
|---|---|
| public InputSource resolveEntity(String pid, String sid) Overrides org. Implements org. Doc from org. Resolve an external entity. Always return null, so that the parser will use the system identifier provided in the XML document. This method implements the SAX default behaviour: application writers can override it in a subclass to do special translations such as catalog lookups or URI redirection.
| |
| startElement | back to summary |
|---|---|
| public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the start of an element. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
| |
| warning | back to summary |
|---|---|
| public void warning(SAXParseException ex) Overrides org. Implements org. Doc from org. Receive notification of a parser warning. The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each warning, such as inserting the message in a log file or printing it to the console.
| |
| Modifier and Type | Field and Description |
|---|---|
| private XmlParser. | |
| private boolean | |
| private ArrayList | |
| pack-priv XmlParser. | |
| private String | |
| private String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(int
index at which the specified element is to be inserted i, Object element to be inserted o)Overrides java. Implements java. |
| public void | clear()
Overrides java. Implements java. |
| public Object | Returns: Node or String.index of the element to return i)Implements abstract java. Implements java. |
| public XmlParser. | |
| public String | |
| public String | |
| public XmlParser. | |
| public XmlParser. | |
| public String | |
| public String | |
| public String | |
| public Iterator | |
| public int | size()
Implements abstract java. Implements java. |
| public synchronized String | toString()
Overrides java. |
| public synchronized String | |
| public synchronized String | |
| private synchronized void |
| _attrs | back to summary |
|---|---|
| private XmlParser. | |
| _lastString | back to summary |
|---|---|
| private boolean _lastString | |
| _list | back to summary |
|---|---|
| private ArrayList<E> _list | |
| _parent | back to summary |
|---|---|
| pack-priv XmlParser. | |
| _path | back to summary |
|---|---|
| private String _path | |
| _tag | back to summary |
|---|---|
| private String _tag | |
| Node | back to summary |
|---|---|
| pack-priv Node(XmlParser. | |
| add | back to summary |
|---|---|
| public void add(int i, Object o) Overrides java. Implements java. Doc from java. Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the elements from this list (optional operation). The list will be empty after this call returns. | |
| get | back to summary |
|---|---|
| public Object get(int i) Implements abstract java. Implements java. Get the ith child node or content.
| |
| get | back to summary |
|---|---|
| public XmlParser. Get the first child node with the tag. | |
| getAttribute | back to summary |
|---|---|
| public String getAttribute(String name) Get an element attribute.
| |
| getAttribute | back to summary |
|---|---|
| public String getAttribute(String name, String dft) Get an element attribute.
| |
| getAttributes | back to summary |
|---|---|
| public XmlParser. Get an array of element attributes. | |
| getParent | back to summary |
|---|---|
| public XmlParser. | |
| getPath | back to summary |
|---|---|
| public String getPath() | |
| getString | back to summary |
|---|---|
| public String getString(String tag, boolean tags, boolean trim) Get a tag as a string. | |
| getTag | back to summary |
|---|---|
| public String getTag() | |
| iterator | back to summary |
|---|---|
| public Iterator Iterator over named child nodes. | |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Get the number of children nodes.
| |
| toString | back to summary |
|---|---|
| public synchronized String toString() Overrides java. Doc from java. Returns a string representation of this collection. The string
representation consists of a list of the collection's elements in the
order they are returned by its iterator, enclosed in square brackets
(
| |
| toString | back to summary |
|---|---|
| public synchronized String toString(boolean tag) Convert to a string.
| |
| toString | back to summary |
|---|---|
| public synchronized String toString(boolean tag, boolean trim) Convert to a string.
| |
| toString | back to summary |
|---|---|
| private synchronized void toString(StringBuilder buf, boolean tag) | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | endElement(String
The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed. uri, String The local name (without prefix), or the
empty string if Namespace processing is not being
performed. localName, String The qualified name (with prefix), or the
empty string if qualified names are not available. qName)Overrides org. Implements org. |
| public void | startElement(String
The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed. uri, String The local name (without prefix), or the
empty string if Namespace processing is not being
performed. localName, String The qualified name (with prefix), or the
empty string if qualified names are not available. qName, Attributes The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object. attrs)Overrides org. Implements org. |
| _depth | back to summary |
|---|---|
| pack-priv int _depth | |
| _next | back to summary |
|---|---|
| pack-priv XmlParser. | |
| NoopHandler | back to summary |
|---|---|
| pack-priv NoopHandler(XmlParser. | |
| endElement | back to summary |
|---|---|
| public void endElement(String uri, String localName, String qName) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the end of an element. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
| |
| startElement | back to summary |
|---|---|
| public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the start of an element. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
| |