Package org.languagetool
Class XMLValidator
- java.lang.Object
-
- org.languagetool.XMLValidator
-
public final class XMLValidator extends java.lang.ObjectValidate XML files with a given DTD or XML Schema (XSD).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classXMLValidator.ErrorHandlerXML handler that throws exception on error and warning, does nothing otherwise.
-
Constructor Summary
Constructors Constructor Description XMLValidator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckSimpleXMLString(java.lang.String xml)Check some limits of our simplified XML output.private javax.xml.validation.ValidatorgetValidator(java.net.URL xmlSchema)private static javax.xml.transform.SourcemergeIntoSource(java.io.InputStream baseXmlStream, java.io.InputStream xmlStream)private voidvalidateInternal(java.lang.String xml, java.lang.String dtdPath, java.lang.String docType)private voidvalidateInternal(javax.xml.transform.Source xmlSrc, java.net.URL xmlSchema)voidvalidateStringWithXmlSchema(java.lang.String xml, java.lang.String xmlSchemaPath)Validate XML file using the given XSD.voidvalidateWithDtd(java.lang.String filename, java.lang.String dtdPath, java.lang.String docType)Validate XML file in classpath with the given DTD.voidvalidateWithXmlSchema(java.lang.String filename, java.lang.String xmlSchemaPath)Validate XML file using the given XSD.voidvalidateWithXmlSchema(java.lang.String baseFilename, java.lang.String filename, java.lang.String xmlSchemaPath)Validate XML file using the given XSD.voidvalidateXMLString(java.lang.String xml, java.lang.String dtdFile, java.lang.String docType)Validate XML with the given DTD.
-
-
-
Method Detail
-
checkSimpleXMLString
public void checkSimpleXMLString(java.lang.String xml) throws java.io.IOExceptionCheck some limits of our simplified XML output.- Throws:
java.io.IOException
-
validateXMLString
public void validateXMLString(java.lang.String xml, java.lang.String dtdFile, java.lang.String docType) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationExceptionValidate XML with the given DTD. Throws exception on error.- Throws:
org.xml.sax.SAXExceptionjava.io.IOExceptionjavax.xml.parsers.ParserConfigurationException
-
validateWithDtd
public void validateWithDtd(java.lang.String filename, java.lang.String dtdPath, java.lang.String docType) throws java.io.IOExceptionValidate XML file in classpath with the given DTD. Throws exception on error.- Throws:
java.io.IOException
-
validateWithXmlSchema
public void validateWithXmlSchema(java.lang.String filename, java.lang.String xmlSchemaPath) throws java.io.IOExceptionValidate XML file using the given XSD. Throws an exception on error.- Parameters:
filename- File in classpath to validatexmlSchemaPath- XML schema file in classpath- Throws:
java.io.IOException
-
validateWithXmlSchema
public void validateWithXmlSchema(java.lang.String baseFilename, java.lang.String filename, java.lang.String xmlSchemaPath) throws java.io.IOExceptionValidate 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:
java.io.IOException
-
mergeIntoSource
private static javax.xml.transform.Source mergeIntoSource(java.io.InputStream baseXmlStream, java.io.InputStream xmlStream) throws java.lang.Exception- Throws:
java.lang.Exception
-
validateStringWithXmlSchema
public void validateStringWithXmlSchema(java.lang.String xml, java.lang.String xmlSchemaPath) throws java.io.IOExceptionValidate 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:
java.io.IOException- Since:
- 2.3
-
validateInternal
private void validateInternal(java.lang.String xml, java.lang.String dtdPath, java.lang.String docType) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException- Throws:
org.xml.sax.SAXExceptionjava.io.IOExceptionjavax.xml.parsers.ParserConfigurationException
-
validateInternal
private void validateInternal(javax.xml.transform.Source xmlSrc, java.net.URL xmlSchema) throws org.xml.sax.SAXException, java.io.IOException- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
getValidator
private javax.xml.validation.Validator getValidator(java.net.URL xmlSchema) throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException
-
-