Package com.github.oowekyala.ooxml
Class DomUtils
- java.lang.Object
-
- com.github.oowekyala.ooxml.DomUtils
-
public final class DomUtils extends java.lang.ObjectSimple utilities to work with theorg.w3c.domAPI.
-
-
Constructor Summary
Constructors Constructor Description DomUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<org.w3c.dom.Node>asList(org.w3c.dom.NamedNodeMap nodeList)Returns an unmodifiable view of the given nodemap as a list.static java.util.List<org.w3c.dom.Node>asList(org.w3c.dom.NodeList nodeList)Returns an unmodifiable view of the given nodelist as a list.static java.util.List<org.w3c.dom.Element>children(org.w3c.dom.Element element)Returns the list of children of the given element that are also elements.static java.util.List<org.w3c.dom.Element>childrenNamed(org.w3c.dom.Element element, java.lang.String localName)Returns the list of children of the given element that are also elements.static java.util.Optional<java.lang.String>getAttributeOpt(org.w3c.dom.Element element, java.lang.String attributeName)Returns the value of the attribute with the given name as an optional.static java.util.Map<java.lang.String,org.w3c.dom.Node>toMap(org.w3c.dom.NamedNodeMap nodeList)Returns a new map of nodes built from the given node map.
-
-
-
Method Detail
-
children
public static java.util.List<org.w3c.dom.Element> children(org.w3c.dom.Element element)
Returns the list of children of the given element that are also elements.
-
childrenNamed
public static java.util.List<org.w3c.dom.Element> childrenNamed(org.w3c.dom.Element element, java.lang.String localName)Returns the list of children of the given element that are also elements.
-
getAttributeOpt
public static java.util.Optional<java.lang.String> getAttributeOpt(org.w3c.dom.Element element, java.lang.String attributeName)Returns the value of the attribute with the given name as an optional.- Parameters:
element- Element to get the attribute fromattributeName- Attribute name (local name, no NS)
-
asList
public static java.util.List<org.w3c.dom.Node> asList(org.w3c.dom.NodeList nodeList)
Returns an unmodifiable view of the given nodelist as a list.- Parameters:
nodeList- A node list- Returns:
- A list view
-
asList
public static java.util.List<org.w3c.dom.Node> asList(org.w3c.dom.NamedNodeMap nodeList)
Returns an unmodifiable view of the given nodemap as a list. Note that as per the specification ofNamedNodeMap, elements are in no particular order, but this allows to iterate over them easily.- Parameters:
nodeList- A node map- Returns:
- A list view
-
toMap
public static java.util.Map<java.lang.String,org.w3c.dom.Node> toMap(org.w3c.dom.NamedNodeMap nodeList)
Returns a new map of nodes built from the given node map. This uses local names to index the nodes. The returned map is modifiable.- Parameters:
nodeList- A node map- Returns:
- A new, modifiable map
-
-