libxml++ 5.0.1

- Main Page
- Related Pages
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
xmlpp::RelaxNGValidator Class Reference

RelaxNG schema validator. More...

`#include <libxml++/validators/relaxngvalidator.h>`

Inheritance diagram for xmlpp::RelaxNGValidator:
[legend]

## Public Member Functions
LIBXMLPP_API | RelaxNGValidator ()
LIBXMLPP_API | RelaxNGValidator (const std::string& filename)
| Create a validator and parse a schema definition file. More...
LIBXMLPP_API | RelaxNGValidator (const Document* document)
| Create a validator and parse a schema definition document. More...
LIBXMLPP_API | RelaxNGValidator (RelaxNGSchema* schema, bool take_ownership)
| Create a validator. More...
LIBXMLPP_API | ~RelaxNGValidator () override
LIBXMLPP_API RelaxNGSchema* | get_schema () noexcept
| Get the schema. More...
LIBXMLPP_API const RelaxNGSchema* | get_schema () const noexcept
| Get the schema. More...
LIBXMLPP_API | operator bool () const noexcept override
| Test whether a schema has been parsed. More...
LIBXMLPP_API void | parse_document (const Document* document) override
| Parse a schema definition from a document. More...
LIBXMLPP_API void | parse_file (const std::string& filename) override
| Parse a schema definition file. More...
LIBXMLPP_API void | parse_memory (const ustring& contents) override
| Parse a schema definition from a string. More...
LIBXMLPP_API void | set_schema (RelaxNGSchema* schema, bool take_ownership)
| Set a schema. More...
LIBXMLPP_API void | validate (const Document* document) override
| Validate a document, using a previously parsed schema. More...
LIBXMLPP_API void | validate (const std::string& filename) override
| Validate an XML file, using a previously parsed schema. More...
Public Member Functions inherited from xmlpp::SchemaValidatorBase
LIBXMLPP_API | SchemaValidatorBase () noexcept
LIBXMLPP_API | ~SchemaValidatorBase () override
Public Member Functions inherited from xmlpp::Validator
LIBXMLPP_API | Validator () noexcept
LIBXMLPP_API | ~Validator () override

## Protected Member Functions
LIBXMLPP_API void | initialize_context () override
LIBXMLPP_API void | release_underlying () override
Protected Member Functions inherited from xmlpp::SchemaValidatorBase
LIBXMLPP_API void | initialize_context () override
LIBXMLPP_API void | release_underlying () override
Protected Member Functions inherited from xmlpp::Validator
virtual LIBXMLPP_API void | check_for_exception ()
virtual LIBXMLPP_API void | check_for_validity_messages ()
virtual LIBXMLPP_API void | handle_exception ()
| To be called in an exception handler. More...
virtual LIBXMLPP_API void | on_validity_error (const ustring& message)
virtual LIBXMLPP_API void | on_validity_warning (const ustring& message)
Protected Member Functions inherited from xmlpp::NonCopyable
| NonCopyable () noexcept
| NonCopyable (const NonCopyable&)=delete
| NonCopyable (NonCopyable&&)=delete
virtual | ~NonCopyable ()
NonCopyable& | operator= (const NonCopyable&)=delete
NonCopyable& | operator= (NonCopyable&&)=delete

## Additional Inherited Members
Static Protected Member Functions inherited from xmlpp::Validator
static LIBXMLPP_API void | callback_validity_error (void* ctx, const char* msg,...)
static LIBXMLPP_API void | callback_validity_warning (void* ctx, const char* msg,...)
Protected Attributes inherited from xmlpp::Validator
std::unique_ptr< exception > | exception_
ustring | validate_error_
ustring | validate_warning_

## Detailed Description

RelaxNG schema validator.

RelaxNG = REgular LAnguage for XML Next Generation

Since libxml++ 2.38:

## Constructor & Destructor Documentation

LIBXMLPP_API xmlpp::RelaxNGValidator::RelaxNGValidator | ( |  | ) |

LIBXMLPP_API xmlpp::RelaxNGValidator::RelaxNGValidator | ( | const std::string & | filename | ) |
| explicit

Create a validator and parse a schema definition file.

The schema must be defined with XML syntax (.rng file). The compact syntax (.rnc file) is not supported.

Parameters

  filename | The URL of the schema.

Exceptions

  xmlpp::parse_error |

LIBXMLPP_API xmlpp::RelaxNGValidator::RelaxNGValidator | ( | const Document* | document | ) |
| explicit

Create a validator and parse a schema definition document.

