org.globus.ogsa.impl.base.servicegroup.common
Class XMLUtil

java.lang.Object
  extended byorg.globus.ogsa.impl.base.servicegroup.common.XMLUtil

public class XMLUtil
extends java.lang.Object

XML Utilities class.


Constructor Summary
XMLUtil()
           
 
Method Summary
static java.lang.String denormalize(java.lang.String anXMLAttrValue)
          Denormalizes a string containing XML attribute name/value pairs.
static java.lang.String docToString(org.w3c.dom.Document aDoc)
          Converts XML from a Document to a String
static java.lang.String elementToString(org.w3c.dom.Element anElement)
          Converts an XML Element to String representation.
static java.lang.String getElementValue(org.w3c.dom.Element anElement)
          Gets the value of an Element in String representation.
static org.w3c.dom.Node getNode(org.w3c.dom.Node aParentNode, java.lang.String anXPath)
          Applies an XPath query to a Node, returns the result as a Node.
static org.w3c.dom.Node getNSNode(java.util.HashMap namespaceMap)
          Creates a Node containing all of the namespaces contained in a HashMap.
static org.w3c.dom.Document load(java.lang.String aFilePath)
          Loads the contents of a file into an XML Document
static void removeElementValue(org.w3c.dom.Element anElement)
          Strips child Nodes from an Element.
static void save(java.lang.String aFilePath, org.w3c.dom.Document aDocument)
          Writes an XML Document to a file.
static void setElementValue(org.w3c.dom.Element anElement, java.lang.String anElementValue)
          Sets the value of an Element
static org.w3c.dom.Document stringToDoc(java.lang.String anXMLDocInStringFormat)
          Creates a Document from an XML document in String format.
 
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

setElementValue

public static void setElementValue(org.w3c.dom.Element anElement,
                                   java.lang.String anElementValue)
                            throws org.w3c.dom.DOMException
Sets the value of an Element

Parameters:
anElement - - the Element whose value may change.
anElementValue - - value to apply to the Elem
Throws:
org.w3c.dom.DOMException

getElementValue

public static java.lang.String getElementValue(org.w3c.dom.Element anElement)
                                        throws org.w3c.dom.DOMException
Gets the value of an Element in String representation.

Parameters:
anElement - - the Element to process
Returns:
the Element converted to String
Throws:
org.w3c.dom.DOMException

removeElementValue

public static void removeElementValue(org.w3c.dom.Element anElement)
                               throws org.w3c.dom.DOMException
Strips child Nodes from an Element.

Parameters:
anElement - - the Element to process
Throws:
org.w3c.dom.DOMException

getNode

public static org.w3c.dom.Node getNode(org.w3c.dom.Node aParentNode,
                                       java.lang.String anXPath)
                                throws javax.xml.transform.TransformerException
Applies an XPath query to a Node, returns the result as a Node.

Parameters:
aParentNode - - parent Node to query against
anXPath - - the XPath query string
Returns:
result of XPath application.
Throws:
javax.xml.transform.TransformerException

elementToString

public static java.lang.String elementToString(org.w3c.dom.Element anElement)
                                        throws java.io.IOException
Converts an XML Element to String representation.

Parameters:
anElement - - the input Element for conversion to String
Returns:
the string representation of input Element.
Throws:
java.io.IOException

docToString

public static java.lang.String docToString(org.w3c.dom.Document aDoc)
                                    throws java.io.IOException
Converts XML from a Document to a String

Parameters:
aDoc - - the XML Document to convert
Returns:
the string representation of the input Document
Throws:
java.io.IOException

load

public static org.w3c.dom.Document load(java.lang.String aFilePath)
                                 throws java.io.FileNotFoundException,
                                        java.io.IOException,
                                        javax.xml.parsers.ParserConfigurationException,
                                        org.xml.sax.SAXException
Loads the contents of a file into an XML Document

Parameters:
aFilePath - - the filepath to load.
Returns:
DOM representation of the file contents
Throws:
java.io.FileNotFoundException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

save

public static void save(java.lang.String aFilePath,
                        org.w3c.dom.Document aDocument)
                 throws java.io.IOException
Writes an XML Document to a file.

Parameters:
aFilePath - - the filepath of the output file
aDocument - - the XML document to save
Throws:
java.io.IOException

stringToDoc

public static org.w3c.dom.Document stringToDoc(java.lang.String anXMLDocInStringFormat)
                                        throws java.io.IOException,
                                               javax.xml.parsers.ParserConfigurationException,
                                               org.xml.sax.SAXException
Creates a Document from an XML document in String format.

Parameters:
anXMLDocInStringFormat - - the XML document in String format.
Returns:
the XML in Document form.
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

denormalize

public static java.lang.String denormalize(java.lang.String anXMLAttrValue)
Denormalizes a string containing XML attribute name/value pairs.

Parameters:
anXMLAttrValue - - the XML attribute values
Returns:
the denormalized input string.
Throws:
org.w3c.dom.DOMException

getNSNode

public static org.w3c.dom.Node getNSNode(java.util.HashMap namespaceMap)
Creates a Node containing all of the namespaces contained in a HashMap.

Parameters:
namespaceMap - - the namespace Map
Returns:
the namespace Node