Class XmlUtil

java.lang.Object
cl.netswitch.lib.util.XmlUtil

public final class XmlUtil extends Object
Provides static utility methods that perform XML operations.
  • Method Details

    • getDocument

      public static Document getDocument()
      Create a new instance of a DOM Document object usied to build a DOM trees. The Document is created with a DocumentBuilder that is created the first time it is needed.
      Returns:
      a new Document instance.
    • getTransformer

      public static Transformer getTransformer()
      Create a new Transformer object that performs a copy of the source to the result. The Transformer is created with a TransformerFactory that is created the first time is needed.
      Returns:
      a new Transformer instance.
    • stringToXml

      public static Document stringToXml(String xmlString, InputStream schemaSource) throws SAXException, IOException, ParserConfigurationException
      Converts a XML string to a XML document validating with a schema.
      Parameters:
      xmlString - a string with a XML representation of the document.
      schemaSource - the input stream of a XML schema (can be null).
      Returns:
      the XML document obtained from supplied xmlString.
      Throws:
      ParserConfigurationException - if a configuration error occurs.
      SAXException - if a XML parse error occurs.
      IOException - if an I/O error occurs.