xmlpp::DtdValidator Class Reference

XML DTD validator. More...

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

Inheritance diagram for xmlpp::DtdValidator:
[legend]

## Public Member Functions

| DtdValidator ()
| DtdValidator (const std::string & filename)
| Create a validator and parse an external subset (DTD file) immediately.
| DtdValidator (const ustring & external, const ustring & system)
| Create a validator and parse an external subset (DTD file) immediately.
| DtdValidator (Dtd * dtd, bool take_ownership)
| Create a validator.
| ~DtdValidator () override
const Dtd * | get_dtd () const noexcept
| Get the parsed DTD.
Dtd * | get_dtd () noexcept
| Get the parsed DTD.
| operator bool () const noexcept override
| Test whether a DTD has been parsed.
void | parse_file (const std::string & filename) override
| Parse an external subset (DTD file).
void | parse_memory (const ustring & contents) override
| Parse a DTD from a string.
void | parse_stream (std::istream & in)
| Parse a DTD from a stream.
void | parse_subset (const ustring & external, const ustring & system)
| Parse an external subset (DTD file).
void | set_dtd (Dtd * dtd, bool take_ownership)
| Set a DTD.
void | validate (const Document * document) override
| Validate a document, using a previously parsed DTD.
Public Member Functions inherited from xmlpp::Validator
| Validator () noexcept
| ~Validator () override
Public Member Functions inherited from xmlpp::NonCopyable
| NonCopyable (const NonCopyable &)=delete
| NonCopyable (NonCopyable &&)=delete
NonCopyable & | operator= (const NonCopyable &)=delete
NonCopyable & | operator= (NonCopyable &&)=delete

## Protected Member Functions

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

## Additional Inherited Members

Static Protected Member Functions inherited from xmlpp::Validator
static void | callback_error_or_warning (bool error, void * ctx, const char * msg, va_list var_args)
static void | callback_validity_error (void * ctx, const char * msg,...)
static void | callback_validity_warning (void * ctx, const char * msg,...)
static ValidatorCallbackCFuncType | get_callback_validity_error_cfunc ()
static ValidatorCallbackCFuncType | get_callback_validity_warning_cfunc ()
Protected Attributes inherited from xmlpp::Validator
std::unique_ptr< exception > | exception_
ustring | validate_error_
ustring | validate_warning_

## Detailed Description

XML DTD validator.

DTD = Document Type Definition

## Constructor & Destructor Documentation

## DtdValidator() [1/4]

xmlpp::DtdValidator::DtdValidator | ( |  | ) |

## DtdValidator() [2/4]

xmlpp::DtdValidator::DtdValidator | ( | const std::string & | filename | ) |

explicit

Create a validator and parse an external subset (DTD file) immediately.

Parameters

  filename | The URL of the DTD.

Exceptions

  xmlpp::parse_error |

## DtdValidator() [3/4]

xmlpp::DtdValidator::DtdValidator | ( | const ustring & | external,
|  | const ustring & | system )

explicit

Create a validator and parse an external subset (DTD file) immediately.

Parameters

  external | The external ID of the DTD.
  system | The URL of the DTD.

Exceptions

  xmlpp::parse_error |

## DtdValidator() [4/4]

xmlpp::DtdValidator::DtdValidator | ( | Dtd * | dtd,
|  | bool | take_ownership )

explicit

Create a validator.

Since libxml++ 3.0

Parameters

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

## ~DtdValidator()

xmlpp::DtdValidator::~DtdValidator | ( |  | ) |

override

## Member Function Documentation

## get_dtd() [1/2]

const Dtd * xmlpp::DtdValidator::get_dtd | ( |  | ) | const

noexcept

Get the parsed DTD.

Returns
  A pointer to the parsed DTD, or `nullptr`.

## get_dtd() [2/2]

Dtd * xmlpp::DtdValidator::get_dtd | ( |  | ) |

noexcept

Get the parsed DTD.

Returns
  A pointer to the parsed DTD, or `nullptr`.

## initialize_context()

void xmlpp::DtdValidator::initialize_context | ( |  | ) |

overrideprotectedvirtual

Reimplemented from xmlpp::Validator.

## operator bool()

xmlpp::DtdValidator::operator bool | ( |  | ) | const

explicitoverridevirtualnoexcept

Test whether a DTD has been parsed.

For instance

if (validator)
do_something();

Implements xmlpp::Validator.

## parse_file()

void xmlpp::DtdValidator::parse_file | ( | const std::string & | filename | ) |

overridevirtual

Parse an external subset (DTD file).

If the validator already contains a DTD, that DTD is deleted.

Parameters

  filename | The URL of the DTD.

Exceptions

  xmlpp::parse_error |

Implements xmlpp::Validator.

## parse_memory()

void xmlpp::DtdValidator::parse_memory | ( | const ustring & | contents | ) |

overridevirtual

Parse a DTD from a string.

If the validator already contains a DTD, that DTD is deleted.

Parameters

  contents | The DTD as a string.

Exceptions

  xmlpp::parse_error |

Implements xmlpp::Validator.

## parse_stream()

void xmlpp::DtdValidator::parse_stream | ( | std::istream & | in | ) |

Parse a DTD from a stream.

If the validator already contains a DTD, that DTD is deleted.

Parameters

  in | The stream.

Exceptions

  xmlpp::parse_error |

## parse_subset()

void xmlpp::DtdValidator::parse_subset | ( | const ustring & | external,
|  | const ustring & | system )

Parse an external subset (DTD file).

If the validator already contains a DTD, that DTD is deleted.

Parameters

  external | The external ID of the DTD.
  system | The URL of the DTD.

Exceptions

  xmlpp::parse_error |

## release_underlying()

void xmlpp::DtdValidator::release_underlying | ( |  | ) |

overrideprotectedvirtual

Reimplemented from xmlpp::Validator.

## set_dtd()

void xmlpp::DtdValidator::set_dtd | ( | Dtd * | dtd,
|  | bool | take_ownership )

Set a DTD.

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

Parameters

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

## validate()

void xmlpp::DtdValidator::validate | ( | const Document * | document | ) |

overridevirtual

Validate a document, using a previously parsed DTD.

The internal subset (if present) is de-coupled (i.e. not used), which could give problems if ID or IDREF is present.

Parameters

  document | Pointer to the document.

Exceptions

  xmlpp::internal_error |
  xmlpp::validity_error |

Implements xmlpp::Validator.