java.lang.Object
cl.netswitch.lib.util.XmlUtil
Provides static utility methods that perform XML operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Document
Create a new instance of a DOM Document object usied to build a DOM trees.static Transformer
Create a new Transformer object that performs a copy of the source to the result.static Document
stringToXml
(String xmlString, InputStream schemaSource) Converts a XML string to a XML document validating with a schema.
-
Method Details
-
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
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.
-