java.lang.Object
bayern.steinbrecher.javaUtility.XMLUtility
public final class XMLUtility
extends java.lang.Object
Contains convenient method for handling and checking XML files.
- Since:
- 0.1
-
Method Summary
Modifier and Type Method Description static java.util.Optional<java.lang.String>isValidXML(java.lang.String xml, java.net.URL schema)Checks whether the givenStringcontains valid XML based on the given schemas.
-
Method Details
-
isValidXML
public static java.util.Optional<java.lang.String> isValidXML(java.lang.String xml, java.net.URL schema) throws org.xml.sax.SAXException, java.io.IOExceptionChecks whether the givenStringcontains valid XML based on the given schemas.- Parameters:
xml- The XML content to check.schema- The XSD schema to validate against.- Returns:
- An
Optionalcontaining the error output ifXMLis erroneous. IfOptional.empty()is returned the XML does not contain errors but it may still contain warnings. If so these are logged. - Throws:
org.xml.sax.SAXException- If any parse error occurs.java.io.IOException- If any I/O error occurs.
-