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

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

public class XPathUtil
extends java.lang.Object

The XPathUtil class provides convenience methods for getting or removing XML nodes using XPath syntax. This class is using Jaxen.


Field Summary
static java.util.Map WCM_NS
           
 
Method Summary
static org.w3c.dom.NodeList createNodeList(java.util.List nodes)
          This method takes a List of Node object and returns a NodeList object.
static org.w3c.dom.Node removeNode(org.w3c.dom.Node contextNode, java.lang.String xPath, java.util.Map namespaces)
          Remove the XML node specified by the xPath string from the context node.
static void removeNodes(org.w3c.dom.Node contextNode, java.lang.String xPath, java.util.Map namespaces)
          Remove the entire nodelist specified by the xPath string from the context node.
static java.util.List selectNodes(org.w3c.dom.Node contextNode, java.lang.String xPath, java.util.Map namespaces)
          Get a XML nodelist using the specified xPath string.
static org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextNode, java.lang.String xPath, java.util.Map namespaces)
          Get a single XML node using the specified xPath string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WCM_NS

public static java.util.Map WCM_NS
Method Detail

selectSingleNode

public static org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextNode,
                                                java.lang.String xPath,
                                                java.util.Map namespaces)
                                         throws java.lang.Exception
Get a single XML node using the specified xPath string. XPath namespace prefixes are resolved from the namespaceNode.

Parameters:
contextNode - The node to start searching from.
xPath - A valid XPath string.
namespaces - A map of prefixes to URIs
Returns:
The first node found that matches the xPath, or null.
Throws:
java.lang.Exception

selectNodes

public static java.util.List selectNodes(org.w3c.dom.Node contextNode,
                                         java.lang.String xPath,
                                         java.util.Map namespaces)
                                  throws java.lang.Exception
Get a XML nodelist using the specified xPath string. XPath namespace prefixes are resolved from the namespaceNode.

Parameters:
contextNode - The node to start searching from.
xPath - A valid XPath string.
namespaces - A map of prefixes to URIs
Returns:
A List, should never be null.
Throws:
java.lang.Exception

removeNode

public static org.w3c.dom.Node removeNode(org.w3c.dom.Node contextNode,
                                          java.lang.String xPath,
                                          java.util.Map namespaces)
                                   throws java.lang.Exception
Remove the XML node specified by the xPath string from the context node. XPath namespace prefixes are resolved from the namespaceNode.

Parameters:
contextNode - The node to start searching for the specified node to be removed.
xPath - A valid XPath string.
namespaces - A map of prefixes to URIs
Returns:
The removed node or null.
Throws:
java.lang.Exception

removeNodes

public static void removeNodes(org.w3c.dom.Node contextNode,
                               java.lang.String xPath,
                               java.util.Map namespaces)
                        throws java.lang.Exception
Remove the entire nodelist specified by the xPath string from the context node. XPath namespace prefixes are resolved from the namespaceNode.

Parameters:
contextNode - The node to start searching from for the specified nodelist.
xPath - A valid XPath string.
namespaces - A map of prefixes to URIs
Throws:
java.lang.Exception

createNodeList

public static org.w3c.dom.NodeList createNodeList(java.util.List nodes)
This method takes a List of Node object and returns a NodeList object.

Parameters:
nodes - List of Node objects. Null value is not supported.
Returns:
NodeList object


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