com.caucho.xml2
Class XmlUtil

java.lang.Object
  extended by com.caucho.xml2.XmlUtil

public class XmlUtil
extends java.lang.Object

XML utilities for manipulating names and the DOM.


Constructor Summary
XmlUtil()
           
 
Method Summary
static java.lang.String getNamespace(org.w3c.dom.Node node, java.lang.String prefix)
          Returns the namespace for the given prefix.
static org.w3c.dom.Node getNext(org.w3c.dom.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 org.w3c.dom.Node getPrevious(org.w3c.dom.Node node)
          Get the previous node in a DFS preorder traversal
static boolean isWhitespace(java.lang.String text)
          Extracts the text value from the node.
static java.util.HashMap<java.lang.String,java.lang.String> splitNameList(java.lang.String name)
          Treats the string as an attribute list, splitting it into a HashMap.
static void textValue(CharBuffer cb, org.w3c.dom.Node node)
          Extracts the text value from the node.
static java.lang.String textValue(org.w3c.dom.Node node)
          Extracts the text value from the node.
static void toSAX(org.w3c.dom.Node node, org.xml.sax.ContentHandler handler)
          Sends data to the helper.
 
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<java.lang.String,java.lang.String> 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.
Throws:
java.io.IOException

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 org.w3c.dom.Node getNext(org.w3c.dom.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 org.w3c.dom.Node getPrevious(org.w3c.dom.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(org.w3c.dom.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,
                             org.w3c.dom.Node node)
Extracts the text value from the node. Text nodes return their value and elements return the concatenation of the child values.


isWhitespace

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


toSAX

public static void toSAX(org.w3c.dom.Node node,
                         org.xml.sax.ContentHandler handler)
                  throws org.xml.sax.SAXException
Sends data to the helper.

Throws:
org.xml.sax.SAXException

getNamespace

public static java.lang.String getNamespace(org.w3c.dom.Node node,
                                            java.lang.String prefix)
Returns the namespace for the given prefix.