Class DomUtils

java.lang.Object
esa.opensf.osfi.xmlutils.DomUtils

public final class DomUtils extends Object
Utility class with methods that work on DOM nodes, documents and elements.
  • Method Details

    • validateAgainst

      public static boolean validateAgainst(Node docOrEl, String xsdFile)
      Validate a document/element tree against an external XSD file.
      Parameters:
      docOrEl - XML document or element to be validated
      xsdFile - Path to an XSD schema file
      Returns:
      true if the validation succeeds, false otherwise.
      Throws:
      IllegalArgumentException - if the schema cannot be loaded
    • validateAgainstInternalSchema

      public static boolean validateAgainstInternalSchema(Node docOrEl)
      Validate a document/element tree against a XSD schema referenced in the XML itself.
      Parameters:
      docOrEl - XML document or element to be validated
      Returns:
      true if the validation succeeds, false otherwise.
    • getChildElements

      public static List<Element> getChildElements(Node node, String name)
      Parameters:
      node - Node whose direct children will be filtered
      name - String that will be checked against the Node.getNodeName() value. If null, all direct child elements will be returned.
      Returns:
      List of all the direct children elements with the given tag name