schwing.util
Class XMLUtil

java.lang.Object
  |
  +--schwing.util.XMLUtil

public class XMLUtil
extends java.lang.Object

Contains helper methods for working with XML.

Version:
$Revision: 1.1 $
Author:
Darryl L. Pierce

Method Summary
static org.w3c.dom.Document createDocument()
          Creates an instance of Document.
static org.w3c.dom.Document createDocument(java.lang.String tag)
          Creates an instance of Document with the supplied root tag.
static org.xml.sax.EntityResolver getEntityResolver(java.io.InputStream istream)
          Creates an instance of EntityResolver using the supplied InputStream.
static org.w3c.dom.Document loadDocument(java.io.InputStream istream)
          Loads the specified document from the supplied InputStream.
static org.w3c.dom.Document loadDocument(java.io.InputStream istream, org.xml.sax.EntityResolver resolver)
          Loads the specified document from the supplied InputStream.
static org.w3c.dom.Document loadDocument(java.io.InputStream istream, org.xml.sax.EntityResolver resolver, org.xml.sax.ErrorHandler ehandler)
          Loads the specified document from the supplied InputStream.
static org.w3c.dom.Document loadDocument(java.io.InputStream istream, org.xml.sax.EntityResolver resolver, org.xml.sax.ErrorHandler ehandler, java.lang.Object[][] features)
          Loads the specified document from the supplied InputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEntityResolver

public static org.xml.sax.EntityResolver getEntityResolver(java.io.InputStream istream)

Creates an instance of EntityResolver using the supplied InputStream. The InputStream will contain the actual DTD file.

Parameters:
istream - the input stream
Returns:
the resolver, or null if the operation failed

createDocument

public static org.w3c.dom.Document createDocument()

Creates an instance of Document.

Returns:
the document

createDocument

public static org.w3c.dom.Document createDocument(java.lang.String tag)

Creates an instance of Document with the supplied root tag.

Parameters:
tag - the root tag name
Returns:
the document

loadDocument

public static org.w3c.dom.Document loadDocument(java.io.InputStream istream)
                                         throws org.xml.sax.SAXException,
                                                java.io.IOException

Loads the specified document from the supplied InputStream.

Parameters:
istream - the input stream
Throws:
org.xml.sax.SAXException - if a parsing error occurs
java.io.IOException - if an I/O error occurs

loadDocument

public static org.w3c.dom.Document loadDocument(java.io.InputStream istream,
                                                org.xml.sax.EntityResolver resolver)
                                         throws org.xml.sax.SAXException,
                                                java.io.IOException

Loads the specified document from the supplied InputStream. The supplied EntityResolver is used to validate the content as it is parsed.

Parameters:
istream - the input stream
resolver - the DTD
Throws:
org.xml.sax.SAXException - if a parsing error occurs
java.io.IOException - if an I/O error occurs

loadDocument

public static org.w3c.dom.Document loadDocument(java.io.InputStream istream,
                                                org.xml.sax.EntityResolver resolver,
                                                org.xml.sax.ErrorHandler ehandler)
                                         throws org.xml.sax.SAXException,
                                                java.io.IOException

Loads the specified document from the supplied InputStream. The supplied EntityResolver is used to validate the content as it is parsed. When content-related errors are found, the supplied instance of ErrorHandler is notified.

Parameters:
istream - the input stream
resolver - the DTD
Throws:
org.xml.sax.SAXException - if a parsing error occurs
java.io.IOException - if an I/O error occurs

loadDocument

public static org.w3c.dom.Document loadDocument(java.io.InputStream istream,
                                                org.xml.sax.EntityResolver resolver,
                                                org.xml.sax.ErrorHandler ehandler,
                                                java.lang.Object[][] features)
                                         throws org.xml.sax.SAXException,
                                                java.io.IOException

Loads the specified document from the supplied InputStream. The supplied EntityResolver is used to validate the content as it is parsed. When content-related errors are found, the supplied instance of ErrorHandler is notified. The supplied list of features are used to set the specified parser features for loading the document.

In this implementation, the supplied list of features is expected to be an array of 2-element Object arrays, where element 0 is a String for the feature, and element 1 is a java.lang.Boolean setting the state for the feature. For example:

 Object[][] features =
     {
     {"feature1",Boolean.TRUE},
     {"feature2",Boolean.FALSE},
     };
 
Parameters:
istream - the input stream
resolver - the DTD
ehandler - the error handling object
features - the parser features
Returns:
the document
Throws:
org.xml.sax.SAXException - if a parsing error occurs
java.io.IOException - if an I/O error occurs