VdexReload 1.1.3 API

uk.ac.reload.dweezil.util
Class XMLUtils

java.lang.Object
  extended byuk.ac.reload.dweezil.util.XMLUtils

public final class XMLUtils
extends java.lang.Object

Some useful XML Utilities that leverage the JDOM Package


Field Summary
static java.lang.String DEFAULT_SAX_DRIVER_CLASS
          The default Sax Parser that JDOM will use.
 
Constructor Summary
XMLUtils()
           
 
Method Summary
static boolean getElementByNameValuePair(java.lang.String rootName, DomPath domPath, java.io.File xmlFile, java.lang.String value)
          Gets the an element using domPath and its value
static java.lang.String getElementValueByName(java.lang.String rootName, DomPath domPath, java.io.File xmlFile)
          Gets the value of an element from its name
static java.util.ArrayList getElementValuesFromFileByName(java.io.File source, java.io.File stylesheet)
          Gets all values of a particular element using its name from the file
static boolean getFileByNameValuePair(java.lang.String rootName, DomPath domPath, java.io.File xmlFile, java.lang.String value)
          Identifies the file using domPath and its value
static java.io.File getMetadataFile(java.io.File source, java.io.File stylesheet, java.lang.String filename)
          Gets the metadata file
static org.jdom.Document readXMLFile(java.io.File file)
          Reads and returns a JDOM Document from file without Schema Validation
static org.jdom.Document readXMLFile(java.io.File file, java.lang.String schemaNamespace, java.lang.String schemaLocation)
          Reads and returns a JDOM Document from file with Schema validation
static void write2XMLFile(org.jdom.Document doc, java.io.File file)
          Writes a JDOM Document to file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SAX_DRIVER_CLASS

public static java.lang.String DEFAULT_SAX_DRIVER_CLASS
The default Sax Parser that JDOM will use. This can be replaced by something else.

Constructor Detail

XMLUtils

public XMLUtils()
Method Detail

write2XMLFile

public static void write2XMLFile(org.jdom.Document doc,
                                 java.io.File file)
                          throws DweezilXMLException
Writes a JDOM Document to file

Parameters:
doc - The JDOM Document to write
file - The file to write to
Throws:
DweezilXMLException - If there is any problem

readXMLFile

public static org.jdom.Document readXMLFile(java.io.File file,
                                            java.lang.String schemaNamespace,
                                            java.lang.String schemaLocation)
                                     throws DweezilXMLException
Reads and returns a JDOM Document from file with Schema validation

Parameters:
file - The XML File
schemaNamespace - The Schema Target Namespace
schemaLocation - The Schema Location
Returns:
The JDOM Document or null if not found
Throws:
DweezilXMLException - If there is any problem

readXMLFile

public static org.jdom.Document readXMLFile(java.io.File file)
                                     throws DweezilXMLException
Reads and returns a JDOM Document from file without Schema Validation

Parameters:
file - The XML File
Returns:
The JDOM Document or null if not found
Throws:
DweezilXMLException - If there is any problem

getElementValueByName

public static java.lang.String getElementValueByName(java.lang.String rootName,
                                                     DomPath domPath,
                                                     java.io.File xmlFile)
                                              throws DweezilXMLException
Gets the value of an element from its name

Parameters:
rootName - the name of the documents root element
domPath - the domPath of the element concerned
xmlFile - the XML file of the document concerned
Returns:
the string value of element or null if element not found
Throws:
DweezilXMLException

getElementByNameValuePair

public static boolean getElementByNameValuePair(java.lang.String rootName,
                                                DomPath domPath,
                                                java.io.File xmlFile,
                                                java.lang.String value)
                                         throws DweezilXMLException
Gets the an element using domPath and its value

Parameters:
rootName - the name of the documents root element
domPath - the domPath of the element concerned
xmlFile - the XML file of the document concerned
value - the value of the element we are searching for
Returns:
true or false depending on whether element was found or not
Throws:
DweezilXMLException

getFileByNameValuePair

public static boolean getFileByNameValuePair(java.lang.String rootName,
                                             DomPath domPath,
                                             java.io.File xmlFile,
                                             java.lang.String value)
                                      throws DweezilXMLException
Identifies the file using domPath and its value

Parameters:
rootName - the name of the documents root element
domPath - the domPath of the element concerned
xmlFile - the XML file of the document concerned
value - the value of the element we are searching for
Returns:
the true/false depending on whether element was found or not
Throws:
DweezilXMLException

getElementValuesFromFileByName

public static java.util.ArrayList getElementValuesFromFileByName(java.io.File source,
                                                                 java.io.File stylesheet)
                                                          throws DweezilXMLException
Gets all values of a particular element using its name from the file

Parameters:
source - the XML file
stylesheet - the XSLT stylesheet to be used for transformations and obtaining data
Returns:
all values of the element
Throws:
DweezilXMLException

getMetadataFile

public static java.io.File getMetadataFile(java.io.File source,
                                           java.io.File stylesheet,
                                           java.lang.String filename)
                                    throws DweezilXMLException
Gets the metadata file

Parameters:
source - the XML file
stylesheet - the XSLT stylesheet to be used for transformations and obtaining data
filename - the filename to be used for the metadata file
Returns:
the metadata file created
Throws:
DweezilXMLException

VdexReload 1.1.3 API