OpenMS
XMLValidator.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Marc Sturm $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 
13 #include <xercesc/sax/ErrorHandler.hpp>
14 
15 #include <iostream>
16 
17 namespace OpenMS
18 {
26  class OPENMS_DLLAPI XMLValidator :
27  private xercesc::ErrorHandler
28  {
29 public:
32 
45  bool isValid(const String& filename, const String& schema, std::ostream& os = std::cerr);
46 
47 protected:
49  bool valid_;
52  //output stream reference (for error messages)
53  std::ostream* os_;
54 
56 
57  void warning(const xercesc::SAXParseException& exception) override;
58  void error(const xercesc::SAXParseException& exception) override;
59  void fatalError(const xercesc::SAXParseException& exception) override;
60  void resetErrors() override;
62  };
63 
64 } // namespace OpenMS
65 
A more convenient string class.
Definition: String.h:34
Validator for XML files.
Definition: XMLValidator.h:28
void resetErrors() override
std::ostream * os_
Definition: XMLValidator.h:53
void warning(const xercesc::SAXParseException &exception) override
bool valid_
Flag if the validated file is valid.
Definition: XMLValidator.h:49
String filename_
File name of validated file (for error messages)
Definition: XMLValidator.h:51
XMLValidator()
Constructor.
void fatalError(const xercesc::SAXParseException &exception) override
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.
void error(const xercesc::SAXParseException &exception) override
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22