|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.commons.xml.DOMUtil
public class DOMUtil
W3C DOM Utilities.
A set of utility methods that allow clients to perform various DOM
manipulations.
Constructor Summary | |
---|---|
DOMUtil()
|
Method Summary | |
---|---|
static void |
addBigDecimal(org.w3c.dom.Element parent,
java.lang.String elementName,
java.math.BigDecimal value)
Add a child element to a parent element. |
static void |
addBigDecimal(org.w3c.dom.Element parent,
java.lang.String elementName,
java.math.BigDecimal value,
java.lang.String namespace)
Add a child element to a parent element. |
static void |
addBoolean(org.w3c.dom.Element parent,
java.lang.String elementName,
boolean value)
Add a child element to a parent element. |
static void |
addBoolean(org.w3c.dom.Element parent,
java.lang.String elementName,
boolean value,
java.lang.String namespace)
Add a child element to a parent element. |
static void |
addDate(org.w3c.dom.Element parent,
java.lang.String elementName,
java.sql.Date value)
Add a child element to a parent element. |
static void |
addDate(org.w3c.dom.Element parent,
java.lang.String elementName,
java.sql.Date value,
java.lang.String namespace)
Add a child element to a parent element. |
static void |
addDouble(org.w3c.dom.Element parent,
java.lang.String elementName,
double value)
Add a child element to a parent element. |
static void |
addDouble(org.w3c.dom.Element parent,
java.lang.String elementName,
double value,
java.lang.String namespace)
Add a child element to a parent element. |
static void |
addInteger(org.w3c.dom.Element parent,
java.lang.String elementName,
int value)
Add a child element to a parent element. |
static void |
addInteger(org.w3c.dom.Element parent,
java.lang.String elementName,
int value,
java.lang.String namespace)
Add a child element to a parent element. |
static void |
addLong(org.w3c.dom.Element parent,
java.lang.String elementName,
long value)
Add a child element to a parent element. |
static void |
addLong(org.w3c.dom.Element parent,
java.lang.String elementName,
long value,
java.lang.String namespace)
Add a child element to a parent element. |
static void |
addNode(org.w3c.dom.Element parent,
java.lang.String elementName)
Add a child element to a parent element. |
static void |
addNode(org.w3c.dom.Element parent,
java.lang.String elementName,
java.lang.String namespaceURI)
Add a child element to a parent element. |
static void |
addString(org.w3c.dom.Element parent,
java.lang.String elementName,
java.lang.String value)
Add a child element to a parent element. |
static void |
addString(org.w3c.dom.Element parent,
java.lang.String elementName,
java.lang.String value,
java.lang.String namespaceURI)
Add a child element to a parent element. |
static void |
addTime(org.w3c.dom.Element parent,
java.lang.String elementName,
java.sql.Time value)
Add a child element to a parent element. |
static void |
addTime(org.w3c.dom.Element parent,
java.lang.String elementName,
java.sql.Time value,
java.lang.String namespaceURI)
Add a child element to a parent element. |
static void |
addTimestamp(org.w3c.dom.Element parent,
java.lang.String elementName,
java.sql.Timestamp value)
Add a child element to a parent element. |
static void |
addTimestamp(org.w3c.dom.Element parent,
java.lang.String elementName,
java.sql.Timestamp value,
java.lang.String namespaceURI)
Add a child element to a parent element. |
static void |
clearDocument(org.w3c.dom.Document doc)
Clear all of the content from the specified document |
static org.w3c.dom.Document |
clone(org.w3c.dom.Document inDoc)
Clone a Document. |
static int |
compareLocations(org.w3c.dom.Node node1,
int offset1,
org.w3c.dom.Node node2,
int offset2)
compare two nodes. |
static com.ibm.commons.xml.xpath.NodeListImpl |
concatNodeLists(org.w3c.dom.NodeList nl1,
org.w3c.dom.NodeList nl2)
This method will return a nodelist containing all the nodes from 2 given nodeLists. |
static org.w3c.dom.Document |
createDocument()
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(org.w3c.dom.DocumentType docType)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.io.InputStream is)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.io.InputStream is,
boolean ignoreBlanks)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.io.InputStream is,
boolean ignoreBlanks,
boolean resolveEntities)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.io.InputStream is,
boolean ignoreBlanks,
boolean resolveEntities,
boolean validate)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.io.Reader is)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.io.Reader is,
boolean ignoreBlanks)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.io.Reader is,
boolean ignoreBlanks,
boolean resolveEntities)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.io.Reader is,
boolean ignoreBlanks,
boolean resolveEntities,
boolean validate)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.lang.String xmlText)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.lang.String xmlText,
boolean ignoreBlanks)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.lang.String namespaceURI,
java.lang.String qualifiedName)
Create a new W3C Document. |
static org.w3c.dom.Document |
createDocument(java.lang.String namespaceURI,
java.lang.String qualifiedName,
org.w3c.dom.DocumentType doctype)
Create a new W3C Document. |
static org.w3c.dom.DocumentType |
createDocumentType(java.lang.String qualifiedName,
java.lang.String publicId,
java.lang.String systemId)
Create a new W3C DocumentType. |
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document document,
org.w3c.dom.Element parent,
java.lang.String name)
Create an element with the specified name and add it as a child of the specified parent. |
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document document,
java.lang.String name)
Create an element with the specified name and add it as a child of the specified parent. |
static java.lang.Object |
createNodes(org.w3c.dom.Node node,
java.lang.String xpathExpr)
Create a node based on an XPath expression object. |
static java.lang.Object |
createNodes(org.w3c.dom.Node node,
java.lang.String xpathExpr,
boolean useCache)
Create a node based on an XPath expression object. |
static com.ibm.commons.xml.xpath.XPathExpression |
createXPath(java.lang.String xpathExpr)
Create an XPath expression object. |
static com.ibm.commons.xml.xpath.XPathExpression |
createXPath(java.lang.String xpathExpr,
boolean useCache)
Create an XPath expression object. |
static org.w3c.dom.Document |
emptyDocument(org.w3c.dom.Document doc)
Remove the content of an existing document. |
static com.ibm.commons.xml.XResult |
evaluateXPath(org.w3c.dom.Node node,
java.lang.String xpathExpr)
Evaluate an XPath expression. |
static com.ibm.commons.xml.XResult |
evaluateXPath(org.w3c.dom.Node node,
java.lang.String xpathExpr,
boolean useCache)
Evaluate an XPath expression. |
static com.ibm.commons.xml.XResult |
evaluateXPath(org.w3c.dom.Node node,
java.lang.String xpathExpr,
com.ibm.commons.xml.NamespaceContext nsContext)
Evaluate an XPath expression. |
static com.ibm.commons.xml.XResult |
evaluateXPath(org.w3c.dom.Node node,
java.lang.String xpathExpr,
com.ibm.commons.xml.NamespaceContext nsContext,
boolean useCache)
Evaluate an XPath expression. |
static boolean |
findChildAtAnyLevel(org.w3c.dom.Node parent,
org.w3c.dom.Node child)
Search through all child nodes and sub child nodes of the given parent node, and return true, if the given child node is ever found. |
static org.w3c.dom.NodeList |
getAllChildElementsByName(org.w3c.dom.Element parent,
java.lang.String name)
Find all element of a given name that is a child or subchild to n levels of a given parent element. |
static org.w3c.dom.Attr |
getAttributeIgnoreCase(org.w3c.dom.Element element,
java.lang.String attributeName)
Gets the DOM attribute of element with the given name. |
static java.lang.String |
getAttributeValue(org.w3c.dom.Element e,
java.lang.String key)
This returns the attribute value for the attribute of the input element with the given name and within no namespace. |
static java.lang.String |
getAttributeValueIgnoreCase(org.w3c.dom.Element element,
java.lang.String attributeName)
Gets the value of DOM attribute of element with the given name
It returns the first attribute value that matches the name, regardless the case. |
static org.w3c.dom.NodeList |
getChildElementsByTagName(org.w3c.dom.Element element,
java.lang.String tag)
Behaves like getElementsByTagName() but only return nodes that are the children of a specified element. |
static org.w3c.dom.NodeList |
getChildElementsByTagNameNS(org.w3c.dom.Element element,
java.lang.String uri,
java.lang.String tag)
Behaves like getElementsByTagNameNS() but only return nodes that are the children of a specified element. |
static org.w3c.dom.NodeList |
getChildNodesToNLevels(org.w3c.dom.Node parent)
Find all children and subChildren of the given parent to n sub levels. |
static java.util.Iterator |
getChildren(org.w3c.dom.Node node)
Get the list of the children Element. |
static java.util.List<org.w3c.dom.Node> |
getChildrenAsList(org.w3c.dom.Element elt)
Create a java.util.List contain the child nodes of the specified element. |
static java.lang.String |
getChildText(org.w3c.dom.Element element,
java.lang.String nodeName)
Returns the textual content of the named child element, or null if there's no such child. |
static java.lang.Object |
getContextNodes(org.w3c.dom.Document doc)
Get the current XPath context result that is associated to a document. |
static org.w3c.dom.NodeList |
getElementsByName(org.w3c.dom.Element parent,
java.lang.String name)
Find a element by name. |
static org.w3c.dom.NodeList |
getElementsByNameNS(org.w3c.dom.Element parent,
java.lang.String namespaceURI,
java.lang.String name)
Find a element by name. |
static org.w3c.dom.Element |
getFirstElementAtAnyDepthByNodeName(org.w3c.dom.Element parent,
java.lang.String name)
Find the first element that is a child or subchild under a given Element parent. |
static org.w3c.dom.Element |
getFirstElementByName(org.w3c.dom.Element parent,
java.lang.String name)
Find a element by name. |
static org.w3c.dom.Element |
getFirstElementByNameNS(org.w3c.dom.Element parent,
java.lang.String namespaceURI,
java.lang.String name)
Find a element by name. |
static java.lang.String |
getNamespaceContextAsString(com.ibm.commons.xml.NamespaceContext namespaceContext)
Debugging function for NamespaceContext. |
static java.lang.String |
getNamespacePrefix(org.w3c.dom.Node parentNode,
java.lang.String preferredPrefix,
java.lang.String nsUri)
Traverse a node, and parent nodes, for a namespace URI. |
static org.w3c.dom.Node |
getNode(org.w3c.dom.Node node,
int offset)
Convert the parent, offset into the child node. |
static int |
getOffsetInParent(org.w3c.dom.Node node)
Helper method to get the offset of a given node with respect to its parent. |
static org.w3c.dom.Document |
getOwnerDocument(org.w3c.dom.Node node)
Return the owner document for the specified node. |
static XMLParserDriver |
getParserDriver()
Get the internal XML parser driver used. |
static com.ibm.commons.xml.NamespaceContext |
getSelectionNamespaces(org.w3c.dom.Document doc)
Get the selection NamespaceContext use during the XPath evaluation on the document. |
static java.lang.String |
getSourceReferenceId(org.w3c.dom.Node node)
Return the source reference id for the specified node. |
static java.lang.String |
getText(org.w3c.dom.Node n)
Returns the textual content directly held under this element as a string. |
static java.lang.String |
getTextValue(org.w3c.dom.Node node)
Get the text associated with a node. |
static java.lang.String |
getXMLString(org.w3c.dom.Node node)
Method to convert a DOM document into a string with no XML declaration line. |
static java.lang.String |
getXMLString(org.w3c.dom.Node node,
boolean compact)
Method to convert a DOM document into a string with no XML declaration line. |
static java.lang.String |
getXMLString(org.w3c.dom.Node node,
boolean compact,
boolean xmldecl)
Method to convert a DOM document into a string. |
static java.lang.String |
getXMLString(org.w3c.dom.Node node,
com.ibm.commons.xml.Format format)
Method to convert a DOM document into a string. |
static com.ibm.commons.xml.XPathContext |
getXPathContext(org.w3c.dom.Document doc)
Get the current XPath contextthat is associated to a document. |
static com.ibm.commons.xml.xpath.XPathExpressionFactory |
getXPathExpressionFactory()
Get the internal XPath factory used. |
static boolean |
hasChildren(org.w3c.dom.Element element)
Deprecated. use element.hasChildNode() instead |
static boolean |
hasRootElement(org.w3c.dom.Document document)
Returns whether a DOM has a root. |
static org.w3c.dom.Node |
insertAfter(org.w3c.dom.Node parent,
org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
Inserts the node newChild after the existing child node refChild. |
static boolean |
isNamespaceAttribute(org.w3c.dom.Attr attribute)
Determines if an Attribute is a namespace attribute. |
static boolean |
moveNodeDown(org.w3c.dom.Node node)
Move an element prior to his previous sibling. |
static boolean |
moveNodeUp(org.w3c.dom.Node node)
Move an element prior to his previous sibling. |
static java.lang.Object |
node(org.w3c.dom.Node node,
java.lang.String xpath)
Evaluate the given XPath expression on the given document, and returns the first element or attribute that match this XPath. |
static java.lang.Object |
node(org.w3c.dom.Node node,
java.lang.String xpath,
com.ibm.commons.xml.NamespaceContext selectionNS)
Evaluate the given XPath expression on the given document, and returns the first element or attribute that match this XPath. |
static java.lang.Object[] |
nodes(org.w3c.dom.Node node,
java.lang.String xpath)
Evaluate the given XPath expression on the given document, and returns an array with all elements and attributes that match this XPath. |
static java.lang.Object[] |
nodes(org.w3c.dom.Node node,
java.lang.String xpath,
com.ibm.commons.xml.NamespaceContext selectionNS)
Evaluate the given XPath expression on the given document, and returns an array with all elements and attributes that match this XPath. |
static void |
popXPathContext(org.w3c.dom.Document doc)
Remove the latest XPath context that has been set to the document An XML document contains a base XPath that is used when evaluating XPath against a node. |
static void |
pushXPathContext(org.w3c.dom.Document doc,
java.lang.String xPathContext)
Push an XPath context to an existing document. |
static void |
removeAttributeIgnoreCase(org.w3c.dom.Element element,
java.lang.String attributeName)
Removes the DOM attribute from element with the given name. |
static void |
removeChildren(org.w3c.dom.Node node)
Remove all the children from a node. |
static org.w3c.dom.Element |
rootElement(org.w3c.dom.Document document)
Deprecated. use document.getDocumentElement() instead |
static void |
serialize(java.io.File file,
org.w3c.dom.Node node,
com.ibm.commons.xml.Format format)
Serialize a node to a file. |
static void |
serialize(java.io.OutputStream os,
org.w3c.dom.Node node,
boolean compact,
boolean xmldecl)
Serialize a node to a stream. |
static void |
serialize(java.io.OutputStream os,
org.w3c.dom.Node node,
com.ibm.commons.xml.Format format)
Serialize a node to a stream. |
static void |
serialize(java.io.Writer w,
org.w3c.dom.Node node,
boolean compact,
boolean xmldecl)
Serialize a node to a writer. |
static void |
serialize(java.io.Writer w,
org.w3c.dom.Node node,
com.ibm.commons.xml.Format format)
Serialize a node to a writer. |
static void |
setDocument(org.w3c.dom.Document source,
org.w3c.dom.Document target)
Set the content of the target document from the sourec document. |
static void |
setFilterIndex(org.w3c.dom.Document doc,
int index)
Set the filter index on the current XPath context that is associated with the specified document. |
static void |
setSelectionNamespaces(org.w3c.dom.Document doc,
com.ibm.commons.xml.NamespaceContext selectionNS)
Set the namespaces map use during the XPath evaluation on the document. |
static void |
setTextValue(org.w3c.dom.Node node,
java.lang.String value)
Set the text associated with a node. |
static void |
setTextValue(org.w3c.dom.Node node,
java.lang.String value,
boolean cdata)
|
static void |
setValue(org.w3c.dom.Node node,
java.lang.String path,
java.lang.String value)
Set the value of the first XPath matching element. |
static void |
setValue(org.w3c.dom.Node node,
java.lang.String path,
java.lang.String value,
com.ibm.commons.xml.NamespaceContext selectionNS)
Set the value of the first XPath matching element. |
static void |
setXMLString(org.w3c.dom.Document target,
java.lang.String s)
Reads the given string to update the document content. |
static java.lang.String |
value(org.w3c.dom.Node node,
java.lang.String xpath)
Get a string value from the first XPath matching element. |
static java.lang.String |
value(org.w3c.dom.Node node,
java.lang.String xpath,
com.ibm.commons.xml.NamespaceContext selectionNS)
Get a string value from the first XPath matching element. |
static java.lang.String[] |
values(org.w3c.dom.Node node,
java.lang.String xpath)
Get the string values from the XPath matching elements. |
static java.lang.String[] |
values(org.w3c.dom.Node node,
java.lang.String xpath,
com.ibm.commons.xml.NamespaceContext selectionNS)
Get the string values from the XPath matching elements. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DOMUtil()
Method Detail |
---|
public static XMLParserDriver getParserDriver()
public static com.ibm.commons.xml.xpath.XPathExpressionFactory getXPathExpressionFactory()
public static org.w3c.dom.Document createDocument(java.lang.String namespaceURI, java.lang.String qualifiedName, org.w3c.dom.DocumentType doctype) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.lang.String namespaceURI, java.lang.String qualifiedName) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(org.w3c.dom.DocumentType docType) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument() throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.io.InputStream is, boolean ignoreBlanks) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.io.InputStream is, boolean ignoreBlanks, boolean resolveEntities) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.io.InputStream is, boolean ignoreBlanks, boolean resolveEntities, boolean validate) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.io.InputStream is) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.io.Reader is, boolean ignoreBlanks) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.io.Reader is, boolean ignoreBlanks, boolean resolveEntities) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.io.Reader is, boolean ignoreBlanks, boolean resolveEntities, boolean validate) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.io.Reader is) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.lang.String xmlText, boolean ignoreBlanks) throws XMLException
XMLException
public static org.w3c.dom.Document createDocument(java.lang.String xmlText) throws XMLException
XMLException
public static org.w3c.dom.DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicId, java.lang.String systemId) throws XMLException
XMLException
public static org.w3c.dom.Element rootElement(org.w3c.dom.Document document)
document
- the source document
public static boolean hasRootElement(org.w3c.dom.Document document)
document
- the source document
public static boolean hasChildren(org.w3c.dom.Element element)
element
- the element to check
public static void removeChildren(org.w3c.dom.Node node)
node
- the node to remove the childrenpublic static org.w3c.dom.Document emptyDocument(org.w3c.dom.Document doc)
doc
- the document to clear
public static java.lang.String getTextValue(org.w3c.dom.Node node)
public static void setTextValue(org.w3c.dom.Node node, java.lang.String value)
public static void setTextValue(org.w3c.dom.Node node, java.lang.String value, boolean cdata)
public static java.util.Iterator getChildren(org.w3c.dom.Node node)
public static void serialize(java.io.File file, org.w3c.dom.Node node, com.ibm.commons.xml.Format format) throws XMLException
file
- the java.io.Filenode
- the source nodeformat
- the desired output format
XMLException
public static void serialize(java.io.OutputStream os, org.w3c.dom.Node node, com.ibm.commons.xml.Format format) throws XMLException
os
- the output streamnode
- the source nodeformat
- the desired output format
XMLException
public static void serialize(java.io.OutputStream os, org.w3c.dom.Node node, boolean compact, boolean xmldecl) throws XMLException
os
- the output streamnode
- the source nodecompact
- if true, the document does'nt contains any formatting text (blanks, new lines..)xmldecl
- if true, include the XML declaration statement
XMLException
public static void serialize(java.io.Writer w, org.w3c.dom.Node node, com.ibm.commons.xml.Format format) throws XMLException
w
- the writernode
- the source nodeformat
- the desired output format
XMLException
public static void serialize(java.io.Writer w, org.w3c.dom.Node node, boolean compact, boolean xmldecl) throws XMLException
w
- the writernode
- the source nodecompact
- if true, the document does'nt contains any formatting text (blanks, new lines..)xmldecl
- if true, include the XML declaration statement
XMLException
public static java.lang.String getXMLString(org.w3c.dom.Node node, com.ibm.commons.xml.Format format) throws XMLException
If xmlDecl
is false, the resulting string
won't contain an XML declaration. (<?xml version="1.0"?>
)
If compact
is true, the resulting string will be compacted
(no indent, no empty lines).
node
- the source XML nodecompact
- if true, the document does'nt contains any formatting text (blanks, new lines..)xmldecl
- if true, include the XML declaration statement
XMLException
- if an error occurredpublic static java.lang.String getXMLString(org.w3c.dom.Node node, boolean compact, boolean xmldecl) throws XMLException
If xmlDecl
is false, the resulting string
won't contain an XML declaration. (<?xml version="1.0"?>
)
If compact
is true, the resulting string will be compacted
(no indent, no empty lines).
node
- the source XML nodecompact
- if true, the document does'nt contains any formatting text (blanks, new lines..)xmldecl
- if true, include the XML declaration statement
XMLException
- if an error occurredpublic static java.lang.String getXMLString(org.w3c.dom.Node node, boolean compact) throws XMLException
If compact
is true, the resulting string will be compacted
(no indent, no empty lines).
node
- the source XML nodecompact
- if true, the document does'nt contains any formatting text (blanks, new lines..)
XMLException
- if an error occurredpublic static java.lang.String getXMLString(org.w3c.dom.Node node) throws XMLException
node
- the source XML node
XMLException
- if an error occurredpublic static void setXMLString(org.w3c.dom.Document target, java.lang.String s) throws XMLException
doc
- the XML node to updates
- the XML string to parse
XMLException
- if an error occurredpublic static void clearDocument(org.w3c.dom.Document doc)
doc
- public static void setDocument(org.w3c.dom.Document source, org.w3c.dom.Document target)
source
- target
- public static void pushXPathContext(org.w3c.dom.Document doc, java.lang.String xPathContext) throws XMLException
doc
- the source documentxPathContext
- the XPath context to push to the document
XMLException
public static void popXPathContext(org.w3c.dom.Document doc) throws XMLException
doc
- the source document
XMLException
public static java.lang.Object getContextNodes(org.w3c.dom.Document doc)
doc
- the source documentpublic static com.ibm.commons.xml.XPathContext getXPathContext(org.w3c.dom.Document doc)
doc
- the source documentpublic static void setFilterIndex(org.w3c.dom.Document doc, int index) throws XMLException
doc
- index
-
XMLException
public static void setSelectionNamespaces(org.w3c.dom.Document doc, com.ibm.commons.xml.NamespaceContext selectionNS)
doc
- the source documentselectionNS
- the NamespaceContext used during XPath evaluation on the document,
in order to resolve namespaces.public static com.ibm.commons.xml.NamespaceContext getSelectionNamespaces(org.w3c.dom.Document doc)
doc
- the source documentpublic static java.lang.String getNamespaceContextAsString(com.ibm.commons.xml.NamespaceContext namespaceContext)
namespaceContext
- the namespace context to dump.
public static com.ibm.commons.xml.xpath.XPathExpression createXPath(java.lang.String xpathExpr, boolean useCache) throws XMLException
xpathExpr
- the xpath expressionuseCache
- indicate if the xpath should be cached
XMLException
public static com.ibm.commons.xml.xpath.XPathExpression createXPath(java.lang.String xpathExpr) throws XMLException
xpathExpr
- the xpath expression
XMLException
public static com.ibm.commons.xml.XResult evaluateXPath(org.w3c.dom.Node node, java.lang.String xpathExpr, com.ibm.commons.xml.NamespaceContext nsContext, boolean useCache) throws XMLException
node
- the node source of the XPathxpathExpr
- the xpath expressionnsContext
- the namespace context to use by the engineuseCache
- indicate if the xpath should be cached
XMLException
public static com.ibm.commons.xml.XResult evaluateXPath(org.w3c.dom.Node node, java.lang.String xpathExpr, com.ibm.commons.xml.NamespaceContext nsContext) throws XMLException
node
- the node source of the XPathxpathExpr
- the xpath expressionnsContext
- the namespace context to use by the engine
XMLException
public static com.ibm.commons.xml.XResult evaluateXPath(org.w3c.dom.Node node, java.lang.String xpathExpr) throws XMLException
node
- the node source of the XPathxpathExpr
- the xpath expression
XMLException
public static com.ibm.commons.xml.XResult evaluateXPath(org.w3c.dom.Node node, java.lang.String xpathExpr, boolean useCache) throws XMLException
node
- the node source of the XPathxpathExpr
- the xpath expressionuseCache
- indicate if the xpath should be cached
XMLException
public static java.lang.Object createNodes(org.w3c.dom.Node node, java.lang.String xpathExpr, boolean useCache) throws XMLException
node
- the node to start fromxpathExpr
- the xpath expressionuseCache
- indicate if the xpath should be cached
XMLException
public static java.lang.Object createNodes(org.w3c.dom.Node node, java.lang.String xpathExpr) throws XMLException
node
- the node to start fromxpathExpr
- the xpath expressionuseCache
- indicate if the xpath should be cached
XMLException
public static org.w3c.dom.Element createElement(org.w3c.dom.Document document, org.w3c.dom.Element parent, java.lang.String name)
document
- parent
- name
-
public static org.w3c.dom.Element createElement(org.w3c.dom.Document document, java.lang.String name)
document
- name
-
public static java.lang.Object[] nodes(org.w3c.dom.Node node, java.lang.String xpath) throws XMLException
node
- the source nodexpath
- the XPath to evaluate
XMLException
- if an error occurredpublic static java.lang.Object node(org.w3c.dom.Node node, java.lang.String xpath) throws XMLException
node
- the source nodexpath
- the XPath to evaluate
XMLException
- if an error occurredpublic static java.lang.Object[] nodes(org.w3c.dom.Node node, java.lang.String xpath, com.ibm.commons.xml.NamespaceContext selectionNS) throws XMLException
node
- the source nodexpath
- the XPath to evaluateselectionNS
- the NamespacContext used to resolve namespaces during XPath evaluation
XMLException
- if an error occurredpublic static java.lang.Object node(org.w3c.dom.Node node, java.lang.String xpath, com.ibm.commons.xml.NamespaceContext selectionNS) throws XMLException
node
- the source nodexpath
- the XPath to evaluateselectionNS
- the NamespacContext used to resolve namespaces during XPath evaluation
XMLException
- if an error occurredpublic static java.lang.String value(org.w3c.dom.Node node, java.lang.String xpath) throws XMLException
node
- the source nodexpath
- the XPath to evaluate
XMLException
- if an error occurredpublic static java.lang.String value(org.w3c.dom.Node node, java.lang.String xpath, com.ibm.commons.xml.NamespaceContext selectionNS) throws XMLException
node
- the source nodexpath
- the XPath to evaluateselectionNS
- the NamespacContext used to resolve namespaces during XPath evaluation
XMLException
- if an error occurredpublic static java.lang.String[] values(org.w3c.dom.Node node, java.lang.String xpath) throws XMLException
node
- the source nodexpath
- the XPath to evaluate
XMLException
- if an error occurredpublic static java.lang.String[] values(org.w3c.dom.Node node, java.lang.String xpath, com.ibm.commons.xml.NamespaceContext selectionNS) throws XMLException
node
- the source nodexpath
- the XPath to evaluateselectionNS
- the NamespacContext used to resolve namespaces during XPath evaluation
XMLException
- if an error occurredpublic static void setValue(org.w3c.dom.Node node, java.lang.String path, java.lang.String value) throws XMLException
node[/node...]
.
node
- the source nodepath
- the XPath to usevalue
- the value to set
XMLException
- if an error occurredpublic static void setValue(org.w3c.dom.Node node, java.lang.String path, java.lang.String value, com.ibm.commons.xml.NamespaceContext selectionNS) throws XMLException
node[/node...]
.
node
- the source nodepath
- the XPath to usevalue
- the value to setselectionNS
- the NamespacContext used to resolve namespaces during XPath evaluation
XMLException
- if an error occurredpublic static org.w3c.dom.Element getFirstElementByName(org.w3c.dom.Element parent, java.lang.String name)
public static org.w3c.dom.Element getFirstElementByNameNS(org.w3c.dom.Element parent, java.lang.String namespaceURI, java.lang.String name)
public static org.w3c.dom.NodeList getElementsByName(org.w3c.dom.Element parent, java.lang.String name)
public static org.w3c.dom.NodeList getElementsByNameNS(org.w3c.dom.Element parent, java.lang.String namespaceURI, java.lang.String name)
public static org.w3c.dom.Node insertAfter(org.w3c.dom.Node parent, org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
public static boolean moveNodeUp(org.w3c.dom.Node node)
node
- the node to move up
public static boolean moveNodeDown(org.w3c.dom.Node node)
node
- the node to move down
public static boolean isNamespaceAttribute(org.w3c.dom.Attr attribute)
public static org.w3c.dom.Attr getAttributeIgnoreCase(org.w3c.dom.Element element, java.lang.String attributeName)
element
with the given name.
It returns the first attribute that matches the name, regardless the case.
This is particularly useful when dealing with an HTML DOM, as HTML is not
case sensitive.
element
- the source elementattributeName
- the attribute name
public static void removeAttributeIgnoreCase(org.w3c.dom.Element element, java.lang.String attributeName)
element
with the given name.
It removes the first attribute that matches the name, regardless the case.
This is particularly useful when dealing with an HTML DOM, as HTML is not
case sensitive.
element
- the source elementattributeName
- the attribute namepublic static java.lang.String getAttributeValueIgnoreCase(org.w3c.dom.Element element, java.lang.String attributeName)
element
with the given name
It returns the first attribute value that matches the name, regardless the case.
This is particularly useful when dealing with an HTML DOM, as HTML is not
case sensitive.
element
- the source elementattributeName
- the attribute name
public static org.w3c.dom.Document getOwnerDocument(org.w3c.dom.Node node)
node
-
public static java.lang.String getNamespacePrefix(org.w3c.dom.Node parentNode, java.lang.String preferredPrefix, java.lang.String nsUri)
parentNode
- - node from which to begin the searchpreferredPrefix
- - Prefix to use if the namespace attribute must be created.nsUri
- - the namesapce URI to search for
public static org.w3c.dom.Document clone(org.w3c.dom.Document inDoc)
inDoc
- the input document
public static java.lang.String getChildText(org.w3c.dom.Element element, java.lang.String nodeName)
element
- to search for children
public static java.lang.String getText(org.w3c.dom.Node n)
n
-
public static java.lang.String getAttributeValue(org.w3c.dom.Element e, java.lang.String key)
e
- the Nodekey
- the attribute name
public static void addNode(org.w3c.dom.Element parent, java.lang.String elementName)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addNode(org.w3c.dom.Element parent, java.lang.String elementName, java.lang.String namespaceURI)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addBigDecimal(org.w3c.dom.Element parent, java.lang.String elementName, java.math.BigDecimal value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addBigDecimal(org.w3c.dom.Element parent, java.lang.String elementName, java.math.BigDecimal value, java.lang.String namespace)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addBoolean(org.w3c.dom.Element parent, java.lang.String elementName, boolean value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addBoolean(org.w3c.dom.Element parent, java.lang.String elementName, boolean value, java.lang.String namespace)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addDate(org.w3c.dom.Element parent, java.lang.String elementName, java.sql.Date value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addDate(org.w3c.dom.Element parent, java.lang.String elementName, java.sql.Date value, java.lang.String namespace)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addDouble(org.w3c.dom.Element parent, java.lang.String elementName, double value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addDouble(org.w3c.dom.Element parent, java.lang.String elementName, double value, java.lang.String namespace)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addInteger(org.w3c.dom.Element parent, java.lang.String elementName, int value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addInteger(org.w3c.dom.Element parent, java.lang.String elementName, int value, java.lang.String namespace)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addLong(org.w3c.dom.Element parent, java.lang.String elementName, long value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addLong(org.w3c.dom.Element parent, java.lang.String elementName, long value, java.lang.String namespace)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addString(org.w3c.dom.Element parent, java.lang.String elementName, java.lang.String value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addString(org.w3c.dom.Element parent, java.lang.String elementName, java.lang.String value, java.lang.String namespaceURI)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addTime(org.w3c.dom.Element parent, java.lang.String elementName, java.sql.Time value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addTime(org.w3c.dom.Element parent, java.lang.String elementName, java.sql.Time value, java.lang.String namespaceURI)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addTimestamp(org.w3c.dom.Element parent, java.lang.String elementName, java.sql.Timestamp value)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static void addTimestamp(org.w3c.dom.Element parent, java.lang.String elementName, java.sql.Timestamp value, java.lang.String namespaceURI)
parent
- the parent elementelementName
- the Element namevalue
- the Element valuepublic static java.util.List<org.w3c.dom.Node> getChildrenAsList(org.w3c.dom.Element elt)
elt
-
public static java.lang.String getSourceReferenceId(org.w3c.dom.Node node)
node
-
public static org.w3c.dom.NodeList getChildElementsByTagNameNS(org.w3c.dom.Element element, java.lang.String uri, java.lang.String tag)
element
- - element to find the children of, may not be null.uri
- - only return children matching this namespace uri.tag
- - only return children matching this tag name.
public static org.w3c.dom.NodeList getChildElementsByTagName(org.w3c.dom.Element element, java.lang.String tag)
element
- - element to find the children of, may not be null.tag
- - only return children matching this tag name.
public static int compareLocations(org.w3c.dom.Node node1, int offset1, org.w3c.dom.Node node2, int offset2)
node1
- offset1
- node2
- offset2
-
public static org.w3c.dom.Node getNode(org.w3c.dom.Node node, int offset)
node
- offset
-
public static int getOffsetInParent(org.w3c.dom.Node node)
node
- -
may not be null
public static org.w3c.dom.NodeList getAllChildElementsByName(org.w3c.dom.Element parent, java.lang.String name)
public static com.ibm.commons.xml.xpath.NodeListImpl concatNodeLists(org.w3c.dom.NodeList nl1, org.w3c.dom.NodeList nl2)
nl1
- nl2
-
public static org.w3c.dom.Element getFirstElementAtAnyDepthByNodeName(org.w3c.dom.Element parent, java.lang.String name)
public static org.w3c.dom.NodeList getChildNodesToNLevels(org.w3c.dom.Node parent)
public static boolean findChildAtAnyLevel(org.w3c.dom.Node parent, org.w3c.dom.Node child)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |