com.caucho.xml
Class XmlUtil

java.lang.Object
  |
  +--com.caucho.xml.XmlUtil

public class XmlUtil
extends java.lang.Object

XML utilities for manipulating names and the DOM.


Constructor Summary
XmlUtil()
           
 
Method Summary
static Node getNext(Node node)
          Get the next node in a depth first preorder traversal.
static java.lang.String getPIAttribute(java.lang.String pi, java.lang.String key)
          Extracts an attribute from a processing instruction.
static Node getPrevious(Node node)
          Get the previous node in a DFS preorder traversal
static java.util.HashMap splitNameList(java.lang.String name)
          Treats the string as an attribute list, splitting it into a HashMap.
static void textValue(CharBuffer cb, Node node)
          Extracts the text value from the node.
static java.lang.String textValue(Node node)
          Extracts the text value from the node.
 
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

splitNameList

public static java.util.HashMap splitNameList(java.lang.String name)
                                       throws java.io.IOException
Treats the string as an attribute list, splitting it into a HashMap.
Parameters:
name - a string to be interpreted as an attribute list
Returns:
a hash map containing the attribute (key, value) pairs.

getPIAttribute

public static java.lang.String getPIAttribute(java.lang.String pi,
                                              java.lang.String key)
Extracts an attribute from a processing instruction. Since processing instructions are opaque, the standard DOM has no API for the common case where the PI value is an attribute list.
   <?xml-stylesheet href="default.xsl"?>
 

In the above example,

getPIAttribute(node.getNodeValue(), "href")
would return "default.xsl".
Parameters:
pi - the value of the processing instruction
key - the attribute key
Returns:
the value corresponding to the attribute key.

getNext

public static Node getNext(Node node)
Get the next node in a depth first preorder traversal.
Parameters:
node - the current node
Returns:
the next node in the preorder traversal

getPrevious

public static Node getPrevious(Node node)
Get the previous node in a DFS preorder traversal
Parameters:
node - the current node
Returns:
the previous node in the preorder traversal

textValue

public static java.lang.String textValue(Node node)
Extracts the text value from the node. Text nodes return their value and elements return the concatenation of the child values.

textValue

public static void textValue(CharBuffer cb,
                             Node node)
Extracts the text value from the node. Text nodes return their value and elements return the concatenation of the child values.