libxml++ 2.42.2
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:
Inheritance graph
[legend]

Public Member Functions

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

Protected Member Functions

LIBXMLPP_API void initialize_valid () override
 
LIBXMLPP_API void release_underlying () override
 
LIBXMLPP_API void initialize_valid () 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 handleException (const exception & e)
 
virtual LIBXMLPP_API void initialize_valid ()
 
virtual LIBXMLPP_API void on_validity_error (const Glib::ustring & message)
 
virtual LIBXMLPP_API void on_validity_warning (const Glib::ustring & message)
 
virtual LIBXMLPP_API void release_underlying ()
 

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().
 
- 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
exceptionexception_
 
_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

◆ XsdValidator() [1/4]

LIBXMLPP_API xmlpp::XsdValidator::XsdValidator ( )

◆ XsdValidator() [2/4]

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

Create a validator and parse a schema definition file.

Parameters
filenameThe URL of the schema.
Exceptions
xmlpp::parse_error

◆ XsdValidator() [3/4]

LIBXMLPP_API xmlpp::XsdValidator::XsdValidator ( const Document document)
explicit

Create a validator and parse a schema definition document.

Parameters
documentA preparsed document tree, containing the schema definition.
Exceptions
xmlpp::parse_error

◆ XsdValidator() [4/4]

LIBXMLPP_API xmlpp::XsdValidator::XsdValidator ( XsdSchema schema,
bool  take_ownership 
)
explicit

Create a validator.

Parameters
schemaA pointer to the schema to use when validating XML documents.
take_ownershipIf 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.

◆ ~XsdValidator()

LIBXMLPP_API xmlpp::XsdValidator::~XsdValidator ( )
override

Member Function Documentation

◆ get_schema() [1/2]

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

Get the schema.

Returns
A pointer to the schema, or nullptr.

◆ get_schema() [2/2]

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

Get the schema.

Returns
A pointer to the schema, or nullptr.

◆ initialize_valid()

LIBXMLPP_API void xmlpp::XsdValidator::initialize_valid ( )
overrideprotectedvirtual

Reimplemented from xmlpp::SchemaValidatorBase.

◆ operator BoolExpr()

LIBXMLPP_API xmlpp::XsdValidator::operator BoolExpr ( ) const
overridevirtual

Test whether a schema has been parsed.

For instance

if (xsd_validator)
do_something();

Implements xmlpp::SchemaValidatorBase.

◆ parse_document()

LIBXMLPP_API void xmlpp::XsdValidator::parse_document ( const Document document)
overridevirtual

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
documentA preparsed document tree, containing the schema definition.
Exceptions
xmlpp::parse_error

Implements xmlpp::SchemaValidatorBase.

◆ parse_file()

LIBXMLPP_API void xmlpp::XsdValidator::parse_file ( const Glib::ustring &  filename)
overridevirtual

Parse a schema definition file.

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

Parameters
filenameThe URL of the schema.
Exceptions
xmlpp::parse_error

Implements xmlpp::SchemaValidatorBase.

◆ parse_memory()

LIBXMLPP_API void xmlpp::XsdValidator::parse_memory ( const Glib::ustring &  contents)
overridevirtual

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
contentsThe schema definition as a string.
Exceptions
xmlpp::parse_error

Implements xmlpp::SchemaValidatorBase.

◆ release_underlying()

LIBXMLPP_API void xmlpp::XsdValidator::release_underlying ( )
overrideprotectedvirtual

Reimplemented from xmlpp::SchemaValidatorBase.

◆ set_schema()

LIBXMLPP_API 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
schemaA pointer to the schema to use when validating XML documents.
take_ownershipIf 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.

◆ validate() [1/2]

LIBXMLPP_API void xmlpp::XsdValidator::validate ( const Document document)
overridevirtual

Validate a document, using a previously parsed schema.

Parameters
documentPointer to the document.
Exceptions
xmlpp::internal_error
xmlpp::validity_error

Implements xmlpp::SchemaValidatorBase.

◆ validate() [2/2]

LIBXMLPP_API void xmlpp::XsdValidator::validate ( const Glib::ustring &  filename)
overridevirtual

Validate an XML file, using a previously parsed schema.

Parameters
filenameThe URL of the XML file.
Exceptions
xmlpp::internal_error
xmlpp::validity_error

Implements xmlpp::SchemaValidatorBase.