libxml++: xmlpp::XsdValidator Class Reference

libxml++ 2.40.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::XsdValidator Class Reference

XSD schema validator. More...

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

Inheritance diagram for xmlpp::XsdValidator:
[legend]

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

## Protected Member Functions
void | initialize_valid () 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 | handleException (const exception& e)
virtual void | on_validity_error (const Glib::ustring& message)
virtual void | on_validity_warning (const Glib::ustring& message)

## Additional Inherited Members
Public Types inherited from xmlpp::SchemaValidatorBase
typedef const void* | BoolExpr
| This typedef is just to make it more obvious that our operator const void* should be used like operator bool(). More...
Static Protected Member Functions inherited from xmlpp::Validator
static void | callback_validity_error (void* ctx, const char* msg,...)
static void | callback_validity_warning (void* ctx, const char* msg,...)
Protected Attributes inherited from xmlpp::Validator
exception* | exception_
_xmlValidCtxt* | valid_
Glib::ustring | validate_error_
Glib::ustring | validate_warning_

## Detailed Description

XSD schema validator.

XSD = XML Schema Definition, a.k.a. XML Schema or W3C XML Schema

Since libxml++ 2.38:

## Constructor & Destructor Documentation

xmlpp::XsdValidator::XsdValidator | ( |  | ) |

xmlpp::XsdValidator::XsdValidator | ( | const Glib::ustring & | filename | ) |
| explicit

Create a validator and parse a schema definition file.

Parameters

  filename | The URL of the schema.

Exceptions

  xmlpp::parse_error |

xmlpp::XsdValidator::XsdValidator | ( | 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 |

xmlpp::XsdValidator::XsdValidator | ( | XsdSchema* | 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.

xmlpp::XsdValidator::~XsdValidator | ( |  | ) |
| override

## Member Function Documentation

XsdSchema* xmlpp::XsdValidator::get_schema | ( |  | ) |

Get the schema.

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

const XsdSchema* xmlpp::XsdValidator::get_schema | ( |  | ) | const

Get the schema.

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

void xmlpp::XsdValidator::initialize_valid | ( |  | ) |
| override protected virtual

Reimplemented from xmlpp::SchemaValidatorBase.

virtual xmlpp::XsdValidator::operator BoolExpr | ( |  | ) | const
| virtual

Test whether a schema has been parsed.

For instance

if (xsd_validator)
do_something();

Implements xmlpp::SchemaValidatorBase.

virtual void xmlpp::XsdValidator::parse_document | ( | const Document* | document | ) |
| 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.

virtual void xmlpp::XsdValidator::parse_file | ( | const Glib::ustring & | filename | ) |
| virtual

Parse a schema definition file.

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.

virtual void xmlpp::XsdValidator::parse_memory | ( | const Glib::ustring & | contents | ) |
| virtual

Parse a schema definition from a string.

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.

void xmlpp::XsdValidator::release_underlying | ( |  | ) |
| override protected virtual

Reimplemented from xmlpp::SchemaValidatorBase.

void xmlpp::XsdValidator::set_schema | ( | XsdSchema* | 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.

virtual void xmlpp::XsdValidator::validate | ( | const Document* | document | ) |
| 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.

virtual void xmlpp::XsdValidator::validate | ( | const Glib::ustring & | filename | ) |
| virtual

Validate an XML file, using a previously parsed schema.

Parameters

  filename | The URL of the XML file.

Exceptions

  xmlpp::internal_error |
  xmlpp::validity_error |

Implements xmlpp::SchemaValidatorBase.