| java.lang.Object edu.iu.uis.eden.util.XmlHelper
XmlHelper | public class XmlHelper (Code) | | Provides a set of utilities for XML-related operations.
author: rkirkend author: ewestfal author: ahamid |
Field Summary | |
final protected static org.apache.log4j.Logger | LOG |
Method Summary | |
public static void | appendXml(Node parentNode, String xml) | public static org.jdom.Document | buildJDocument(StringReader xmlStream) | public static org.jdom.Document | buildJDocument(org.w3c.dom.Document document) | public static org.jdom.Document | buildJDocument(StringReader xmlStream, boolean validateXML) Same as above but can specify whether validation is to be performed or
not. | public static Element | findElement(Element root, String elementName) returns the one element in root according to elementName. | public static Vector | findElements(Element root, String elementName) | public static Element | getAttributeElement(Document document, String elementName) | public static Element | getAttributeRootElement(Document document) | public static String | getElementAttributeValue(Element root, String elementName, String attributeName) Returns the value of the given element names given attribute tag based
upon the root element passed in. | public static String | getTextContent(org.w3c.dom.Element element) | public static String | jotDocument(org.jdom.Document document) | public static String | jotNode(org.jdom.Element element) | public static String | jotNode(org.w3c.dom.Node node) | public static String | jotNode(org.w3c.dom.Node node, boolean indent) | public static Element | makeElement(String elementName, String value) | public static boolean | pathExists(XPath xpath, String expression, Object object) Convenience method that performs an xpath evaluation to determine whether the expression
evaluates to true (a node exists). | public static void | printDocumentStructure(org.w3c.dom.Document doc) | public static void | printNode(Node node, int level) | public static void | printSAXDocumentStructure(Document doc) | public static void | printSAXNode(Element element, int level) | public static org.w3c.dom.Element | propertiesToXml(org.w3c.dom.Document doc, Object o, String elementName) | public static void | propogateNamespace(Element element, Namespace namespace) | public static org.w3c.dom.Document | readXml(String xml) | public static String | readerToString(Reader is) | public static void | trimElement(Node node) | public static void | trimSAXElement(Element element) | public static Document | trimSAXXml(InputStream input) | public static org.w3c.dom.Document | trimXml(InputStream input) | public static void | validate(InputSource source) | public static String | writeNode(org.w3c.dom.Node node) | public static String | writeNode(org.w3c.dom.Node node, boolean indent) |
LOG | final protected static org.apache.log4j.Logger LOG(Code) | | |
XmlHelper | public XmlHelper()(Code) | | |
buildJDocument | public static org.jdom.Document buildJDocument(StringReader xmlStream, boolean validateXML) throws InvalidXmlException(Code) | | Same as above but can specify whether validation is to be performed or
not. Would have liked to have added a property that these methods could
have used but would force instantiate on an otherwise static class
Parameters: xmlSream - Parameters: validateXML - JDOM Document throws: InvalidXMLException - |
findElement | public static Element findElement(Element root, String elementName) throws InvalidXmlException(Code) | | returns the one element in root according to elementName. If more than
one or none of element exists InvalidXmlException is thrown. This method
is based on the assumption you have validated your xml and know the
element is there. It provides a way to make code independent of the xml
structure i.e. it digs for the element.
Parameters: root - Parameters: elementName - Element throws: InvalidXmlException - |
findElements | public static Vector findElements(Element root, String elementName)(Code) | | Find all Elements in document of a particular name
Parameters: root - -the starting Element to scan Parameters: elementName - -name of the Element to scan for Vector - a list of the Elements found - return null if none found |
getElementAttributeValue | public static String getElementAttributeValue(Element root, String elementName, String attributeName) throws InvalidXmlException(Code) | | Returns the value of the given element names given attribute tag based
upon the root element passed in.
Parameters: root - Parameters: elementName - Parameters: attributeName - value of the Element's attribute who's name matches the passedelement name and attribute matches the attribute name passes throws: InvalidXmlException - if element or attribute are not present |
jotDocument | public static String jotDocument(org.jdom.Document document)(Code) | | |
jotNode | public static String jotNode(org.jdom.Element element)(Code) | | |
makeElement | public static Element makeElement(String elementName, String value) throws Exception(Code) | | makes a properly formed element in the manner of
if value is null value attribute is given an empty value
Parameters: elementName - Parameters: value - Element throws: Exception - |
pathExists | public static boolean pathExists(XPath xpath, String expression, Object object) throws XPathExpressionException(Code) | | Convenience method that performs an xpath evaluation to determine whether the expression
evaluates to true (a node exists).
This is method exists only to disambiguate the cases of determining the *presence* of a node
and determining the *boolean value of the node as converted from a string*, as the syntaxes
are very similar and could be misleading.
Parameters: xpath - the XPath object Parameters: expression - the XPath expression Parameters: object - the object on which to evaluate the expression as required by the XPath API, typically a Node whether the result of the expression evaluation, which is whether or not a node was present throws: XPathExpressionException - |
printNode | public static void printNode(Node node, int level)(Code) | | |
printSAXDocumentStructure | public static void printSAXDocumentStructure(Document doc)(Code) | | |
printSAXNode | public static void printSAXNode(Element element, int level)(Code) | | |
propogateNamespace | public static void propogateNamespace(Element element, Namespace namespace)(Code) | | |
|
|