uPortal 2.4.1
API Documentation

org.jasig.portal.utils
Class XML

java.lang.Object
  extended byorg.jasig.portal.utils.XML

public class XML
extends java.lang.Object

This utility provides useful XML helper methods.

Version:
$Revision: 1.17 $
Author:
Ken Weiner, kweiner@unicon.net

Constructor Summary
XML()
           
 
Method Summary
static org.w3c.dom.Document cloneDocument(org.w3c.dom.Document olddoc)
          This is only being kept around for backward compatibility.
static void dom2sax(org.w3c.dom.Node dom, org.xml.sax.ContentHandler sax)
          Outputs a dom document into a sax stream.
static java.lang.String getChildElementText(org.w3c.dom.Element e, java.lang.String childElementName)
          Gets the text value of a child Element.
static java.lang.String getElementText(org.w3c.dom.Element e)
          Gets the text value of an Element.
static java.lang.String serializeNode(org.w3c.dom.Node node)
          Gets the contents of an XML Document or Element as a nicely formatted string.
static java.lang.String serializeNode(org.w3c.dom.Node node, OutputFormat format)
          Gets the contents of an XML Document or Element as a formatted string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XML

public XML()
Method Detail

getElementText

public static java.lang.String getElementText(org.w3c.dom.Element e)
Gets the text value of an Element. For example, if an element nameElement looks like this: Fred, then getElementText(nameElement) would return "Fred". An empty String is returned in the case that there is no text under the element.

Parameters:
e - the Element with a text value
Returns:
the the text value of the element

getChildElementText

public static java.lang.String getChildElementText(org.w3c.dom.Element e,
                                                   java.lang.String childElementName)
Gets the text value of a child Element. For example, if an element nameElement looks like this: FredFlinstone, then getChildElementText(nameElement, "first") would return "Fred". An empty String is returned in the case that there is no text under the child Element.

Parameters:
e - the Element to search under
childElementName - the name of the child Element
Returns:
the text value of the child element

serializeNode

public static java.lang.String serializeNode(org.w3c.dom.Node node)
Gets the contents of an XML Document or Element as a nicely formatted string. This method is useful for debugging.

Parameters:
node - the Node to print; must be of type Document or Element
Returns:
a nicely formatted String suitable for printing

serializeNode

public static java.lang.String serializeNode(org.w3c.dom.Node node,
                                             OutputFormat format)
Gets the contents of an XML Document or Element as a formatted string. This method is useful for debugging.

Parameters:
node - the Node to print; must be of type Document or Element
format - controls the formatting of the string
Returns:
a nicely formatted String suitable for printing

cloneDocument

public static org.w3c.dom.Document cloneDocument(org.w3c.dom.Document olddoc)
This is only being kept around for backward compatibility. Callers should now be using Document.cloneNode(true).

Parameters:
olddoc - the original document
Returns:
a clone of the original document with preserved ID tables

dom2sax

public static void dom2sax(org.w3c.dom.Node dom,
                           org.xml.sax.ContentHandler sax)
                    throws javax.xml.transform.TransformerConfigurationException,
                           javax.xml.transform.TransformerException
Outputs a dom document into a sax stream.

Parameters:
dom - a dom Node value
sax - a sax ContentHandler value
Throws:
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

uPortal 2.4.1
API Documentation