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 classDefines an input source based on the correct path to external entities.(package private) static classXML handler that throws exception on error and warning, does nothing otherwise.(package private) static classDefines an EntityResolver-like object (cf. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate ValidatorgetValidator(URL xmlSchema, String xmlPath) private static SourcemergeIntoSource(InputStream baseXmlStream, InputStream xmlStream, String baseXmlPath) private voidvalidateInternal(String xml, String dtdPath, String docType) private voidvalidateInternal(Source xmlSrc, URL xmlSchema, String xmlPath) voidvalidateStringWithXmlSchema(String xml, String xmlSchemaPath, String xmlPath) 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
-
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, String baseXmlPath) throws Exception - Throws:
Exception
-
validateStringWithXmlSchema
public void validateStringWithXmlSchema(String xml, String xmlSchemaPath, String xmlPath) throws IOException 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
private void validateInternal(Source xmlSrc, URL xmlSchema, String xmlPath) throws SAXException, IOException - Throws:
SAXExceptionIOException
-
getValidator
- Throws:
SAXException
-