org.jafer.util.xml
Class DomUtils

java.lang.Object
  extended by org.jafer.util.xml.DomUtils

public class DomUtils
extends java.lang.Object


Field Summary
private static javax.xml.parsers.DocumentBuilderFactory factory
           
 
Constructor Summary
DomUtils()
           
 
Method Summary
static java.lang.String getChildTextValue(org.w3c.dom.Element node, java.lang.String child)
          Get the text node from an element node.
static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
          Gets the DocumentBuilder for parsing xml documents.
static java.lang.String getElementTextByAttr(org.w3c.dom.Element modsroot, java.lang.String nodename, java.lang.String attrname, java.lang.String attrvalue)
          Retrieves text of element by attribute value (e.g.
static java.lang.String getNodeAsString(org.w3c.dom.Node node)
           
static java.lang.String getSubNodeText(org.w3c.dom.Element modsroot, java.lang.String nodename, java.lang.String subnodename)
          Retrieves name/subname text value.
static java.lang.String getSubSubNodeText(org.w3c.dom.Element modsroot, java.lang.String nodename, java.lang.String subnodename, java.lang.String subsubnodename)
          Retrieves name/subname/subsub text value.
static java.lang.String getTextFields(org.w3c.dom.NodeList list)
          Extracts all text values from a list of Element nodes.
static java.lang.String getTextValue(org.w3c.dom.Node node)
          Get the text node from an element node.
static boolean hasElementWithAttr(org.w3c.dom.Element modsroot, java.lang.String nodename, java.lang.String attrname, java.lang.String attrvalue)
           
static org.w3c.dom.Document newDocument()
          Gets an empty Document for manipulating with DOM..
static org.w3c.dom.Document parse(java.lang.String data)
          Parses an xml document.
static void setElementTextByAttr(org.w3c.dom.Element modsroot, java.lang.String nodename, java.lang.String attrname, java.lang.String attrvalue, java.lang.String newValue)
          Sets text of element by attribute value (e.g.
static void setTextValue(org.w3c.dom.Node node, java.lang.String newValue)
          set the text node from an element node.
static void transform(org.w3c.dom.Node sourceNode, java.io.Writer writer)
          Transforms a DOM node to a string and writes it to a writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

private static javax.xml.parsers.DocumentBuilderFactory factory
Constructor Detail

DomUtils

public DomUtils()
Method Detail

getElementTextByAttr

public static java.lang.String getElementTextByAttr(org.w3c.dom.Element modsroot,
                                                    java.lang.String nodename,
                                                    java.lang.String attrname,
                                                    java.lang.String attrvalue)
Retrieves text of element by attribute value (e.g. xxx ).


hasElementWithAttr

public static boolean hasElementWithAttr(org.w3c.dom.Element modsroot,
                                         java.lang.String nodename,
                                         java.lang.String attrname,
                                         java.lang.String attrvalue)

setElementTextByAttr

public static void setElementTextByAttr(org.w3c.dom.Element modsroot,
                                        java.lang.String nodename,
                                        java.lang.String attrname,
                                        java.lang.String attrvalue,
                                        java.lang.String newValue)
Sets text of element by attribute value (e.g. xxx ).


getSubNodeText

public static java.lang.String getSubNodeText(org.w3c.dom.Element modsroot,
                                              java.lang.String nodename,
                                              java.lang.String subnodename)
Retrieves name/subname text value.


getSubSubNodeText

public static java.lang.String getSubSubNodeText(org.w3c.dom.Element modsroot,
                                                 java.lang.String nodename,
                                                 java.lang.String subnodename,
                                                 java.lang.String subsubnodename)
Retrieves name/subname/subsub text value.


getTextFields

public static java.lang.String getTextFields(org.w3c.dom.NodeList list)
Extracts all text values from a list of Element nodes. Appends them with '\n' preceding


getTextValue

public static java.lang.String getTextValue(org.w3c.dom.Node node)
Get the text node from an element node.


setTextValue

public static void setTextValue(org.w3c.dom.Node node,
                                java.lang.String newValue)
set the text node from an element node.


getChildTextValue

public static java.lang.String getChildTextValue(org.w3c.dom.Element node,
                                                 java.lang.String child)
Get the text node from an element node.


getNodeAsString

public static java.lang.String getNodeAsString(org.w3c.dom.Node node)
                                        throws DomUtilsException
Throws:
DomUtilsException

getDocumentBuilder

public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
                                                            throws DomUtilsException
Gets the DocumentBuilder for parsing xml documents.

Throws:
DomUtilsException

newDocument

public static org.w3c.dom.Document newDocument()
                                        throws DomUtilsException
Gets an empty Document for manipulating with DOM..

Throws:
DomUtilsException

parse

public static org.w3c.dom.Document parse(java.lang.String data)
                                  throws DomUtilsException
Parses an xml document.

Throws:
DomUtilsException

transform

public static void transform(org.w3c.dom.Node sourceNode,
                             java.io.Writer writer)
                      throws DomUtilsException
Transforms a DOM node to a string and writes it to a writer.

Throws:
DomUtilsException