org.ofbiz.base.util
Class UtilXml

java.lang.Object
  extended by org.ofbiz.base.util.UtilXml

public class UtilXml
extends java.lang.Object

Utilities methods to simplify dealing with JAXP & DOM XML parsing


Nested Class Summary
static class UtilXml.LocalErrorHandler
          Local error handler for entity resolver to DocumentBuilder parser.
static class UtilXml.LocalResolver
          Local entity resolver to handle J2EE DTDs.
 
Field Summary
static java.lang.String module
           
 
Constructor Summary
UtilXml()
           
 
Method Summary
static org.w3c.dom.Element addChildElement(org.w3c.dom.Element element, java.lang.String childElementName, org.w3c.dom.Document document)
          Creates a child element with the given name and appends it to the element child node list.
static org.w3c.dom.Element addChildElementCDATAValue(org.w3c.dom.Element element, java.lang.String childElementName, java.lang.String childElementValue, org.w3c.dom.Document document)
          Creates a child element with the given name and appends it to the element child node list.
static org.w3c.dom.Element addChildElementValue(org.w3c.dom.Element element, java.lang.String childElementName, java.lang.String childElementValue, org.w3c.dom.Document document)
          Creates a child element with the given name and appends it to the element child node list.
static boolean checkBoolean(java.lang.String str)
           
static boolean checkBoolean(java.lang.String str, boolean defaultValue)
           
static java.lang.String checkEmpty(java.lang.String string)
           
static java.lang.String checkEmpty(java.lang.String string1, java.lang.String string2)
           
static java.lang.String checkEmpty(java.lang.String string1, java.lang.String string2, java.lang.String string3)
           
static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.DocumentFragment fragment)
          Return a List of Element objects that are children of the given DocumentFragment
static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.Element element)
          Return a List of Element objects that are children of the given element
static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.Element element, java.util.Set<java.lang.String> childElementNames)
          Return a List of Element objects that have the given name and are immediate children of the given element; if name is null, all child elements will be included.
static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.Element element, java.lang.String... childElementNames)
          Return a List of Element objects that have the given name and are immediate children of the given element; if name is null, all child elements will be included.
static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.Element element, java.lang.String childElementName)
          Return a List of Element objects that have the given name and are immediate children of the given element; if name is null, all child elements will be included.
static java.lang.String childElementValue(org.w3c.dom.Element element, java.lang.String childElementName)
          Return the text (node value) contained by the named child node.
static java.lang.String childElementValue(org.w3c.dom.Element element, java.lang.String childElementName, java.lang.String defaultValue)
          Return the text (node value) contained by the named child node or a default value if null.
static java.util.List<? extends org.w3c.dom.Node> childNodeList(org.w3c.dom.Node node)
          Return a List of Node objects that have the given name and are immediate children of the given element; if name is null, all child elements will be included.
static java.lang.String elementValue(org.w3c.dom.Element element)
          Return the text (node value) of the first node under this, works best if normalized.
static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element)
          Return the first child Element returns the first element.
static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element, java.util.Set<java.lang.String> childElementNames)
          Return the first child Element returns the first element.
static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element, java.lang.String... childElementNames)
          Return the first child Element returns the first element.
static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element, java.lang.String childElementName)
          Return the first child Element with the given name; if name is null returns the first element.
static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element, java.lang.String childElementName, java.lang.String attrName, java.lang.String attrValue)
          Return the first child Element with the given name; if name is null returns the first element.
static org.w3c.dom.Document makeEmptyXmlDocument()
           
static org.w3c.dom.Document makeEmptyXmlDocument(java.lang.String rootElementName)
           
static java.lang.String nodeValue(org.w3c.dom.Node node)
          Return the text (node value) of the first node under this
static org.w3c.dom.Document readXmlDocument(java.io.InputStream is)
          Deprecated.  
static org.w3c.dom.Document readXmlDocument(java.io.InputStream is, boolean validate, java.lang.String docDescription)
           
static org.w3c.dom.Document readXmlDocument(java.io.InputStream is, java.lang.String docDescription)
           
static org.w3c.dom.Document readXmlDocument(java.lang.String content)
           
static org.w3c.dom.Document readXmlDocument(java.lang.String content, boolean validate)
           
static org.w3c.dom.Document readXmlDocument(java.net.URL url)
           
