libxml++  3.2.3
Public Member Functions | Protected Member Functions | List of all members
xmlpp::DtdValidator Class Reference

XML DTD validator. More...

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

Inheritance diagram for xmlpp::DtdValidator:
Inheritance graph
[legend]

Public Member Functions

LIBXMLPP_API DtdValidator ()
 
LIBXMLPP_API DtdValidator (const Glib::ustring& external, const Glib::ustring& system)
 Create a validator and parse an external subset (DTD file) immediately. More...
 
LIBXMLPP_API DtdValidator (const std::string& filename)
 Create a validator and parse an external subset (DTD file) immediately. More...
 
LIBXMLPP_API DtdValidator (Dtd* dtd, bool take_ownership)
 Create a validator. More...
 
LIBXMLPP_API ~DtdValidator () override
 
LIBXMLPP_API const Dtdget_dtd () const noexcept
 Get the parsed DTD. More...
 
LIBXMLPP_API Dtdget_dtd () noexcept
 Get the parsed DTD. More...
 
LIBXMLPP_API operator bool () const noexcept override
 Test whether a DTD has been parsed. More...
 
LIBXMLPP_API void parse_file (const std::string& filename) override
 Parse an external subset (DTD file). More...
 
LIBXMLPP_API void parse_memory (const Glib::ustring& contents) override
 Parse a DTD from a string. More...
 
LIBXMLPP_API void parse_stream (std::istream& in)
 Parse a DTD from a stream. More...
 
LIBXMLPP_API void parse_subset (const Glib::ustring& external, const Glib::ustring& system)
 Parse an external subset (DTD file). More...
 
LIBXMLPP_API void set_dtd (Dtd* dtd, bool take_ownership)
 Set a DTD. More...
 
LIBXMLPP_API void validate (const Document* document) override
 Validate a document, using a previously parsed DTD. More...
 
- 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::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 Glib::ustring& message)
 
virtual LIBXMLPP_API void on_validity_warning (const Glib::ustring& message)
 
- Protected Member Functions inherited from xmlpp::NonCopyable
 NonCopyable () noexcept
 
 NonCopyable (const NonCopyable&)=delete
 
 NonCopyable (NonCopyable&&)=delete
 
virtual ~NonCopyable ()
 
NonCopyableoperator= (const NonCopyable&)=delete
 
NonCopyableoperator= (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< exceptionexception_
 
Glib::ustring validate_error_
 
Glib::ustring validate_warning_
 

Detailed Description

XML DTD validator.

DTD = Document Type Definition

Constructor & Destructor Documentation

◆ DtdValidator() [1/4]

LIBXMLPP_API xmlpp::DtdValidator::DtdValidator ( )

◆ DtdValidator() [2/4]

LIBXMLPP_API xmlpp::DtdValidator::DtdValidator ( const std::string &  filename)
explicit

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

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

◆ DtdValidator() [3/4]

LIBXMLPP_API xmlpp::DtdValidator::DtdValidator ( const Glib::ustring &  external,
const Glib::ustring &  system 
)
explicit

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

Parameters
externalThe external ID of the DTD.
systemThe URL of the DTD.
Exceptions
xmlpp::parse_error

◆ DtdValidator() [4/4]

LIBXMLPP_API xmlpp::DtdValidator::DtdValidator ( Dtd dtd,
bool  take_ownership 
)
explicit

Create a validator.

Since libxml++ 3.0:
Parameters
dtdA pointer to the DTD to use when validating XML documents.
take_ownershipIf 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()

LIBXMLPP_API xmlpp::DtdValidator::~DtdValidator ( )
override

Member Function Documentation

◆ get_dtd() [1/2]

LIBXMLPP_API 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]

LIBXMLPP_API Dtd* xmlpp::DtdValidator::get_dtd ( )
noexcept

Get the parsed DTD.

Returns
A pointer to the parsed DTD, or nullptr.

◆ initialize_context()

LIBXMLPP_API void xmlpp::DtdValidator::initialize_context ( )
overrideprotectedvirtual

Reimplemented from xmlpp::Validator.

◆ operator bool()

LIBXMLPP_API xmlpp::DtdValidator::operator bool ( ) const
explicitoverridevirtualnoexcept

Test whether a DTD has been parsed.

For instance

if (validator)
do_something();

Implements xmlpp::Validator.

◆ parse_file()

LIBXMLPP_API 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
filenameThe URL of the DTD.
Exceptions
xmlpp::parse_error

Implements xmlpp::Validator.

◆ parse_memory()

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

Parse a DTD from a string.

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

Parameters
contentsThe DTD as a string.
Exceptions
xmlpp::parse_error

Implements xmlpp::Validator.

◆ parse_stream()

LIBXMLPP_API 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
inThe stream.
Exceptions
xmlpp::parse_error

◆ parse_subset()

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

Parse an external subset (DTD file).

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

Parameters
externalThe external ID of the DTD.
systemThe URL of the DTD.
Exceptions
xmlpp::parse_error

◆ release_underlying()

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

Reimplemented from xmlpp::Validator.

◆ set_dtd()

LIBXMLPP_API 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
dtdA pointer to the DTD to use when validating XML documents.
take_ownershipIf 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()

LIBXMLPP_API 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
documentPointer to the document.
Exceptions
xmlpp::internal_error
xmlpp::validity_error

Implements xmlpp::Validator.