| OpenMS 2.5.0

Public Member Functions | Protected Attributes | List of all members
XMLValidator Class Reference
Format » File IO

Validator for XML files. More...

`#include <OpenMS/FORMAT/VALIDATORS/XMLValidator.h>`

Inheritance diagram for XMLValidator:

## Public Member Functions

| XMLValidator ()
| Constructor. More...
bool | isValid (const String &filename, const String &schema, std::ostream &os=std::cerr)
| Returns if an XML file is valid for given a schema file. More...

## Protected Member Functions

Implementation of Xerces ErrorHandler methods
void | warning (const xercesc::SAXParseException &exception) override
void | error (const xercesc::SAXParseException &exception) override
void | fatalError (const xercesc::SAXParseException &exception) override
void | resetErrors () override

## Protected Attributes

bool | valid_
| Flag if the validated file is valid. More...
String | filename_
| File name of validated file (for error messages) More...
std::ostream * | os_

## Detailed Description

Validator for XML files.

Validates an XML file against a given schema.

## Constructor & Destructor Documentation

## ◆ XMLValidator()

XMLValidator | ( |  | ) |

Constructor.

## Member Function Documentation

## ◆ error()

void error | ( | const xercesc::SAXParseException & | exception | ) |

override protected

## ◆ fatalError()

void fatalError | ( | const xercesc::SAXParseException & | exception | ) |

override protected

## ◆ isValid()

bool isValid | ( | const String & | filename,
|  | const String & | schema,
|  | std::ostream & | os = `std::cerr`
| ) |  |

Returns if an XML file is valid for given a schema file.

Error messages are printed to the error stream, unless redirected with the attribute `os` .

Parameters

  filename | The file to validated.
  schema | The filename of the schema that should be used for validation.
  os | The stream where error messages should be send to.

Exceptions

  Exception::FileNotFound | is thrown if the file cannot be found
  Exception::ParseError | is thrown if the parser could not be initialized

## ◆ resetErrors()

void resetErrors | ( |  | ) |

override protected

## ◆ warning()

void warning | ( | const xercesc::SAXParseException & | exception | ) |

override protected

## Member Data Documentation

## ◆ filename_

String filename_

protected

File name of validated file (for error messages)

## ◆ os_

std::ostream* os_

protected

## ◆ valid_

bool valid_

protected

Flag if the validated file is valid.