uk.ac.cam.ch.wwmm.opsin
public final class XOMTools extends java.lang.Object
Constructor and Description |
---|
XOMTools() |
Modifier and Type | Method and Description |
---|---|
static int[] |
countNumberOfElementsAndNumberOfChildLessElements(nu.xom.Element startingElement)
Finds and returns the number of elements and the number of elements with no children, that are descendants of the startingElement
The 0th position of the returned array is the total number of elements
The 1st position is the number of child less elements
|
static java.util.List<nu.xom.Element> |
getChildElementsWithTagName(nu.xom.Element startingElement,
java.lang.String elementName)
Finds all child elements whose localname matches one of the strings in elementNames
Equivalent to an xpath of type ./*[local-name() = 'elementName'] from the startingElement
This is equivalent to XOM's getChildElements(String) other than returning an arrayList
|
static java.util.List<nu.xom.Element> |
getChildElementsWithTagNameAndAttribute(nu.xom.Element startingElement,
java.lang.String elementName,
java.lang.String attributeName,
java.lang.String attributeValue)
Finds all child elements whose localname matches the given elementName
Additionally the element must have the specified attribute and the value of the attribute must be as specified
Equivalent to an xpath of type ./*[local-name() = 'elementName'][@attribute="attributevalue"] from the startingElement
|
static java.util.List<nu.xom.Element> |
getChildElementsWithTagNames(nu.xom.Element startingElement,
java.lang.String[] elementNames)
Finds all child elements whose localname matches one of the strings in elementNames
Equivalent to an xpath of type ./*[local-name() = 'elementName1']|./*[local-name() = 'elementName2']|./*[local-name() = 'elementName3'] from the startingElement
|
static java.util.List<nu.xom.Element> |
getDescendantElementsWithTagName(nu.xom.Element startingElement,
java.lang.String elementName)
Finds all descendant elements whose localname matches the given elementName
Equivalent to an xpath of type .//*[local-name() = 'elementName'] from the startingElement
|
static java.util.List<nu.xom.Element> |
getDescendantElementsWithTagNameAndAttribute(nu.xom.Element startingElement,
java.lang.String elementName,
java.lang.String attributeName,
java.lang.String attributeValue)
Finds all descendant elements whose localname matches the given elementName
Additionally the element must have the specified attribute and the value of the attribute must be as specified
Equivalent to an xpath of type .//*[local-name() = 'elementName'][@attribute="attributevalue"] from the startingElement
|
static java.util.List<nu.xom.Element> |
getDescendantElementsWithTagNames(nu.xom.Element startingElement,
java.lang.String[] elementNames)
Finds all descendant elements whose localname matches one of the strings in elementNames
Equivalent to an xpath of type .//*[local-name() = 'elementName1']|.//*[local-name() = 'elementName2']|.//*[local-name() = 'elementName3'] from the startingElement
|
static nu.xom.Node |
getNext(nu.xom.Node node)
Gets the next node.
|
static java.util.List<nu.xom.Element> |
getNextAdjacentSiblingsOfType(nu.xom.Element currentElem,
java.lang.String type)
Returns an arrayList containing sibling elements of the given type after the given element.
|
static nu.xom.Node |
getNextSibling(nu.xom.Node node)
Gets the next sibling of a given node.
|
static nu.xom.Node |
getNextSibling(nu.xom.Node current,
java.lang.String tagName)
Gets the first next sibling of a given node whose tagname matches the given string.
|
static nu.xom.Element |
getNextSiblingIgnoringCertainElements(nu.xom.Element startingEl,
java.lang.String[] elementsToIgnore)
Gets the next sibling element of the given element.
|
static java.util.List<nu.xom.Element> |
getNextSiblingsOfType(nu.xom.Element currentElem,
java.lang.String type)
Returns an arrayList containing sibling elements of the given type after the given element.
|
static java.util.List<nu.xom.Element> |
getNextSiblingsOfTypes(nu.xom.Element currentElem,
java.lang.String[] types)
Returns an arrayList containing sibling elements of the given types after the given element.
|
static nu.xom.Node |
getPrevious(nu.xom.Node node)
Gets the previous node.
|
static nu.xom.Node |
getPreviousSibling(nu.xom.Node node)
Gets the previous sibling of a given node.
|
static nu.xom.Node |
getPreviousSibling(nu.xom.Node current,
java.lang.String tagName)
Gets the first previous sibling of a given node whose tagname matches the given string.
|
static nu.xom.Element |
getPreviousSiblingIgnoringCertainElements(nu.xom.Element startingEl,
java.lang.String[] elementsToIgnore)
Gets the previous sibling element of the given element.
|
static java.util.List<nu.xom.Element> |
getPreviousSiblingsOfType(nu.xom.Element currentElem,
java.lang.String type)
Returns an arrayList containing sibling elements of the given type before the given element.
|
static java.util.List<nu.xom.Element> |
getSiblingsUpToElementWithTagName(nu.xom.Element startingEl,
java.lang.String tagName)
Find all the later siblings of startingElement with the search terminating at the element with string tagName
or if there are not more siblings
|
static void |
insertAfter(nu.xom.Node node,
nu.xom.Node newNode)
Inserts a node so that it occurs after a reference node.
|
static void |
insertBefore(nu.xom.Node node,
nu.xom.Node newNode)
Inserts a node so that it occurs before a reference node.
|
static void |
setTextChild(nu.xom.Element group,
java.lang.String newName)
Sets the first text child of the group to the newName
Throws an exception if the first child is not a Text node
|
public static nu.xom.Node getNextSibling(nu.xom.Node node)
node
- The reference node.public static nu.xom.Node getNextSibling(nu.xom.Node current, java.lang.String tagName)
current
- The reference node.tagName
- The tagname of a node to look forpublic static nu.xom.Node getPreviousSibling(nu.xom.Node node)
node
- The reference node.public static nu.xom.Node getPreviousSibling(nu.xom.Node current, java.lang.String tagName)
current
- The reference node.tagName
- The tagname of a node to look forpublic static void insertBefore(nu.xom.Node node, nu.xom.Node newNode)
node
- The reference node.newNode
- The new node to insert.public static void insertAfter(nu.xom.Node node, nu.xom.Node newNode)
node
- The reference node.newNode
- The new node to insert.public static nu.xom.Node getNext(nu.xom.Node node)
node:
- starting nodepublic static nu.xom.Node getPrevious(nu.xom.Node node)
node:
- starting nodepublic static void setTextChild(nu.xom.Element group, java.lang.String newName)
group
- newName
- public static java.util.List<nu.xom.Element> getNextSiblingsOfType(nu.xom.Element currentElem, java.lang.String type)
currentElem:
- the element to look for following siblings oftype:
- the "localname" of the element type desiredpublic static java.util.List<nu.xom.Element> getNextAdjacentSiblingsOfType(nu.xom.Element currentElem, java.lang.String type)
currentElem:
- the element to look for following siblings oftype:
- the "localname" of the element type desiredpublic static java.util.List<nu.xom.Element> getNextSiblingsOfTypes(nu.xom.Element currentElem, java.lang.String[] types)
currentElem:
- the element to look for following siblings oftypes:
- An array of the "localname"s of the element types desiredpublic static java.util.List<nu.xom.Element> getPreviousSiblingsOfType(nu.xom.Element currentElem, java.lang.String type)
currentElem:
- the element to look for previous siblings oftype:
- the "localname" of the element type desiredpublic static nu.xom.Element getNextSiblingIgnoringCertainElements(nu.xom.Element startingEl, java.lang.String[] elementsToIgnore)
startingEl
- elementsToIgnore
- public static nu.xom.Element getPreviousSiblingIgnoringCertainElements(nu.xom.Element startingEl, java.lang.String[] elementsToIgnore)
startingEl
- elementsToIgnore
- public static java.util.List<nu.xom.Element> getDescendantElementsWithTagName(nu.xom.Element startingElement, java.lang.String elementName)
startingElement
- elementName
- public static java.util.List<nu.xom.Element> getDescendantElementsWithTagNames(nu.xom.Element startingElement, java.lang.String[] elementNames)
startingElement
- elementNames
- public static java.util.List<nu.xom.Element> getChildElementsWithTagNames(nu.xom.Element startingElement, java.lang.String[] elementNames)
startingElement
- elementNames
- public static java.util.List<nu.xom.Element> getChildElementsWithTagName(nu.xom.Element startingElement, java.lang.String elementName)
startingElement
- elementName
- public static java.util.List<nu.xom.Element> getDescendantElementsWithTagNameAndAttribute(nu.xom.Element startingElement, java.lang.String elementName, java.lang.String attributeName, java.lang.String attributeValue)
startingElement
- elementName
- public static java.util.List<nu.xom.Element> getChildElementsWithTagNameAndAttribute(nu.xom.Element startingElement, java.lang.String elementName, java.lang.String attributeName, java.lang.String attributeValue)
startingElement
- elementName
- public static int[] countNumberOfElementsAndNumberOfChildLessElements(nu.xom.Element startingElement)
startingElement
- public static java.util.List<nu.xom.Element> getSiblingsUpToElementWithTagName(nu.xom.Element startingEl, java.lang.String tagName)
startingEl
- tagName
-