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 classXML handler that throws exception on error and warning, does nothing otherwise. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck some limits of our simplified XML output.private ValidatorgetValidator(URL xmlSchema) private static SourcemergeIntoSource(InputStream baseXmlStream, InputStream xmlStream) private voidvalidateInternal(String xml, String dtdPath, String docType) private voidvalidateInternal(Source xmlSrc, URL xmlSchema) voidvalidateStringWithXmlSchema(String xml, String xmlSchemaPath) Validate XML file using the given XSD.voidvalidateWithDtd(String filename, String dtdPath, String docType) Validate XML file in classpath with the given DTD.voidvalidateWithXmlSchema(String filename, String xmlSchemaPath) Validate XML file using the given XSD.voidvalidateWithXmlSchema(String baseFilename, String filename, String xmlSchemaPath) Validate XML file using the given XSD.voidvalidateXMLString(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:
SAXExceptionIOException
-
getValidator
- Throws:
SAXException
-