static org.w3c.dom.Document readXmlDocument(java.net.URL url, boolean validate)
           
static java.lang.String writeXmlDocument(org.w3c.dom.Document document)
           
static java.lang.String writeXmlDocument(org.w3c.dom.DocumentFragment fragment)
           
static java.lang.String writeXmlDocument(org.w3c.dom.Element element)
           
static void writeXmlDocument(java.io.OutputStream os, org.w3c.dom.Document document)
           
static void writeXmlDocument(java.io.OutputStream os, org.w3c.dom.Element element)
           
static void writeXmlDocument(java.io.OutputStream os, org.w3c.dom.Element element, org.apache.xml.serialize.OutputFormat format)
           
static void writeXmlDocument(java.lang.String filename, org.w3c.dom.Document document)
           
static void writeXmlDocument(java.lang.String filename, org.w3c.dom.Element element)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module
Constructor Detail

UtilXml

public UtilXml()
Method Detail

writeXmlDocument

public static java.lang.String writeXmlDocument(org.w3c.dom.Document document)
                                         throws java.io.IOException
Throws:
java.io.IOException

writeXmlDocument

public static java.lang.String writeXmlDocument(org.w3c.dom.Element element)
                                         throws java.io.IOException
Throws:
java.io.IOException

writeXmlDocument

public static java.lang.String writeXmlDocument(org.w3c.dom.DocumentFragment fragment)
                                         throws java.io.IOException
Throws:
java.io.IOException

writeXmlDocument

public static void writeXmlDocument(java.lang.String filename,
                                    org.w3c.dom.Document document)
                             throws java.io.FileNotFoundException,
                                    java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

writeXmlDocument

public static void writeXmlDocument(java.lang.String filename,
                                    org.w3c.dom.Element element)
                             throws java.io.FileNotFoundException,
                                    java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

writeXmlDocument

public static void writeXmlDocument(java.io.OutputStream os,
                                    org.w3c.dom.Document document)
                             throws java.io.IOException
Throws:
java.io.IOException

writeXmlDocument

public static void writeXmlDocument(java.io.OutputStream os,
                                    org.w3c.dom.Element element)
                             throws java.io.IOException
Throws:
java.io.IOException

writeXmlDocument

public static void writeXmlDocument(java.io.OutputStream os,
                                    org.w3c.dom.Element element,
                                    org.apache.xml.serialize.OutputFormat format)
                             throws java.io.IOException
Throws:
java.io.IOException

readXmlDocument

public static org.w3c.dom.Document readXmlDocument(java.lang.String content)
                                            throws org.xml.sax.SAXException,
                                                   javax.xml.parsers.ParserConfigurationException,
                                                   java.io.IOException
Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException

readXmlDocument

public static org.w3c.dom.Document readXmlDocument(java.lang.String content,
                                                   boolean validate)
                                            throws org.xml.sax.SAXException,
                                                   javax.xml.parsers.ParserConfigurationException,
                                                   java.io.IOException
Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException

readXmlDocument

public static org.w3c.dom.Document readXmlDocument(java.net.URL url)
                                            throws org.xml.sax.SAXException,
                                                   javax.xml.parsers.ParserConfigurationException,
                                                   java.io.IOException
Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException

readXmlDocument

public static org.w3c.dom.Document readXmlDocument(java.net.URL url,
                                                   boolean validate)
                                            throws org.xml.sax.SAXException,
                                                   javax.xml.parsers.ParserConfigurationException,
                                                   java.io.IOException
Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException

readXmlDocument

public static org.w3c.dom.Document readXmlDocument(java.io.InputStream is)
                                            throws org.xml.sax.SAXException,
                                                   javax.xml.parsers.ParserConfigurationException,
                                                   java.io.IOException
Deprecated. 

Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException

readXmlDocument

public static org.w3c.dom.Document readXmlDocument(java.io.InputStream is,
                                                   java.lang.String docDescription)
                                            throws org.xml.sax.SAXException,
                                                   javax.xml.parsers.ParserConfigurationException,
                                                   java.io.IOException
Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException

readXmlDocument

public static org.w3c.dom.Document readXmlDocument(java.io.InputStream is,
                                                   boolean validate,
                                                   java.lang.String docDescription)
                                            throws org.xml.sax.SAXException,
                                                   javax.xml.parsers.ParserConfigurationException,
                                                   java.io.IOException
Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException

