Package com.webmethods.caf.common
Class XMLUtil
java.lang.Object
com.webmethods.caf.common.XMLUtil
Utility class for loading XML documents
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static Document
_loadDocument
(InputSource inputSource) loads an xml document from the xslt input sourcestatic void
deletes the comment nodes and text nodes with all empty spaces.static DocumentBuilderFactory
getMapFromElementAttributes
(Element element) Constructs aMap
from the attributes on the given element.static SAXParserFactory
static Source
getSAXSource
(Reader inputReader) static XMLReader
Convenience to get default xml parser.static Document
loadDocumentFromReader
(Reader reader) loads an xml document by the suplied java.io.Readerstatic Document
Load XML (String format) into a Documentstatic String
Serialize the element
-
Constructor Details
-
XMLUtil
public XMLUtil()
-
-
Method Details
-
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
-
getBuilderFactory
-
serialize
Serialize the element- Parameters:
elem
- null or Element- Returns:
- Serialized version of element
- Throws:
IOException
-
getMapFromElementAttributes
Constructs aMap
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)
-
clean
deletes the comment nodes and text nodes with all empty spaces. If the text node has some value, value will be trimmed -
getXMLParser
Convenience to get default xml parser.- Throws:
SAXException
-
getSAXParserFactory
-
getSAXSource
- Throws:
IOException
-