OpenMS
Loading...
Searching...
No Matches
XMLValidator Class Reference

Validator for XML files. More...

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

Collaboration diagram for XMLValidator:
[legend]

Public Member Functions

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

Protected Member Functions

void logError_ (const std::string &kind, const std::string &message, unsigned long line, unsigned long column)
 

Protected Attributes

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

Friends

class XMLValidatorErrorHandler_
 The internal Xerces ErrorHandler bridge needs access to logError_.
 

Detailed Description

Validator for XML files.

Validates an XML file against a given schema.

Constructor & Destructor Documentation

◆ XMLValidator()

Constructor.

Member Function Documentation

◆ isValid()

bool isValid ( const std::string &  filename,
const std::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
[in]filenameThe file to validated.
[in]schemaThe filename of the schema that should be used for validation.
[in]osThe stream where error messages should be send to.
Exceptions
Exception::FileNotFoundis thrown if the file cannot be found
Exception::ParseErroris thrown if the parser could not be initialized

◆ logError_()

void logError_ ( const std::string &  kind,
const std::string &  message,
unsigned long  line,
unsigned long  column 
)
protected

Record a validation problem. Called by the internal Xerces ErrorHandler bridge (defined in the .cpp); keeps Xerces out of this public header.

Friends And Related Symbol Documentation

◆ XMLValidatorErrorHandler_

friend class XMLValidatorErrorHandler_
friend

The internal Xerces ErrorHandler bridge needs access to logError_.

Member Data Documentation

◆ filename_

std::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.