Class XmlUtils
java.lang.Object
eu.europa.ec.taxud.validation.utils.XmlUtils
XmlUtils contains XML helper methods.-
Method Summary
Modifier and TypeMethodDescriptionfindElements(ValidationContext context, Element element, String path) Search for Element based on XPath and current Validation Context.findElementsWithoutAncestors(ValidationContext context, Element element, String path) Search for Element based on XPath and current Validation Context.static ObjectgetChildObjectValue(ValidationContext context, Node node, String path, QName type) Get the value of a child object based on XPath, current Node and current Validation Context.getElements(NodeList list) convert NodeList to List<Element>.static NodeListgetNodeList(ValidationContext context, Element element, String path) Returns the node list based on XPath and current Validation Context.static NodeListgetNodeListWithoutAncestors(ValidationContext context, Element element, String path) Returns the node list based on XPath and current Validation Context.static ObjectgetObjectValue(ValidationContext context, Node node, String path, QName type) Get the value of an object based on XPath, current Node and current Validation Context.
-
Method Details
-
getElements
convert NodeList to List<Element>.- Parameters:
list- NodeList to convert.- Returns:
- List of Element.
-
findElements
public static List<Element> findElements(ValidationContext context, Element element, String path) throws XPathExpressionException Search for Element based on XPath and current Validation Context.- Parameters:
context- The Validation Context (containing the XPath).element- The current Element for the search.path- The XPath from current element.- Returns:
- The List of Element found.
- Throws:
XPathExpressionException- the x path expression exception.
-
findElementsWithoutAncestors
public static List<Element> findElementsWithoutAncestors(ValidationContext context, Element element, String path) throws XPathExpressionException Search for Element based on XPath and current Validation Context. Be careful, this method creates a clone of the given Element to delete references from its ancestors to optimize the running time.- Parameters:
context- The Validation Context (containing the XPath).element- The current Element for the search.path- The XPath from current element.- Returns:
- The List of Element found.
- Throws:
XPathExpressionException- the x path expression exception.
-
getNodeList
public static NodeList getNodeList(ValidationContext context, Element element, String path) throws XPathExpressionException Returns the node list based on XPath and current Validation Context.- Parameters:
context- The Validation Context (containing the XPath).element- The current Element for the search.path- The XPath from current element.- Returns:
- The node list.
- Throws:
XPathExpressionException- the x path expression exception.
-
getNodeListWithoutAncestors
public static NodeList getNodeListWithoutAncestors(ValidationContext context, Element element, String path) throws XPathExpressionException Returns the node list based on XPath and current Validation Context. Be careful, this method creates a clone of the given Element to delete references from its ancestors to optimize the running time.- Parameters:
context- The Validation Context (containing the XPath).element- The current Element for the search.path- The XPath from current element.- Returns:
- The node list.
- Throws:
XPathExpressionException- the x path expression exception.
-
getObjectValue
Get the value of an object based on XPath, current Node and current Validation Context.- Parameters:
context- The Validation Context (containing the XPath).node- The current node.path- The current path.type- The type.- Returns:
- Return the object corresponding to the query.
-
getChildObjectValue
public static Object getChildObjectValue(ValidationContext context, Node node, String path, QName type) Get the value of a child object based on XPath, current Node and current Validation Context.- Parameters:
context- The Validation Context (containing the XPath).node- The current node.path- The current path.type- The type.- Returns:
- Return the object corresponding to the query.
-