SaxonC 12.5
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
SchemaValidator.h
1
2// Copyright (c) 2022 - 2023 Saxonica Limited.
3// This Source Code Form is subject to the terms of the Mozilla Public License,
4// v. 2.0. If a copy of the MPL was not distributed with this file, You can
5// obtain one at http://mozilla.org/MPL/2.0/. This Source Code Form is
6// "Incompatible With Secondary Licenses", as defined by the Mozilla Public
7// License, v. 2.0.
9
10#ifndef SAXON_SCHEMA_H
11#define SAXON_SCHEMA_H
12
13#include "SaxonProcessor.h"
14
15#include <string>
16
17class SaxonProcessor;
18class XdmValue;
19class XdmNode;
20class XdmItem;
21
26public:
28
33
35
42 SchemaValidator(SaxonProcessor *proc, std::string cwd = "");
43
45
48 SchemaValidator(const SchemaValidator &other);
49
53
55
60
62
67 void setcwd(const char *cwd);
68
70
79 void registerSchemaFromFile(const char *xsd);
80
82
87 void registerSchemaFromString(const char *schemaStr,
88 const char *systemID = nullptr);
89
91
96
100
105 void exportSchema(const char *fileName);
106
108
111 void setOutputFile(const char *outputFile);
112
114
120 void validate(const char *sourceFile = nullptr);
121
123
128 XdmNode *validateToNode(const char *sourceFile = nullptr);
129
131
137 void setSourceNode(XdmNode *source);
138
140
148
150
158 void setParameter(const char *name, XdmValue *value);
159
161
167 bool removeParameter(const char *name);
168
170
176 void setProperty(const char *name, const char *value);
178
185 void clearParameters(bool deleteValues = false);
186
188 void clearProperties();
189
196 XdmValue *getParameter(const char *name, bool withParam);
197
198
200 std::map<std::string, XdmValue *> &getParameters();
201
203 std::map<std::string, std::string> &getProperties();
204
207
212 bool exceptionOccurred();
213
215
219 const char *checkException();
220
222 void exceptionClear();
223
225
228 // int exceptionCount();
229
231
235 const char *getErrorMessage();
236
238
242 const char *getErrorCode();
243
245
253 void setLax(bool l);
254
256 int64_t getUnderlyingValidator() { return cppV; }
257
258private:
259 bool lax;
261 *proc;
262 // jclass cppClass; /*!< JNI object where the SchemaValidator method will be
263 // invoked */
264 int64_t cppV;
265 std::string cwdV;
266 std::string
267 outputFile;
268 std::map<std::string, XdmValue *>
269 parameters;
271 std::map<std::string, std::string>
272 properties;
274 SaxonApiException *exception;
276};
277
278#endif /* SAXON_SCHEMA_H */
Definition SaxonApiException.h:23
Definition SaxonProcessor.h:117
Definition SchemaValidator.h:25
void registerSchemaFromString(const char *schemaStr, const char *systemID=nullptr)
Register the schema supplied as a string.
Definition SchemaValidator.cpp:171
void clearProperties()
Clear property values set.
Definition SchemaValidator.cpp:347
void registerSchemaFromFile(const char *xsd)
Register the schema from file name.
Definition SchemaValidator.cpp:131
void setcwd(const char *cwd)
Set the Current working Directory.
Definition SchemaValidator.cpp:78
void setOutputFile(const char *outputFile)
Set the name of the output file that will be used by the validator.
Definition SchemaValidator.cpp:84
int64_t getUnderlyingValidator()
Get the underlying java object of the C++ schema validator.
Definition SchemaValidator.h:256
SchemaValidator & operator=(const SchemaValidator &other)
The copy assignment= operator.
SchemaValidator()
Default constructor.
Definition SchemaValidator.cpp:12
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition SchemaValidator.cpp:329
void registerSchemaFromNode(XdmNode *node)
Register the schema supplied as an XDM Node Object.
Definition SchemaValidator.cpp:105
void exportSchema(const char *fileName)
Definition SchemaValidator.cpp:156
XdmNode * getValidationReport()
Get the Validation report.
Definition SchemaValidator.cpp:92
void validate(const char *sourceFile=nullptr)
Validate an instance document by a registered schema.
Definition SchemaValidator.cpp:194
~SchemaValidator()
Definition SchemaValidator.cpp:65
const char * getErrorMessage()
Get number of errors during validation of the source against the schema.
Definition SchemaValidator.cpp:261
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition SchemaValidator.cpp:349
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition SchemaValidator.cpp:354
void exceptionClear()
Clear any exception thrown.
Definition SchemaValidator.cpp:247
XdmNode * validateToNode(const char *sourceFile=nullptr)
Validate an instance document supplied as a Source object.
Definition SchemaValidator.cpp:218
void setLax(bool l)
The validation mode may be either strict or lax.
Definition SchemaValidator.cpp:90
void setParameter(const char *name, XdmValue *value)
Set a parameter value used in the validator.
Definition SchemaValidator.cpp:300
void setSourceNode(XdmNode *source)
Set the source node for validation.
Definition SchemaValidator.cpp:281
bool exceptionOccurred()
Definition SchemaValidator.cpp:268
XdmValue * getParameter(const char *name, bool withParam)
Definition SchemaValidator.cpp:291
void setProperty(const char *name, const char *value)
Set a property.
Definition SchemaValidator.cpp:319
const char * getErrorCode()
Get error code if an error is reported.
Definition SchemaValidator.cpp:254
const char * checkException()
Check for exception thrown.
Definition SchemaValidator.cpp:272
bool removeParameter(const char *name)
Remove a parameter (name, value) pair.
Definition SchemaValidator.cpp:315
Definition XdmItem.h:30
Definition XdmNode.h:56
Definition XdmValue.h:42