Package org.languagetool
Class XMLValidator
java.lang.Object
org.languagetool.XMLValidator
Validate XML files with a given DTD or XML Schema (XSD).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
XML handler that throws exception on error and warning, does nothing otherwise. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Check some limits of our simplified XML output.private Validator
getValidator
(URL xmlSchema) private static Source
mergeIntoSource
(InputStream baseXmlStream, InputStream xmlStream) private void
validateInternal
(String xml, String dtdPath, String docType) private void
validateInternal
(Source xmlSrc, URL xmlSchema) void
validateStringWithXmlSchema
(String xml, String xmlSchemaPath) Validate XML file using the given XSD.void
validateWithDtd
(String filename, String dtdPath, String docType) Validate XML file in classpath with the given DTD.void
validateWithXmlSchema
(String filename, String xmlSchemaPath) Validate XML file using the given XSD.void
validateWithXmlSchema
(String baseFilename, String filename, String xmlSchemaPath) Validate XML file using the given XSD.void
validateXMLString
(String xml, String dtdFile, String docType) Validate XML with the given DTD.
-
Constructor Details
-
XMLValidator
public XMLValidator()
-
-
Method Details
-
checkSimpleXMLString
Check some limits of our simplified XML output.- Throws:
IOException
-
validateXMLString
public void validateXMLString(String xml, String dtdFile, String docType) throws SAXException, IOException, ParserConfigurationException Validate XML with the given DTD. Throws exception on error. -
validateWithDtd
Validate XML file in classpath with the given DTD. Throws exception on error.- Throws:
IOException
-
validateWithXmlSchema
Validate XML file using the given XSD. Throws an exception on error.- Parameters:
filename
- File in classpath to validatexmlSchemaPath
- XML schema file in classpath- Throws:
IOException
-
validateWithXmlSchema
public void validateWithXmlSchema(String baseFilename, String filename, String xmlSchemaPath) throws IOException Validate XML file using the given XSD. Throws an exception on error.- Parameters:
baseFilename
- File to prepend common parts (unification) from before validating main filefilename
- File in classpath to validatexmlSchemaPath
- XML schema file in classpath- Throws:
IOException
-
mergeIntoSource
private static Source mergeIntoSource(InputStream baseXmlStream, InputStream xmlStream) throws Exception - Throws:
Exception
-
validateStringWithXmlSchema
Validate XML file using the given XSD. Throws an exception on error.- Parameters:
xml
- the XML string to be validatedxmlSchemaPath
- XML schema file in classpath- Throws:
IOException
- Since:
- 2.3
-
validateInternal
private void validateInternal(String xml, String dtdPath, String docType) throws SAXException, IOException, ParserConfigurationException -
validateInternal
- Throws:
SAXException
IOException
-
getValidator
- Throws:
SAXException
-