Class XMLParser

java.lang.Object
esa.opensf.osfi.XMLParser

@Deprecated(since="3.5.5") public final class XMLParser extends Object
Deprecated.
This class has been moved to XmlFiles and DomUtils to reduce clutter
XMLParser.
XML file builder and parser. Uses the W3C DOM.
  • Method Details

    • read

      @Deprecated(since="3.9.2") public static Document read(String xmlFile, String xsdFile) throws FileNotFoundException, XmlParseException
      Deprecated.
      Due to the convoluted behaviour (to validate against internal schema a non-null but blank file has to be passed).
      Reads a XML file (optionally validating it against a XSD schema) and creates a DOM document.
      Parameters:
      xmlFile - XML file location
      xsdFile - XSD file location. Null if not needed
      Returns:
      The parsed DOM Document.
      Throws:
      FileNotFoundException
      XmlParseException
    • read

      public static Document read(String xmlFile) throws FileNotFoundException, XmlParseException
      Deprecated.
      Read and parse a XML document, without validation.
      Throws:
      FileNotFoundException - if the file cannot be loaded.
      XmlParseException - if the XML cannot be parsed to a DOM document.
    • validateAgainst

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

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

      public static List<Element> getChildElements(Node node, String name)
      Deprecated.
      Given a DOM Node, returns all the direct children elements with the given 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.