org.dspace.app.webui.util
Class XMLUtil

java.lang.Object
  extended by org.dspace.app.webui.util.XMLUtil

public class XMLUtil
extends java.lang.Object

This class provides a set of static methods to load and transform XML documents. It supports parameter-aware stylesheets (XSLT).

Author:
Miguel Ferreira

Constructor Summary
XMLUtil()
           
 
Method Summary
static org.w3c.dom.Document loadXML(java.lang.String filename)
          Loads a W3C XML document from a file.
static org.w3c.dom.Document transformDocument(org.w3c.dom.Document xmlDocument, java.util.Map<java.lang.String,java.lang.String> parameters, java.lang.String xsltFilename)
          Applies a stylesheet (that receives parameters) to a given xml document.
static org.w3c.dom.Document transformDocument(org.w3c.dom.Document xmlDocument, java.lang.String xsltFilename)
          Applies a stylesheet to a given xml document.
static java.lang.String transformDocumentAsString(org.w3c.dom.Document xmlDocument, java.util.Map<java.lang.String,java.lang.String> parameters, java.lang.String xsltFilename)
          Applies a stylesheet (that receives parameters) to a given xml document.
static java.lang.String transformDocumentAsString(org.w3c.dom.Document xmlDocument, java.lang.String xsltFilename)
          Applies a stylesheet to a given xml document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

loadXML

public static org.w3c.dom.Document loadXML(java.lang.String filename)
                                    throws java.io.IOException,
                                           javax.xml.parsers.ParserConfigurationException,
                                           org.xml.sax.SAXException
Loads a W3C XML document from a file.

Parameters:
filename - The name of the file to be loaded
Returns:
a document object model object representing the XML file
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

transformDocument

public static org.w3c.dom.Document transformDocument(org.w3c.dom.Document xmlDocument,
                                                     java.lang.String xsltFilename)
                                              throws java.lang.Exception
Applies a stylesheet to a given xml document.

Parameters:
xmlDocument - the xml document to be transformed
xsltFilename - the filename of the stylesheet
Returns:
the transformed xml document
Throws:
java.lang.Exception

transformDocument

public static org.w3c.dom.Document transformDocument(org.w3c.dom.Document xmlDocument,
                                                     java.util.Map<java.lang.String,java.lang.String> parameters,
                                                     java.lang.String xsltFilename)
                                              throws java.lang.Exception
Applies a stylesheet (that receives parameters) to a given xml document.

Parameters:
xmlDocument - the xml document to be transformed
parameters - the hashtable with the parameters to be passed to the stylesheet
xsltFilename - the filename of the stylesheet
Returns:
the transformed xml document
Throws:
java.lang.Exception

transformDocumentAsString

public static java.lang.String transformDocumentAsString(org.w3c.dom.Document xmlDocument,
                                                         java.util.Map<java.lang.String,java.lang.String> parameters,
                                                         java.lang.String xsltFilename)
                                                  throws java.lang.Exception
Applies a stylesheet (that receives parameters) to a given xml document. The resulting XML document is converted to a string after transformation.

Parameters:
xmlDocument - the xml document to be transformed
parameters - the hashtable with the parameters to be passed to the stylesheet
xsltFilename - the filename of the stylesheet
Returns:
the transformed xml document as a string
Throws:
java.lang.Exception

transformDocumentAsString

public static java.lang.String transformDocumentAsString(org.w3c.dom.Document xmlDocument,
                                                         java.lang.String xsltFilename)
                                                  throws java.lang.Exception
Applies a stylesheet to a given xml document.

Parameters:
xmlDocument - the xml document to be transformed
xsltFilename - the filename of the stylesheet
Returns:
the transformed xml document
Throws:
java.lang.Exception


Copyright © 2010 DuraSpace. All Rights Reserved.