com.filenet.wcm.toolkit.server.util.xml
Class WcmXMLUtil

java.lang.Object
  extended bycom.filenet.wcm.toolkit.server.util.xml.WcmXMLUtil

public class WcmXMLUtil
extends java.lang.Object

Utility class for working with XML and DOM


Method Summary
static org.w3c.dom.Element addChildElement(org.w3c.dom.Element parent, java.lang.String childElementName)
           
static org.w3c.dom.Element addChildElement(org.w3c.dom.Element parent, java.lang.String childElementName, java.lang.String childElementText)
          Adds a new child node using the parent node namespace.
static org.w3c.dom.Element addChildElementNS(org.w3c.dom.Element parent, java.lang.String childElementName)
          Adds a new child node using the parent node namespace.
static org.w3c.dom.Element addChildElementNS(org.w3c.dom.Element parent, java.lang.String childElementName, java.lang.String childElementText)
           
static java.lang.String[] convertListOfNodesToStringArray(java.util.List nodes)
          Returns the result of Node.getNodeValue() method for each node in nodes
static java.lang.String[] convertNodeListOfElementsToStringArray(org.w3c.dom.NodeList elements)
          Returns the result of Node.getNodeValue() method for each node in nodes
static java.lang.String[] convertNodeListToStringArray(org.w3c.dom.NodeList nodes)
          Returns the result of Node.getNodeValue() method for each node in nodes
static org.w3c.dom.Element createNamespace(org.w3c.dom.Document doc, java.lang.String namespaceName, java.lang.String namespaceURI)
           
static java.lang.String decodeFromXML(java.lang.String str)
           
static java.lang.String encodeForXML(java.lang.String str)
           
static org.w3c.dom.Element getChildElement(org.w3c.dom.Element parent, java.lang.String childElementName)
           
static java.util.List getChildElements(org.w3c.dom.Element parentElement)
           
static java.util.List getChildElements(org.w3c.dom.Element parentElement, java.lang.String childElementName)
           
static java.lang.String getChildElementText(org.w3c.dom.Element parent, java.lang.String childElementName)
           
static org.w3c.dom.Node getChildNode(org.w3c.dom.Node node, java.lang.String childToFind)
           
static org.w3c.dom.Document getDocumentFromInputSource(org.xml.sax.InputSource inputSource)
           
static org.w3c.dom.Document getDocumentFromInputStream(java.io.InputStream inputStream)
           
static org.w3c.dom.Document getDocumentFromReader(java.io.Reader reader)
           
static org.w3c.dom.Document getDocumentFromString(java.lang.String xml)
           
static java.lang.String getElementCompleteText(org.w3c.dom.Element element)
           
static java.lang.String getElementText(org.w3c.dom.Element element)
           
static org.w3c.dom.Node getNamedNode(org.w3c.dom.NodeList nodes, java.lang.String nameToFind)
           
static org.w3c.dom.Document getNewDocument()
           
static void removeAllChildren(org.w3c.dom.Node node)
           
static java.lang.String saveToString(org.w3c.dom.Node node)
           
static void setElementText(org.w3c.dom.Element element, java.lang.String value)
           
static void writePrettyXML(java.io.Writer w, org.w3c.dom.Node node)
          Write XML for a node with newlines and indentation for each level of element nesting.
static void writeXML(java.io.OutputStream out, org.w3c.dom.Node node)
           
static void writeXML(java.io.Writer w, org.w3c.dom.Node node)
          Write XML for a node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writePrettyXML

public static void writePrettyXML(java.io.Writer w,
                                  org.w3c.dom.Node node)
Write XML for a node with newlines and indentation for each level of element nesting. Leaf elements are written out on a single line.

Parameters:
w -
node -

writeXML

public static void writeXML(java.io.Writer w,
                            org.w3c.dom.Node node)
Write XML for a node. XML is written out for maximum space and transport efficiency with no embedded blanks or newlines.

Parameters:
w -
node -

writeXML

public static void writeXML(java.io.OutputStream out,
                            org.w3c.dom.Node node)

getDocumentFromString

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

getDocumentFromReader

public static org.w3c.dom.Document getDocumentFromReader(java.io.Reader reader)
                                                  throws java.io.IOException,
                                                         org.xml.sax.SAXException,
                                                         javax.xml.parsers.ParserConfigurationException
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

