com.topologi.diffx.xml
Class XMLHelper

java.lang.Object
  extended by com.topologi.diffx.xml.XMLHelper

public final class XMLHelper
extends Object

Utility class that provides common XML operations so that the calling class uses lighter code.

Most methdos in this implementation will forward the exceptions should occur, so they will have to be handled externally.

Version:
1.0, 6 May 2004
Author:
Christophe Lauret - Allette Systems (Australia)

Method Summary
static XMLReader makeXMLReader(ContentHandler handler)
          Creates a non-validating, non-namespace-aware XMLReader using the specified ContentHandler.
static void parse(XMLReader xmlreader, File file)
          Parses the given File with the specified XMLReader.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeXMLReader

public static XMLReader makeXMLReader(ContentHandler handler)
                               throws SAXException,
                                      ParserConfigurationException
Creates a non-validating, non-namespace-aware XMLReader using the specified ContentHandler.

If the given ContentHandler is null, the XMLReader is not initialised.

Parameters:
handler - The content handler to use.
Returns:
The requested XMLReader
Throws:
SAXException - Should a SAX exception occur
ParserConfigurationException - Should a parser config exception occur

parse

public static void parse(XMLReader xmlreader,
                         File file)
                  throws FileNotFoundException,
                         SAXException,
                         IOException
Parses the given File with the specified XMLReader.

This method assumes the XML is in 'UTF-8', it will not sniff the XML to determine the encoding to use.

Parameters:
xmlreader - The XML reader to use.
file - The file to parse
Throws:
FileNotFoundException - If the file does not exists
SAXException - Should an SAX exception occur
IOException - Should an I/O exception occur