Class XmlUtils

java.lang.Object
eu.europa.ec.taxud.validation.utils.XmlUtils

public final class XmlUtils extends Object
XmlUtils contains XML helper methods.
  • Method Details

    • getElements

      public static List<Element> getElements(NodeList list)
      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

      public static Object getObjectValue(ValidationContext context, Node node, String path, QName type)
      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.