Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Hydra Core Library Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::XmlValidator

Group:  XML Related

Local Index

Members

Header File

#include <rwsf/core/XmlValidator.h>

Description

rwsf::XmlValidator methods are used in classes generated by Hydra to check values in instance documents, working through the isValid() method of each generated class. This method in generated classes validates simple type data in an instance document based on facets defined in the XML schema for that document type. In an XML schema, simple types can have associated facets that restrict the allowable data values for an element or attribute of the specified type.

When isValid() is called on one of the generated datatype classes, it checks all of the simple type data in the instance document that is modeled by the class. If any of the data is found to be invalid, the method returns a bool value of false. Only if all of the data is found to be valid does the method return true.

The methods of rwsf::XmlValidator can be used directly by constructing an instance of rwsf::XmlValidator for some class that is a C++ data binding for an XML element and then calling methods to validate the data in an element of that type. In this case, you must know the facets defined for simple types in the element and call rwsf::XmlValidator methods to check the data for these simple types. For example, if an element contained simple type data with a maxLength facet, you would call checkMaxLength() on that data.

The facet checking methods set a state variable at the end of each check. If the data was found to be invalid, the state variable is set to false and remains that way even if additional calls are made to the method where the data is found to be valid. (The exception to this rule are the methods for checking enumerations and patterns, as described below for checkEnumerations() and checkPatterns().) Thus the state variable indicates whether any of the checks for a particular facet found invalid data. At any point, you can call the rwsf::XmlValidator isValid() method, which checks all of the state variables to determine whether any have been set to false. If any have been, it returns false. If all of the state variables are set to true, it returns true.

The direct use of rwsf::XmlValidator described above is, in fact, what the implementation of the isValid() method in the generated code does.

rwsf::XmlValidator initializes an std::list for rwsf::XmlSchemaException objects. A rwsf::XmlSchemaException object is added to this list whenever one of the facet checking methods reports invalid data. If a call to isValid() returns false, you can obtain the error list through the validator's getErrors() method and iterate through the list to obtain information on the errors discovered. rwsf::XmlSchemaException inherits from rwsf::Exception, so you can use the why() method to obtain the string that describes the error.

Related Classes

rwsf::XmlSchemaException

Public Constructors

XmlValidator(const std::string& name);

Public Enumeration

enum WhiteSpace {PRESERVE, REPLACE, COLLAPSE};

Public Member Functions

void
addError(rwsf::XmlSchemaException error);
bool
checkEnumeration(const std::string& value, 
const std::string& facetValue, WhiteSpace ws = PRESERVE);
bool
checkEnumerations();
bool 
checkEnumerations(std::string enumeration,
          rwsf::HashSet<std::string> enumerations,
          WhiteSpace ws = PRESERVE);
template <class T>
bool 
checkFixed(const T& fixedValue, const T& candidate)
template <class T>
bool
checkFractionDigits(const T& value, const std::string& 
    facetValue, WhiteSpace=PRESERVE);
template <class T>
bool
checkLength(size_t length, const std::string& facetValue);
template <class T>
bool
checkLength(const std::string& value, 
    const std::string& facetValue, WhiteSpace ws=PRESERVE)
template <class T>
bool
checkMaxExclusive(T value, T facetValue,WhiteSpace=PRESERVE);
template <class T>
bool
checkMaxExclusive(ConverterBase<T> converter, T value, 
    T facetValue, WhiteSpace)
template <class T>
bool
checkMaxInclusive(ConverterBase<T> converter, T value, 
    T facetValue, WhiteSpace)
template <class T>
bool
checkMaxInclusive(T value, T facetValue, 
    WhiteSpace = PRESERVE);
bool
checkMaxLength(const std::string& value, 
    const std::string& facetValue, WhiteSpace ws = PRESERVE)
bool
checkMaxLength(size_t length, const std::string&
                facetValue);
template <class T>
bool
checkMinExclusive(ConverterBase<T> converter, 
    T value, T facetValue, WhiteSpace)
template <class T>
bool
checkMinExclusive(T value, T facetValue,WhiteSpace=PRESERVE);
template <class T>
bool
checkMinInclusive(ConverterBase<T> converter, T value, 
    T facetValue, WhiteSpace)
template <class T>
bool
checkMinInclusive(T value, T facetValue,WhiteSpace=PRESERVE);
bool
checkMinLength(const std::string& value, 
    const std::string& facetValue, WhiteSpace ws=PRESERVE);
bool
checkMinLength(size_t length,const std::string& facetValue);
bool
checkPattern(const std::string& value,
    const std::string& facetValue, WhiteSpace ws=PRESERVE);
bool
checkPatterns();
bool 
checkPatterns(std::string pattern,
              std::vector<std::string> patterns,
              WhiteSpace ws = PRESERVE);
template <class T>
bool
checkTotalDigits(const T& value,
    const std::string& facetValue, WhiteSpace=PRESERVE);
bool
checkVectorBounds(int size, int minOccurs, int maxOccurs);
void
clear();
void
clearErrors();
std::list<rwsf::XmlSchemaException>
getErrors();
bool
isValid() const;
bool
isValid(XmlValidator& validator);


Previous fileTop of DocumentContentsIndex pageNext file

©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks and HydraSDO is a trademark of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.