org.qtitools.qti.node
Class XmlUtils

java.lang.Object
  extended by org.qtitools.qti.node.XmlUtils

public class XmlUtils
extends java.lang.Object

This class encapsulates XML parser.

Author:
Jiri Kajaba, Jonathon Hare

Nested Class Summary
static class XmlUtils.UnicodeReader
          Generic unicode textreader, which will use BOM mark to identify the encoding to be used.
 
Field Summary
static java.lang.String ATTRIBUTE_SCHEMA_LANGUAGE_NAME
          Name of schema language attribute.
static java.lang.String ATTRIBUTE_SCHEMA_LANGUAGE_VALUE
          Value of schema language attribute.
static java.lang.String ATTRIBUTE_SCHEMA_SOURCE_NAME
          Name of schema location attribute.
static java.lang.String ATTRIBUTE_SCHEMA_SOURCE_VALUE
          Value of chema location attribute.
 
Constructor Summary
XmlUtils()
           
 
Method Summary
static javax.xml.parsers.DocumentBuilder getBuilder(boolean validate)
          Gets document builder.
static org.w3c.dom.Document getDocument(java.io.File file, boolean validate)
          Gets document from given source file.
static org.w3c.dom.Document getDocument(java.lang.String string, boolean validate)
          Gets document from given source string.
static javax.xml.parsers.DocumentBuilderFactory getFactory(boolean validate)
          Gets document builder factory.
static org.w3c.dom.Node getFirstElementNode(org.w3c.dom.Document document)
          Gets first element node from given source document.
static org.w3c.dom.Node getFirstElementNode(java.io.File file, boolean validate)
          Gets first element node from given source file.
static org.w3c.dom.Node getFirstElementNode(java.lang.String string, boolean validate)
          Gets first element node of given source string.
static org.w3c.dom.Node getFirstElementNode(java.net.URL url, boolean validate)
          Gets first element node from given source url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_SCHEMA_LANGUAGE_NAME

public static final java.lang.String ATTRIBUTE_SCHEMA_LANGUAGE_NAME
Name of schema language attribute.

See Also:
Constant Field Values

ATTRIBUTE_SCHEMA_LANGUAGE_VALUE

public static final java.lang.String ATTRIBUTE_SCHEMA_LANGUAGE_VALUE
Value of schema language attribute.

See Also:
Constant Field Values

ATTRIBUTE_SCHEMA_SOURCE_NAME

public static final java.lang.String ATTRIBUTE_SCHEMA_SOURCE_NAME
Name of schema location attribute.

See Also:
Constant Field Values

ATTRIBUTE_SCHEMA_SOURCE_VALUE

public static final java.lang.String ATTRIBUTE_SCHEMA_SOURCE_VALUE
Value of chema location attribute.

See Also:
Constant Field Values
Constructor Detail

XmlUtils

public XmlUtils()
Method Detail

getFactory

public static javax.xml.parsers.DocumentBuilderFactory getFactory(boolean validate)
Gets document builder factory.

Parameters:
validate - whether validate document
Returns:
document builder factory

getBuilder

public static javax.xml.parsers.DocumentBuilder getBuilder(boolean validate)
                                                    throws QTIParseException
Gets document builder.

Parameters:
validate - whether validate document
Returns:
document builder
Throws:
QTIParseException - if any parsing error occurs

getDocument

public static org.w3c.dom.Document getDocument(java.io.File file,
                                               boolean validate)
                                        throws QTIParseException
Gets document from given source file.

Parameters:
file - source file
validate - whether validate document
Returns:
document from given source file
Throws:
QTIParseException - if any parsing error occurs

getDocument

public static org.w3c.dom.Document getDocument(java.lang.String string,
                                               boolean validate)
                                        throws QTIParseException
Gets document from given source string.

Parameters:
string - source string
validate - whether validate document
Returns:
document from given source string
Throws:
QTIParseException - if any parsing error occurs

getFirstElementNode

public static org.w3c.dom.Node getFirstElementNode(java.net.URL url,
                                                   boolean validate)
                                            throws QTIParseException
Gets first element node from given source url.

Parameters:
url - source url
validate - whether validate document
Returns:
first element node from given source url
Throws:
QTIParseException - if any parsing error occurs

getFirstElementNode

public static org.w3c.dom.Node getFirstElementNode(java.io.File file,
                                                   boolean validate)
                                            throws QTIParseException
Gets first element node from given source file.

Parameters:
file - source file
validate - whether validate document
Returns:
first element node from given source file
Throws:
QTIParseException - if any parsing error occurs

getFirstElementNode

public static org.w3c.dom.Node getFirstElementNode(java.lang.String string,
                                                   boolean validate)
                                            throws QTIParseException
Gets first element node of given source string.

Parameters:
string - source string
validate - whether validate document
Returns:
first element node from given source string
Throws:
QTIParseException - if any parsing error occurs

getFirstElementNode

public static org.w3c.dom.Node getFirstElementNode(org.w3c.dom.Document document)
                                            throws QTIParseException
Gets first element node from given source document.

Parameters:
document - source document
Returns:
first element node from given source document
Throws:
QTIParseException - if given document does not contain any element node


Copyright © 2009. All Rights Reserved.