makeEmptyXmlDocument

public static org.w3c.dom.Document makeEmptyXmlDocument()

makeEmptyXmlDocument

public static org.w3c.dom.Document makeEmptyXmlDocument(java.lang.String rootElementName)

addChildElement

public static org.w3c.dom.Element addChildElement(org.w3c.dom.Element element,
                                                  java.lang.String childElementName,
                                                  org.w3c.dom.Document document)
Creates a child element with the given name and appends it to the element child node list.


addChildElementValue

public static org.w3c.dom.Element addChildElementValue(org.w3c.dom.Element element,
                                                       java.lang.String childElementName,
                                                       java.lang.String childElementValue,
                                                       org.w3c.dom.Document document)
Creates a child element with the given name and appends it to the element child node list. Also creates a Text node with the given value and appends it to the new elements child node list.


addChildElementCDATAValue

public static org.w3c.dom.Element addChildElementCDATAValue(org.w3c.dom.Element element,
                                                            java.lang.String childElementName,
                                                            java.lang.String childElementValue,
                                                            org.w3c.dom.Document document)
Creates a child element with the given name and appends it to the element child node list. Also creates a CDATASection node with the given value and appends it to the new elements child node list.


childElementList

public static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.Element element)
Return a List of Element objects that are children of the given element


childElementList

public static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.Element element,
                                                                             java.lang.String childElementName)
Return a List of Element objects that have the given name and are immediate children of the given element; if name is null, all child elements will be included.


childElementList

public static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.Element element,
                                                                             java.util.Set<java.lang.String> childElementNames)
Return a List of Element objects that have the given name and are immediate children of the given element; if name is null, all child elements will be included.


childElementList

public static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.Element element,
                                                                             java.lang.String... childElementNames)
Return a List of Element objects that have the given name and are immediate children of the given element; if name is null, all child elements will be included.


childElementList

public static java.util.List<? extends org.w3c.dom.Element> childElementList(org.w3c.dom.DocumentFragment fragment)
Return a List of Element objects that are children of the given DocumentFragment


childNodeList

public static java.util.List<? extends org.w3c.dom.Node> childNodeList(org.w3c.dom.Node node)
Return a List of Node objects that have the given name and are immediate children of the given element; if name is null, all child elements will be included.


firstChildElement

public static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element,
                                                    java.util.Set<java.lang.String> childElementNames)
Return the first child Element returns the first element.


firstChildElement

public static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element,
                                                    java.lang.String... childElementNames)
Return the first child Element returns the first element.


firstChildElement

public static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element)
Return the first child Element returns the first element.


firstChildElement

public static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element,
                                                    java.lang.String childElementName)
Return the first child Element with the given name; if name is null returns the first element.


firstChildElement

public static org.w3c.dom.Element firstChildElement(org.w3c.dom.Element element,
                                                    java.lang.String childElementName,
                                                    java.lang.String attrName,
                                                    java.lang.String attrValue)
Return the first child Element with the given name; if name is null returns the first element.


childElementValue

public static java.lang.String childElementValue(org.w3c.dom.Element element,
                                                 java.lang.String childElementName)
Return the text (node value) contained by the named child node.


childElementValue

public static java.lang.String childElementValue(org.w3c.dom.Element element,
                                                 java.lang.String childElementName,
                                                 java.lang.String defaultValue)
Return the text (node value) contained by the named child node or a default value if null.


elementValue

public static java.lang.String elementValue(org.w3c.dom.Element element)
Return the text (node value) of the first node under this, works best if normalized.


nodeValue

public static java.lang.String nodeValue(org.w3c.dom.Node node)
Return the text (node value) of the first node under this


checkEmpty

public static java.lang.String checkEmpty(java.lang.String string)

checkEmpty

public static java.lang.String checkEmpty(java.lang.String string1,
                                          java.lang.String string2)

checkEmpty

public static java.lang.String checkEmpty(java.lang.String string1,
                                          java.lang.String string2,
                                          java.lang.String string3)

checkBoolean

public static boolean checkBoolean(java.lang.String str)

checkBoolean

public static boolean checkBoolean(java.lang.String str,
                                   boolean defaultValue)