com.webmethods.caf.common
Class XMLUtil

java.lang.Object
  extended by com.webmethods.caf.common.XMLUtil

public class XMLUtil
extends Object

Utility class for loading XML documents


Constructor Summary
XMLUtil()
           
 
Method Summary
protected static Document _loadDocument(InputSource inputSource)
          loads an xml document from the xslt input source
static Map getMapFromElementAttributes(Element element)
          Constructs a Map from the attributes on the given element.
static Document loadDocumentFromReader(Reader reader)
          loads an xml document by the suplied java.io.Reader
static Document loadDocumentFromXML(String xml)
          Load XML (String format) into a Document
static String serialize(Element elem)
          Serialize the element
 
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

loadDocumentFromXML

public static Document loadDocumentFromXML(String xml)
                                    throws ParserConfigurationException,
                                           FactoryConfigurationError,
                                           SAXException,
                                           IOException
Load XML (String format) into a Document

Parameters:
xml - String in XML format
Returns:
Document containing XML content
Throws:
ParserConfigurationException
FactoryConfigurationError
SAXException
IOException

loadDocumentFromReader

public static Document loadDocumentFromReader(Reader reader)
                                       throws ParserConfigurationException,
                                              FactoryConfigurationError,
                                              SAXException,
                                              IOException
loads an xml document by the suplied java.io.Reader

Parameters:
reader - is an open Reader to an xml document.
Throws:
ParserConfigurationException
FactoryConfigurationError
SAXException
IOException

_loadDocument

protected static Document _loadDocument(InputSource inputSource)
                                 throws ParserConfigurationException,
                                        FactoryConfigurationError,
                                        SAXException,
                                        IOException
loads an xml document from the xslt input source

Parameters:
inputSource - is the xslt input source
Throws:
ParserConfigurationException
FactoryConfigurationError
SAXException
IOException

serialize

public static String serialize(Element elem)
                        throws IOException
Serialize the element

Parameters:
elem - null or Element
Returns:
Serialized version of element
Throws:
IOException

getMapFromElementAttributes

public static Map getMapFromElementAttributes(Element element)
Constructs a Map from the attributes on the given element. namespaces are ignored.

Parameters:
element - the element to get the attributes from
Returns:
a map of the element's attributes as name-value pairs. (Ignoring namespaces)