be.fgov.ehealth.ehvalidator.core
Class EhValidator

java.lang.Object
  extended by be.fgov.ehealth.ehvalidator.core.EhValidator

public class EhValidator
extends Object

EhValidator

This library can help software makers or command-line enthusiasts to validate a file against the Sumehr, SMF or PMF standard. These standards are published by the e-Health platform on the KMEHR website. For a file to be validated, it must use the kmehr namespace (xmlns="http://www.ehealth.fgov.be/standards/kmehr/schema/v1"). A Sumehr, SMF or PMF is considered valid if and only if the validation report contains no lines with Error, Warning messages are allowed. Depending on the type of file, the result of the validation will be as follows :
File TypeValidation ResultComments
Any file but a Kmehr DocumentFailureThis will generate an EhValidatorXmlValidationException - The file will fail the basic XML checks
A Kmehr Document that does not follow the Sumehr or GSMF StandardFailureThis will produce a validation report containing at least one Error
A Sumehr, SMF or PMF DocumentSuccessThis will produce a validation report containing no Error messages. Warning messages may be present.

Since:
1.0
Author:
Charles-Louis de Maere

Nested Class Summary
static class EhValidator.Language
          allowed languages.
static class EhValidator.ValidationResult
          Validation results.
 
Constructor Summary
EhValidator()
           
 
Method Summary
static String getHTMLReport(String fileName)
          This method performs a validation of the file whose file name is provided as parameter.
static String getHTMLReport(String fileName, EhValidator.Language language)
          This method performs a validation of the file whose file name and language are provided as parameters.
static String getHTMLReport(String fileName, EhValidator.Language language, String rules)
          This method performs a validation of the file whose file name, language and set of rules are provided as parameters.
static String getHTMLView(String fileName)
          This method allows to get the HTML representation of a valid file.
static String getHTMLView(String fileName, EhValidator.Language language)
          This method allows to get the HTML representation of a valid file.
static String getHTMLView(String fileName, EhValidator.Language language, String rules)
          This method allows to get the HTML representation of a valid file.
static String getXMLReport(String fileName)
          This method performs a validation of the file whose file name is provided as parameter.
static String getXMLReport(String fileName, String rules)
          This method performs a validation of the file whose file name and set of rules are provided as parameter.
static void main(String[] args)
          This is the main method of the eHealth Validator, used when run in command-line mode.
static EhValidator.ValidationResult validate(String fileName)
           
static EhValidator.ValidationResult validate(String fileName, String rules)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EhValidator

public EhValidator()
Method Detail

getHTMLReport

public static String getHTMLReport(String fileName)
                            throws SAXException,
                                   FileNotFoundException,
                                   IOException
This method performs a validation of the file whose file name is provided as parameter. The method then returns a String containing the validation report in HTML format.

Parameters:
fileName - Name of the file to validate.
Returns:
a String containing the HTML representation of the report.
Throws:
SAXException
IOException
FileNotFoundException

getHTMLReport

public static String getHTMLReport(String fileName,
                                   EhValidator.Language language)
                            throws SAXException,
                                   FileNotFoundException,
                                   IOException
This method performs a validation of the file whose file name and language are provided as parameters. The method then returns a String containing the validation report in HTML format.

Parameters:
fileName - Name of the file to validate.
language - Default language for Sumehr visualization.
Returns:
a String containing the HTML representation of the report.
Throws:
SAXException
IOException
FileNotFoundException

getHTMLReport

public static String getHTMLReport(String fileName,
                                   EhValidator.Language language,
                                   String rules)
                            throws SAXException,
                                   FileNotFoundException,
                                   IOException
This method performs a validation of the file whose file name, language and set of rules are provided as parameters. The method then returns a String containing the validation report in HTML format.

Parameters:
fileName - Name of the file to validate.
language - Default language for Sumehr visualization.
rules - Set of rules to use for the validation. ("Sumehr" or "PMF" or "SMF")
Returns:
a String containing the HTML representation of the report.
Throws:
SAXException
IOException
FileNotFoundException

getXMLReport

public static String getXMLReport(String fileName)
                           throws SAXException,
                                  FileNotFoundException,
                                  IOException
This method performs a validation of the file whose file name is provided as parameter. The method then returns a String containing the validation report in XML format. The report uses the following format :
 <report>
      <header>
          <validationResult>
              <errors> </errors>
              <warnings> </warnings>
          </validationResult>
      </header>
      <messages>
          <message>
              <type> </type>
              <subject> </subject>
              <description>
                  <en> </en>
                  <fr> </fr>
                  <nl> </nl>
                  <de> </de>
              </description>
              <line> </line>
              <col> </col>
              <location> </location>
              <test> </test>
          </message>
          ...
      </messages>
 </report>
 

Parameters:
fileName - Name of the file to validate
Returns:
a String containing an XML representation of the report.
Throws:
SAXException
IOException
FileNotFoundException

getXMLReport

public static String getXMLReport(String fileName,
                                  String rules)
                           throws SAXException,
                                  FileNotFoundException,
                                  IOException
