org.jsurveylib.utils
Class XMLUtil

java.lang.Object
  extended by org.jsurveylib.utils.XMLUtil

public class XMLUtil
extends java.lang.Object

FOR INTERNAL USE ONLY.


Method Summary
static java.lang.String elementToString(org.w3c.dom.Element element)
          Serializes an Element, and returns it back in form of string.
static java.util.Map<java.lang.String,java.lang.String> getAnswerMapFromElement(org.w3c.dom.Element element)
           
static org.w3c.dom.Element getXMLRoot(java.io.Reader input)
          Gets the XML root element from the Reader and returns it.
static void validateXML(java.io.Reader input, org.xml.sax.ErrorHandler errorHandler)
          Validates the XML by the XSD it finds in the XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

validateXML

public static void validateXML(java.io.Reader input,
                               org.xml.sax.ErrorHandler errorHandler)
                        throws java.io.IOException,
                               javax.xml.parsers.ParserConfigurationException,
                               org.xml.sax.SAXException
Validates the XML by the XSD it finds in the XML. You must pass in an error handler or null if you want to use a standard error handler that throws all exceptions.

Parameters:
input - The Reader of the XML file. This will be closed after it is used.
errorHandler - The error handler to use if an error occurs. If you pass in null, a standard error handler is used that throws all exceptions.
Throws:
java.io.IOException - If an error occurs reading the file.
javax.xml.parsers.ParserConfigurationException - If an error occurs parsing the file.
org.xml.sax.SAXException - If a SAX exception occurs.

getXMLRoot

public static org.w3c.dom.Element getXMLRoot(java.io.Reader input)
                                      throws org.xml.sax.SAXException,
                                             java.io.IOException
Gets the XML root element from the Reader and returns it. No validation occurs. Note that the reader is closed at the end of this method.

Parameters:
input - The Reader of the XML file. This will be closed after it is used.
Returns:
The root element of the XML file.
Throws:
java.io.IOException - If an error occurs reading the file.
org.xml.sax.SAXException - If a SAX exception occurs.

getAnswerMapFromElement

public static java.util.Map<java.lang.String,java.lang.String> getAnswerMapFromElement(org.w3c.dom.Element element)

elementToString

public static java.lang.String elementToString(org.w3c.dom.Element element)
                                        throws java.io.IOException
Serializes an Element, and returns it back in form of string.

Parameters:
element - The element to serialize
Returns:
The element in String form.
Throws:
java.io.IOException - If an error occurs while serializing