OpenMS  3.0.0
XMLValidator.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2022.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
38 
39 #include <xercesc/sax/ErrorHandler.hpp>
40 
41 #include <iostream>
42 
43 namespace OpenMS
44 {
52  class OPENMS_DLLAPI XMLValidator :
53  private xercesc::ErrorHandler
54  {
55 public:
57  XMLValidator();
58 
71  bool isValid(const String& filename, const String& schema, std::ostream& os = std::cerr);
72 
73 protected:
75  bool valid_;
78  //output stream reference (for error messages)
79  std::ostream* os_;
80 
82 
83  void warning(const xercesc::SAXParseException& exception) override;
84  void error(const xercesc::SAXParseException& exception) override;
85  void fatalError(const xercesc::SAXParseException& exception) override;
86  void resetErrors() override;
88  };
89 
90 } // namespace OpenMS
91 
OpenMS::XMLValidator::valid_
bool valid_
Flag if the validated file is valid.
Definition: XMLValidator.h:75
OpenMS::FileTypes::IDXML
OpenMS identification format (.idXML)
Definition: FileTypes.h:64
ConsensusXMLFile.h
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:147
FileHandler.h
FileTypes.h
OpenMS::FileTypes::MZDATA
MzData file (.mzData)
Definition: FileTypes.h:61
OpenMS::MzDataFile
File adapter for MzData files.
Definition: MzDataFile.h:53
OpenMS::FileTypes::MZML
MzML file (.mzML)
Definition: FileTypes.h:70
OpenMS::FileTypes::MZXML
MzXML file (.mzXML)
Definition: FileTypes.h:62
OpenMS::FileTypes::PEPXML
TPP pepXML file (.pepXML)
Definition: FileTypes.h:73
OpenMS::MzMLFile::isValid
bool isValid(const String &filename, std::ostream &os=std::cerr)
Checks if a file validates against the XML schema.
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:57
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::XMLValidator::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.
ParamXMLFile.h
XMLValidator.h
MzMLFile.h
OpenMS::FileTypes::CONSENSUSXML
OpenMS consensus map format (.consensusXML)
Definition: FileTypes.h:65
OpenMS::FileTypes::INI
OpenMS parameters file (.ini)
Definition: FileTypes.h:67
IdXMLFile.h
FeatureXMLFile.h
OpenMS::ParamXMLFile
The file pendant of the Param class used to load and store the param datastructure as paramXML.
Definition: ParamXMLFile.h:49
OpenMS::Internal::ClassTest::exception
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
OpenMS::MzXMLFile
File adapter for MzXML 3.1 files.
Definition: MzXMLFile.h:52
OpenMS::FileTypes::UNKNOWN
Unknown file extension.
Definition: FileTypes.h:58
OpenMS::XMLValidator
Validator for XML files.
Definition: XMLValidator.h:52
OpenMS::Internal::XMLFile::getVersion
const String & getVersion() const
return the version of the schema
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::TraMLFile
File adapter for HUPO PSI TraML files.
Definition: TraMLFile.h:63
OpenMS::FileTypes::FEATUREXML
OpenMS feature file (.featureXML)
Definition: FileTypes.h:63
OpenMS::Internal::XMLFile::isValid
bool isValid(const String &filename, std::ostream &os)
Checks if a file validates against the XML schema.
MzXMLFile.h
OpenMS::FileTypes::Type
Type
Actual file types enum.
Definition: FileTypes.h:56
OpenMS::FileHandler::getType
static FileTypes::Type getType(const String &filename)
Tries to determine the file type (by name or content)
PepXMLFile.h
OpenMS::XMLValidator::os_
std::ostream * os_
Definition: XMLValidator.h:79
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:71
OpenMS::FeatureXMLFile
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLFile.h:62
OpenMS::XMLValidator::filename_
String filename_
File name of validated file (for error messages)
Definition: XMLValidator.h:77
String.h
OpenMS::FileTypes::TRAML
TraML (HUPO PSI format) for transitions (.traML)
Definition: FileTypes.h:80
MzDataFile.h
OpenMS::PepXMLFile
Used to load and store PepXML files.
Definition: PepXMLFile.h:63
TraMLFile.h
MzIdentMLFile.h
TOPPBase.h
OpenMS::ConsensusXMLFile
This class provides Input functionality for ConsensusMaps and Output functionality for alignments and...
Definition: ConsensusXMLFile.h:58
OpenMS::IdXMLFile
Used to load and store idXML files.
Definition: IdXMLFile.h:68
OpenMS::FileTypes::typeToName
static String typeToName(Type type)
Returns the name/extension of the type.