public class

DOMHelper

extends Object
java.lang.Object
   ↳ xades4j.utils.DOMHelper

Class Overview

Utility methods for DOM nodes.

Summary

Public Methods
static Element createElement(Document doc, String name, String prefix, String namespaceURI)
Creates an element on the given document.
static Element createElementInTempDocument(String name, String prefix, String namespaceURI)
static Collection<Element> getChildElementsByTagNameNS(Element e, String namespaceURI, String localName)
Gets all the elements with the given qualified name that are direct children of e.
static Element getFirstChildElement(Node node)
Gets the first child element of a node.
static Element getFirstDescendant(Element e, String namespaceUri, String localName)
Gets the first element with the specified qualified name that is descendant of e.
static Element getLastChildElement(Node node)
Gets the last child element of a node.
static Element getNextSiblingElement(Node node)
Gets the next sibling of a node that is an element.
static Document getOwnerDocument(Node node)
Gets the owner document of a node.
static NodeList nodeList(Iterable<Node> nodes)
static void setIdAsXmlId(Element e, String id)
Sets the "Id" attribute of an element and sets it as the element's XML ID.
static void useIdAsXmlId(Element e)
Defines the element's "Id" attribute as its XML ID, if present.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Element createElement (Document doc, String name, String prefix, String namespaceURI)

Creates an element on the given document. Exceptions are as in createElementNS(java.lang.String, java.lang.String). The qualified name is obtained by prefix:name if the prefix is not null.

Parameters
doc the owner document
name the element's local name
prefix the element's prefix (may be null)
namespaceURI the element's uri (null for no namespace)
Returns
  • the created element

public static Element createElementInTempDocument (String name, String prefix, String namespaceURI)

public static Collection<Element> getChildElementsByTagNameNS (Element e, String namespaceURI, String localName)

Gets all the elements with the given qualified name that are direct children of e.

Parameters
e the element
namespaceURI namespace
localName element name

public static Element getFirstChildElement (Node node)

Gets the first child element of a node.

Parameters
node the node to get the child from
Returns
  • the first element child of node or null if none
Throws
NullPointerException if node is null

public static Element getFirstDescendant (Element e, String namespaceUri, String localName)

Gets the first element with the specified qualified name that is descendant of e.

Parameters
e the element
namespaceUri namespace
localName element name
Returns
  • the element or null if there is no such element

public static Element getLastChildElement (Node node)

Gets the last child element of a node.

Parameters
node the node to get the child from
Returns
  • the last element child of node or null if none
Throws
NullPointerException if node is null

public static Element getNextSiblingElement (Node node)

Gets the next sibling of a node that is an element.

Parameters
node the node
Returns
  • the next sibling element or null if none
Throws
NullPointerException if node is null

public static Document getOwnerDocument (Node node)

Gets the owner document of a node.

Parameters
node the node
Returns
  • the node's document or the node itself if it is a document node
Throws
NullPointerException if node is null

public static NodeList nodeList (Iterable<Node> nodes)

public static void setIdAsXmlId (Element e, String id)

Sets the "Id" attribute of an element and sets it as the element's XML ID.

Parameters
e the element where the ID should be set
id the id

public static void useIdAsXmlId (Element e)

Defines the element's "Id" attribute as its XML ID, if present.

Parameters
e the element