Class XPathUtils
java.lang.Object
eu.europa.esig.dss.xml.utils.xpath.XPathUtils
This class contains utility methods for XPath execution, such as NodeList extraction, etc.
-
Method Summary
Modifier and TypeMethodDescriptiongetChildrenNames(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) This method returns the list of children's names for a givenNode.static ElementgetElement(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) Returns the Element corresponding to the XPath query.static ElementgetElementById(Node node, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery, String id) Extract an element from the givennodeaccording to thexPathQuerywith the matchingidif any.static ElementgetElementById(Node node, String id) Extract an element from the given documentnodewith the given Id.static NamespaceContextMapThis method returns stored namespace definitions mapstatic NodeReturns the Node corresponding to the XPath query.static NodeListgetNodeList(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) Returns the NodeList corresponding to the XPath query.static intgetNodesAmount(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) Returns an amount of found nodes matching thexPathStringstatic StringReturns the String value of the corresponding to the XPath query.static XPathQueryExecutorGets the XPath Query executorstatic booleanregisterNamespace(eu.europa.esig.dss.xml.common.definition.DSSNamespace namespace) This method allows to register a namespace and associated prefix.static voidsetXPathQueryExecutor(XPathQueryExecutor xPathQueryExecutor) Sets the XPathQueryExecutor to be used by the implementation.
-
Method Details
-
getXPathQueryExecutor
Gets the XPath Query executor- Returns:
XPathQueryExecutor
-
setXPathQueryExecutor
Sets the XPathQueryExecutor to be used by the implementation. This method also sets a namespace context to the executor defined within the implementation. Default : Loads implementation accessible through ServiceLoader mechanism.- Parameters:
xPathQueryExecutor-XPathQueryExecutor
-
registerNamespace
public static boolean registerNamespace(eu.europa.esig.dss.xml.common.definition.DSSNamespace namespace) This method allows to register a namespace and associated prefix. If the prefix exists already it is replaced.- Parameters:
namespace- namespace object with the prefix and the URI- Returns:
- true if this map did not already contain the specified element
-
getNamespaceContextMap
This method returns stored namespace definitions map- Returns:
NamespaceContextMapa map with the prefix and the related URI
-
getValue
public static String getValue(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) Returns the String value of the corresponding to the XPath query.- Parameters:
xmlNode- The node where the search should be performed.xPathQuery-XPathQuery- Returns:
- string value of the XPath query
-
getNodeList
public static NodeList getNodeList(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) Returns the NodeList corresponding to the XPath query.- Parameters:
xmlNode- The node where the search should be performed.xPathQuery-XPathQuery- Returns:
- the NodeList corresponding to the XPath query
-
getNode
-
getElement
public static Element getElement(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) Returns the Element corresponding to the XPath query.- Parameters:
xmlNode- The node where the search should be performed.xPathQuery-XPathQuery- Returns:
- the Element corresponding to the XPath query
-
getNodesAmount
public static int getNodesAmount(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) Returns an amount of found nodes matching thexPathString- Parameters:
xmlNode- the current nodexPathQuery-XPathQuery- Returns:
- an amount of returned nodes
-
getChildrenNames
public static List<String> getChildrenNames(Node xmlNode, eu.europa.esig.dss.xml.common.xpath.XPathQuery xPathQuery) This method returns the list of children's names for a givenNode.- Parameters:
xmlNode- The node where the search should be performed.xPathQuery-XPathQuery- Returns:
Listof children's names
-
getElementById
Extract an element from the given documentnodewith the given Id. The method is namespace independent. -
getElementById
-