getDocumentFromInputStream

public static org.w3c.dom.Document getDocumentFromInputStream(java.io.InputStream inputStream)
                                                       throws java.io.IOException,
                                                              org.xml.sax.SAXException,
                                                              javax.xml.parsers.ParserConfigurationException
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

getDocumentFromInputSource

public static org.w3c.dom.Document getDocumentFromInputSource(org.xml.sax.InputSource inputSource)
                                                       throws java.io.IOException,
                                                              org.xml.sax.SAXException,
                                                              javax.xml.parsers.ParserConfigurationException
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

getChildElement

public static org.w3c.dom.Element getChildElement(org.w3c.dom.Element parent,
                                                  java.lang.String childElementName)

getChildElementText

public static java.lang.String getChildElementText(org.w3c.dom.Element parent,
                                                   java.lang.String childElementName)

getChildElements

public static java.util.List getChildElements(org.w3c.dom.Element parentElement)

getChildElements

public static java.util.List getChildElements(org.w3c.dom.Element parentElement,
                                              java.lang.String childElementName)

getChildNode

public static org.w3c.dom.Node getChildNode(org.w3c.dom.Node node,
                                            java.lang.String childToFind)

getNamedNode

public static org.w3c.dom.Node getNamedNode(org.w3c.dom.NodeList nodes,
                                            java.lang.String nameToFind)

setElementText

public static void setElementText(org.w3c.dom.Element element,
                                  java.lang.String value)

getElementText

public static java.lang.String getElementText(org.w3c.dom.Element element)

addChildElement

public static org.w3c.dom.Element addChildElement(org.w3c.dom.Element parent,
                                                  java.lang.String childElementName)

addChildElementNS

public static org.w3c.dom.Element addChildElementNS(org.w3c.dom.Element parent,
                                                    java.lang.String childElementName)
Adds a new child node using the parent node namespace.

Parameters:
parent - Element The parent node.
childElementName - The tag name of the new child node
Returns:
Element The new child node.

addChildElement

public static org.w3c.dom.Element addChildElement(org.w3c.dom.Element parent,
                                                  java.lang.String childElementName,
                                                  java.lang.String childElementText)
Adds a new child node using the parent node namespace.

Parameters:
parent - Element The parent node.
childElementName - The tag name of the new child node
childElementText - The value of the new child node.
Returns:
Element The new child node.

addChildElementNS

public static org.w3c.dom.Element addChildElementNS(org.w3c.dom.Element parent,
                                                    java.lang.String childElementName,
                                                    java.lang.String childElementText)

getElementCompleteText

public static java.lang.String getElementCompleteText(org.w3c.dom.Element element)

removeAllChildren

public static void removeAllChildren(org.w3c.dom.Node node)

convertNodeListToStringArray

public static java.lang.String[] convertNodeListToStringArray(org.w3c.dom.NodeList nodes)
Returns the result of Node.getNodeValue() method for each node in nodes

Parameters:
nodes - NodeList - have to be Attr or Text nodes, not Elements
Returns:
String[] with the results

convertListOfNodesToStringArray

public static java.lang.String[] convertListOfNodesToStringArray(java.util.List nodes)
Returns the result of Node.getNodeValue() method for each node in nodes

Parameters:
nodes - List - have to be Attr or Text nodes, not Elements
Returns:
String[] with the results

convertNodeListOfElementsToStringArray

public static java.lang.String[] convertNodeListOfElementsToStringArray(org.w3c.dom.NodeList elements)
Returns the result of Node.getNodeValue() method for each node in nodes

Parameters:
elements - NodeList - have to be Element nodes
Returns:
String[] with the results

getNewDocument

public static org.w3c.dom.Document getNewDocument()
                                           throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

saveToString

public static java.lang.String saveToString(org.w3c.dom.Node node)

encodeForXML

public static java.lang.String encodeForXML(java.lang.String str)

decodeFromXML

public static java.lang.String decodeFromXML(java.lang.String str)

createNamespace

public static org.w3c.dom.Element createNamespace(org.w3c.dom.Document doc,
                                                  java.lang.String namespaceName,
                                                  java.lang.String namespaceURI)
                                           throws java.lang.Exception
Throws:
java.lang.Exception


© Copyright IBM Corp. 2002, 2007. All Rights Reserved.