xmlwrapp
Lightweight C++ XML parsing library
Loading...
Searching...
No Matches
relaxng.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Vadim Zeitlin <vz-xmlwrapp@zeitlins.org>
3 * All Rights Reserved
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * 3. Neither the name of the Author nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
23 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33/**
34 @file
35
36 This file contains the definition of the xml::relaxng class.
37 */
38
39#ifndef _xmlwrapp_relaxng_h_
40#define _xmlwrapp_relaxng_h_
41
42// xmlwrapp includes
43#include "xmlwrapp/init.h"
44#include "xmlwrapp/export.h"
45#include "xmlwrapp/errors.h"
46
47#include <memory>
48
49XMLWRAPP_MSVC_SUPPRESS_DLL_MEMBER_WARN
50
51namespace xml
52{
53
54// forward declarations
55class document;
56class error_messages;
57
58namespace impl
59{
60struct relaxng_impl;
61}
62
63/**
64 XML validator using RelaxNG.
65
66 This class is used to validate documents against RelaxNG schemas expressed
67 in XML syntax (compact RelaxNG syntax is not supported).
68
69 @since 0.9.0
70 */
71class XMLWRAPP_API relaxng
72{
73public:
74 /**
75 Parses XML RelaxNG document and creates relaxng instance from it.
76
77 Errors are handled by @a on_error handler; by default, xml::exception
78 is thrown on errors. If there's a fatal error that prevents the relaxng
79 from being loaded and the error handler doesn't throw an exception, the
80 constructor will throw xml::exception anyway.
81 */
82 explicit relaxng(const document& doc, error_handler& on_error = throw_on_error);
83
84 /// Destructor
86
87 /**
88 Validates the document @a doc against the relaxng.
89
90 Errors are handled by @a on_error handler; by default, xml::exception
91 is thrown on errors.
92
93 @return `true` if the document is valid with regard to the relaxng,
94 `false` otherwise.
95 */
96 bool validate(const document& doc, error_handler& on_error = throw_on_error) const;
97
98private:
99 std::unique_ptr<impl::relaxng_impl> pimpl_;
100
101 // This class is not copyable
102 relaxng(const relaxng&) = delete;
103 relaxng& operator=(const relaxng&) = delete;
104};
105
106} // namespace xml
107
108XMLWRAPP_MSVC_RESTORE_DLL_MEMBER_WARN
109
110#endif // _xmlwrapp_relaxng_h_
The xml::document class is used to hold the XML tree and various bits of information about it.
Definition document.h:88
The xml::error_handler class is used to handle libxml2 errors and warnings emitted during parsing,...
Definition errors.h:89
XML validator using RelaxNG.
Definition relaxng.h:72
~relaxng()
Destructor.
bool validate(const document &doc, error_handler &on_error=throw_on_error) const
Validates the document doc against the relaxng.
relaxng(const document &doc, error_handler &on_error=throw_on_error)
Parses XML RelaxNG document and creates relaxng instance from it.
This file contains errors-handling classes: xml::exception and xml::error_handler and derived classes...
XML library namespace.
Definition attributes.h:55
This file contains the definition of the xml::init class.