Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

SemanticValidator Class Reference

Semantically validates XML files using CVMappings and a ControlledVocabulary. More...

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

Inheritance diagram for SemanticValidator:
XMLHandler XMLFile DefaultHandler MzDataValidator MzIdentMLValidator MzMLValidator MzQuantMLValidator TraMLValidator

List of all members.

Classes

struct  CVTerm
 Representation of a parsed CV term. More...

Public Member Functions

 SemanticValidator (const CVMappings &mapping, const ControlledVocabulary &cv)
 Constructor.
virtual ~SemanticValidator ()
 Destructor.
bool validate (const String &filename, StringList &errors, StringList &warnings)
 Semantically validates an XML file.
bool locateTerm (const String &path, const CVTerm &parsed_term) const
 Checks if a CVTerm is allowed in a given path.
void setTag (const String &tag)
 Sets the CV parameter tag name (default: 'cvParam').
void setAccessionAttribute (const String &accession)
 Sets the name of the attribute for accessions in the CV parameter tag name (default: 'accession').
void setNameAttribute (const String &name)
 Sets the name of the attribute for accessions in the CV parameter tag name (default: 'name').
void setValueAttribute (const String &value)
 Sets the name of the attribute for accessions in the CV parameter tag name (default: 'value').
void setCheckTermValueTypes (bool check)
 Set if CV term value types should be check (enabled by default).
void setCheckUnits (bool check)
 Set if CV term units should be check (disabled by default).
void setUnitAccessionAttribute (const String &accession)
 Sets the name of the unit accession attribute (default: 'unitAccession').
void setUnitNameAttribute (const String &name)
 Sets the name of the unit name attribute (default: 'unitName').

Protected Member Functions

void startElement (const XMLCh *const , const XMLCh *const , const XMLCh *const qname, const xercesc::Attributes &attributes)
void endElement (const XMLCh *const , const XMLCh *const , const XMLCh *const qname)
void characters (const XMLCh *const chars, const XMLSize_t)
virtual String getPath_ (UInt remove_from_end=0) const
 Returns the current element path.
virtual void getCVTerm_ (const xercesc::Attributes &attributes, CVTerm &parsed_term)
 Parses the CV term accession (required), name (required) and value (optional) from the XML attributes.
virtual void handleTerm_ (const String &path, const CVTerm &parsed_term)
 Handling of the term.

Protected Attributes

const CVMappingsmapping_
 Reference to the mappings.
const ControlledVocabularycv_
 Reference to the CVs.
StringList errors_
 Validation erros.
StringList warnings_
 Validation warnings.
StringList open_tags_
 List of open tags.
Map< String, std::vector
< CVMappingRule > > 
rules_
 Rules (location => rule).
Map< String, Map< String, Map
< String, UInt > > > 
fulfilled_
Tag and attribute names

String cv_tag_
String accession_att_
String name_att_
String value_att_
String unit_accession_att_
String unit_name_att_
bool check_term_value_types_
bool check_units_

Private Member Functions

 SemanticValidator ()
 Not implemented.
 SemanticValidator (const SemanticValidator &rhs)
 Not implemented.
SemanticValidatoroperator= (const SemanticValidator &rhs)
 Not implemented.

Detailed Description

Semantically validates XML files using CVMappings and a ControlledVocabulary.

This is the general validator.
Specialized validators for specific file formats are derived from this class.


Constructor & Destructor Documentation

SemanticValidator ( const CVMappings mapping,
const ControlledVocabulary cv 
)

Constructor.

Parameters:
mapping The mapping rules
cv All controlled vocabularies required for the mapping
virtual ~SemanticValidator (  )  [virtual]

Destructor.

SemanticValidator (  )  [private]

Not implemented.

SemanticValidator ( const SemanticValidator rhs  )  [private]

Not implemented.


Member Function Documentation

void characters ( const XMLCh *const   chars,
const   XMLSize_t 
) [protected]
void endElement ( const XMLCh *  const,
const XMLCh *  const,
const XMLCh *const   qname 
) [protected]
virtual void getCVTerm_ ( const xercesc::Attributes &  attributes,
CVTerm parsed_term 
) [protected, virtual]

Parses the CV term accession (required), name (required) and value (optional) from the XML attributes.

virtual String getPath_ ( UInt  remove_from_end = 0  )  const [protected, virtual]

Returns the current element path.

Reimplemented in MzMLValidator.

virtual void handleTerm_ ( const String path,
const CVTerm parsed_term 
) [protected, virtual]

Handling of the term.

Reimplemented in MzDataValidator, and MzMLValidator.

bool locateTerm ( const String path,
const CVTerm parsed_term 
) const

Checks if a CVTerm is allowed in a given path.

SemanticValidator& operator= ( const SemanticValidator rhs  )  [private]

Not implemented.

void setAccessionAttribute ( const String accession  ) 

Sets the name of the attribute for accessions in the CV parameter tag name (default: 'accession').

void setCheckTermValueTypes ( bool  check  ) 

Set if CV term value types should be check (enabled by default).

If set to true, the xsd value types are checked, and errors are given in the cases

  • CVTerm needs value but has none
  • CVTerm has value but must not have one
  • CVTerm has value, needs value but value is of wrong type
void setCheckUnits ( bool  check  ) 

Set if CV term units should be check (disabled by default).

If set to true additional checks for CVTerms are performed:

  • CVTerm that must have a unit, but has none
  • CVTerm that has a wrong unit
void setNameAttribute ( const String name  ) 

Sets the name of the attribute for accessions in the CV parameter tag name (default: 'name').

void setTag ( const String tag  ) 

Sets the CV parameter tag name (default: 'cvParam').

void setUnitAccessionAttribute ( const String accession  ) 

Sets the name of the unit accession attribute (default: 'unitAccession').

void setUnitNameAttribute ( const String name  ) 

Sets the name of the unit name attribute (default: 'unitName').

void setValueAttribute ( const String value  ) 

Sets the name of the attribute for accessions in the CV parameter tag name (default: 'value').

void startElement ( const XMLCh *  const,
const XMLCh *  const,
const XMLCh *const   qname,
const xercesc::Attributes &  attributes 
) [protected]

Reimplemented in MzMLValidator.

bool validate ( const String filename,
StringList errors,
StringList warnings 
)

Semantically validates an XML file.

Parameters:
filename The file to validate
errors Errors during the validation are returned in this output parameter.
warnings Warnings during the validation are returned in this output parameter.
Returns:
true if the validation was successfull, false otherwise.
Exceptions:
Exception::FileNotFound is thrown if the file could not be opened

Member Data Documentation

String accession_att_ [protected]
bool check_term_value_types_ [protected]
bool check_units_ [protected]
const ControlledVocabulary& cv_ [protected]

Reference to the CVs.

String cv_tag_ [protected]
StringList errors_ [protected]

Validation erros.

Map<String, Map<String, Map<String, UInt> > > fulfilled_ [protected]

Fulfilled rules (location => rule ID => term ID => term count ) When a tag is closed, the fulfilled rules of the current location are checked against the required rules The fulfilled rules for that location are then deleted.

const CVMappings& mapping_ [protected]

Reference to the mappings.

String name_att_ [protected]
StringList open_tags_ [protected]

List of open tags.

Map<String, std::vector<CVMappingRule> > rules_ [protected]

Rules (location => rule).

String unit_name_att_ [protected]
String value_att_ [protected]
StringList warnings_ [protected]

Validation warnings.


OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:43:00 using doxygen 1.7.1