Class XMLValidator


  • public final class XMLValidator
    extends Object
    Validate XML files with a given DTD or XML Schema (XSD).
    Author:
    Daniel Naber
    • Constructor Detail

      • XMLValidator

        public XMLValidator()
    • Method Detail

      • checkSimpleXMLString

        public void checkSimpleXMLString​(String xml)
                                  throws IOException
        Check some limits of our simplified XML output.
        Throws:
        IOException
      • validateWithDtd

        public void validateWithDtd​(String filename,
                                    String dtdPath,
                                    String docType)
                             throws IOException
        Validate XML file in classpath with the given DTD. Throws exception on error.
        Throws:
        IOException
      • validateWithXmlSchema

        public void validateWithXmlSchema​(String filename,
                                          String xmlSchemaPath)
                                   throws IOException
        Validate XML file using the given XSD. Throws an exception on error.
        Parameters:
        filename - File in classpath to validate
        xmlSchemaPath - 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 file
        filename - File in classpath to validate
        xmlSchemaPath - XML schema file in classpath
        Throws:
        IOException
      • validateStringWithXmlSchema

        public void validateStringWithXmlSchema​(String xml,
                                                String xmlSchemaPath)
                                         throws IOException
        Validate XML file using the given XSD. Throws an exception on error.
        Parameters:
        xml - the XML string to be validated
        xmlSchemaPath - XML schema file in classpath
        Throws:
        IOException
        Since:
        2.3