Parameters

  document | A preparsed document tree, containing the schema definition.

Exceptions

  xmlpp::parse_error |

LIBXMLPP_API xmlpp::RelaxNGValidator::RelaxNGValidator | ( | RelaxNGSchema* | schema,
|  | bool | take_ownership
| ) |  |
| explicit

Create a validator.

Parameters

  schema | A pointer to the schema to use when validating XML documents.
  take_ownership | If `true`, the validator takes ownership of the schema. The caller must not delete it. If `false`, the validator does not take ownership of the schema. The caller must guarantee that the schema exists as long as the validator keeps a pointer to it. The caller is responsible for deleting the schema when it's no longer needed.

LIBXMLPP_API xmlpp::RelaxNGValidator::~RelaxNGValidator | ( |  | ) |
| override

## Member Function Documentation

LIBXMLPP_API RelaxNGSchema* xmlpp::RelaxNGValidator::get_schema | ( |  | ) |
| noexcept

Get the schema.

Returns
  A pointer to the schema, or `nullptr`.

LIBXMLPP_API const RelaxNGSchema* xmlpp::RelaxNGValidator::get_schema | ( |  | ) | const
| noexcept

Get the schema.

Returns
  A pointer to the schema, or `nullptr`.

LIBXMLPP_API void xmlpp::RelaxNGValidator::initialize_context | ( |  | ) |
| override protected virtual

Reimplemented from xmlpp::Validator.

LIBXMLPP_API xmlpp::RelaxNGValidator::operator bool | ( |  | ) | const
| explicit override virtual noexcept

Test whether a schema has been parsed.

For instance

if (relaxng_validator)
do_something();

Implements xmlpp::SchemaValidatorBase.

LIBXMLPP_API void xmlpp::RelaxNGValidator::parse_document | ( | const Document* | document | ) |
| override virtual

Parse a schema definition from a document.

If the validator already contains a schema, that schema is released (deleted if the validator owns the schema).

Parameters

  document | A preparsed document tree, containing the schema definition.

Exceptions

  xmlpp::parse_error |

Implements xmlpp::SchemaValidatorBase.

LIBXMLPP_API void xmlpp::RelaxNGValidator::parse_file | ( | const std::string & | filename | ) |
| override virtual

Parse a schema definition file.

The schema must be defined with XML syntax (.rng file). The compact syntax (.rnc file) is not supported.

If the validator already contains a schema, that schema is released (deleted if the validator owns the schema).

Parameters

  filename | The URL of the schema.

Exceptions

  xmlpp::parse_error |

Implements xmlpp::SchemaValidatorBase.

LIBXMLPP_API void xmlpp::RelaxNGValidator::parse_memory | ( | const ustring& | contents | ) |
| override virtual

Parse a schema definition from a string.

The schema must be defined with XML syntax. The compact syntax is not supported.

If the validator already contains a schema, that schema is released (deleted if the validator owns the schema).

Parameters

  contents | The schema definition as a string.

Exceptions

  xmlpp::parse_error |

Implements xmlpp::SchemaValidatorBase.

LIBXMLPP_API void xmlpp::RelaxNGValidator::release_underlying | ( |  | ) |
| override protected virtual

Reimplemented from xmlpp::Validator.

LIBXMLPP_API void xmlpp::RelaxNGValidator::set_schema | ( | RelaxNGSchema* | schema,
|  | bool | take_ownership
| ) |  |

Set a schema.

If the validator already contains a schema, that schema is released (deleted if the validator owns the schema).

Parameters

  schema | A pointer to the schema to use when validating XML documents.
  take_ownership | If `true`, the validator takes ownership of the schema. The caller must not delete it. If `false`, the validator does not take ownership of the schema. The caller must guarantee that the schema exists as long as the validator keeps a pointer to it. The caller is responsible for deleting the schema when it's no longer needed.

LIBXMLPP_API void xmlpp::RelaxNGValidator::validate | ( | const Document* | document | ) |
| override virtual

Validate a document, using a previously parsed schema.

Parameters

  document | Pointer to the document.

Exceptions

  xmlpp::internal_error |
  xmlpp::validity_error |

Implements xmlpp::SchemaValidatorBase.

LIBXMLPP_API void xmlpp::RelaxNGValidator::validate | ( | const std::string & | filename | ) |
| override virtual

Validate an XML file, using a previously parsed schema.

Parameters

  filename | The URL of the XML file.

Exceptions

  xmlpp::internal_error |
  xmlpp::parse_error |
  xmlpp::validity_error |

Implements xmlpp::SchemaValidatorBase.