This method performs a validation of the file whose file name and set of rules are provided as parameter. The method then returns a String containing the validation report in XML format. The report uses the following format :
 <report>
      <header>
          <validationResult>
              <errors> </errors>
              <warnings> </warnings>
          </validationResult>
      </header>
      <messages>
          <message>
              <type> </type>
              <subject> </subject>
              <description>
                  <en> </en>
                  <fr> </fr>
                  <nl> </nl>
                  <de> </de>
              </description>
              <line> </line>
              <col> </col>
              <location> </location>
              <test> </test>
          </message>
          ...
      </messages>
 </report>
 

Parameters:
fileName - Name of the file to validate.
rules - Set of rules to use for the validation.
Returns:
a String containing an XML representation of the report.
Throws:
SAXException
IOException
FileNotFoundException

getHTMLView

public static String getHTMLView(String fileName)
                          throws EhValidatorXmlValidationException,
                                 EhValidatorSchematronException,
                                 EhValidatorXsltTransformException,
                                 FileNotFoundException,
                                 IOException,
                                 SAXException
This method allows to get the HTML representation of a valid file. If the file is valid, and can be viewed as HTML, it returns a String representation of this HTML visualisation. Use english as default language for visualization.

Parameters:
fileName - Name of the file to view as HTML. It should be valid.
Returns:
a String containing an HTML representation of the file.
Throws:
EhValidatorXmlValidationException - when the file fails basic schema validation.
EhValidatorSchematronException - when the file is not a valid, and there were issues with the schematron validation.
EhValidatorXsltTransformException - when there was an issue producing the HTML view of the file.
IOException
FileNotFoundException
SAXException

getHTMLView

public static String getHTMLView(String fileName,
                                 EhValidator.Language language)
                          throws EhValidatorXmlValidationException,
                                 EhValidatorSchematronException,
                                 EhValidatorXsltTransformException,
                                 FileNotFoundException,
                                 IOException,
                                 SAXException
This method allows to get the HTML representation of a valid file. If the file is valid, and can be viewed as HTML, it returns a String representation of this HTML visualisation. Use Sumehr as default set of rules.

Parameters:
fileName - Name of the file to validate.
language - Default language for visualization.
Returns:
a String containing an HTML representation of the file.
Throws:
EhValidatorXmlValidationException
EhValidatorSchematronException
EhValidatorXsltTransformException
IOException
FileNotFoundException
SAXException

getHTMLView

public static String getHTMLView(String fileName,
                                 EhValidator.Language language,
                                 String rules)
                          throws EhValidatorXmlValidationException,
                                 EhValidatorSchematronException,
                                 EhValidatorXsltTransformException,
                                 FileNotFoundException,
                                 IOException,
                                 SAXException
This method allows to get the HTML representation of a valid file. If the file is valid, and can be viewed as HTML, it returns a String representation of this HTML visualisation.

Parameters:
fileName - Name of the file to view as HTML. It should be valid.
language - Default language for Sumehr visualization.
rules - Set of rules to use for the validation. ("Sumehr" or "PMF" or "SMF")
Returns:
a String containing an HTML representation of the file.
Throws:
EhValidatorXmlValidationException - when the file fails basic schema validation.
EhValidatorSchematronException - when the file is not a valid file, and there were issues with the schematron validation.
EhValidatorXsltTransformException - when there was an issue producing the HTML view of the file.
IOException
FileNotFoundException
SAXException

validate

public static EhValidator.ValidationResult validate(String fileName)
                                             throws EhValidatorXmlValidationException,
                                                    EhValidatorSchematronException,
                                                    IOException,
                                                    SAXException
Parameters:
fileName - Name of the file to validate.
Returns:
The validation result.
Throws:
EhValidatorXmlValidationException
EhValidatorSchematronException
IOException
SAXException

validate

public static EhValidator.ValidationResult validate(String fileName,
                                                    String rules)
                                             throws EhValidatorXmlValidationException,
                                                    EhValidatorSchematronException,
                                                    IOException,
                                                    SAXException
Parameters:
fileName - Name of the file to validate. It should be a valid Kmehr.
rules - Set of rules to use for the validation. ("Sumehr" or "PMF" or "SMF")
Returns:
a boolean containing true if the input file is correct, false otherwise.
Throws:
EhValidatorXmlValidationException - when the file fails basic schema validation.
EhValidatorSchematronException - when the file is not valid, and there were issues with the schematron validation.
IOException
SAXException

main

public static void main(String[] args)
This is the main method of the eHealth Validator, used when run in command-line mode. In this mode, the tool can be used as follows :
ehvalidator-core-2.1.1.jar [option] [choice] [inputfile]

Options:

-v|--version : Show version info and halt
-h|--help|-? : Show usage
-r|--request : Execute validation
-r|--request : Execute validation for specified set of rules

Choices:

validation : Get Validation Result
xmlreport : Get Report as XML
htmlreport : Get Report as HTML
htmlreporten : Get Report as HTML with english as default language
htmlreportfr : Get Report as HTML with french as default language
htmlreportnl : Get Report as HTML with dutch as default language
htmlreportde : Get Report as HTML with german as default language
htmlview : Get View as HTML (default language : english)
htmlviewen : Get View as HTML with english as default language
htmlviewfr : Get View as HTML with french as default language
htmlviewnl : Get View as HTML with dutch as default language
htmlviewde : Get View as HTML with german as default language

Example:

ehvalidator-core-2.1.1.jar -request xmlreport document.xml

Parameters:
args - The arguments as defined above.


eHealth Validator Service Master project 2.1.1 API
Copyright © 2013 eHealth. All Rights Reserved.