SaxonC 12.8.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
SchemaValidator.h
1
2// Copyright (c) 2022 - 2025 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 "saxonc_export.h"
14#include "saxonc/SaxonProcessor.h"
15
16#include <string>
17
18class SaxonProcessor;
19class XdmValue;
20class XdmNode;
21class XdmItem;
22
26class SAXONC_EXPORT SchemaValidator {
27public:
34
43 SchemaValidator(SaxonProcessor *proc, std::string cwd = "");
44
49 SchemaValidator(const SchemaValidator &other);
50
55
62
68 void setcwd(const char *cwd);
69
75 const char * getcwd();
76
88 void registerSchemaFromFile(const char *xsd);
89
96 void registerSchemaFromString(const char *schemaStr,
97 const char *systemID = nullptr);
98
105
113 void exportSchema(const char *fileName);
114
119 void setOutputFile(const char *outputFile);
120
125 const char *getOutputFile();
126
133 void validate(const char *sourceFile = nullptr);
134
142 XdmNode *validateToNode(const char *sourceFile = nullptr);
143
150 void setSourceNode(XdmNode *source);
151
161
169 void setParameter(const char *name, XdmValue *value, bool withParam=true);
170
176 bool removeParameter(const char *name);
177
184 void setProperty(const char *name, const char *value);
185
194 void clearParameters(bool deleteValues = false);
195
199 void clearProperties();
200
207 XdmValue *getParameter(const char *name, bool withParam=true);
208
212 std::map<std::string, XdmValue *> &getParameters();
213
217 std::map<std::string, std::string> &getProperties();
218
223 bool exceptionOccurred();
224
231 const char *checkException();
232
237 void exceptionClear();
238
239
246 const char *getErrorMessage();
247
254 const char *getErrorCode();
255
265 void setLax(bool l);
266
270 int64_t getUnderlyingValidator() { return cppV; }
271
276
277private:
278 bool lax;
280 *proc;
281 // jclass cppClass; /*!< JNI object where the SchemaValidator method will be
282 // invoked */
283 int64_t cppV;
284 std::string cwdV;
285 std::string
286 outputFile;
287 std::map<std::string, XdmValue *>
288 parameters;
290 std::map<std::string, std::string>
291 properties;
293 SaxonApiException *exception;
295};
296
297#endif /* SAXON_SCHEMA_H */
SAXONC_EXPORT void setParameter(sxnc_parameter **parameters, int *parLen, int *parCap, const char *name, sxnc_value *value)
Set a parameter.
Definition SaxonCGlue.c:160
SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name)
Get a parameter from the list.
Definition SaxonCGlue.c:136
SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap, const char *name, const char *value)
Set a property.
Definition SaxonCGlue.c:186
SaxonApiException.
Definition SaxonApiException.h:24
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition SaxonProcessor.h:117
void registerSchemaFromString(const char *schemaStr, const char *systemID=nullptr)
Register the schema supplied as a string.
Definition SchemaValidator.cpp:189
void clearProperties()
Clear configuration property values set.
Definition SchemaValidator.cpp:371
void registerSchemaFromFile(const char *xsd)
Register the schema from file name.
Definition SchemaValidator.cpp:146
const char * getcwd()
Get the current working directory set on this validator.
Definition SchemaValidator.cpp:88
void setcwd(const char *cwd)
Set the current working directory for the validator.
Definition SchemaValidator.cpp:82
void setOutputFile(const char *outputFile)
Set the name of the output file that will be used by the validator.
Definition SchemaValidator.cpp:92
SaxonProcessor * getSaxonProcessor()
Get the SaxonProcessor which created this SchemaValidator.
Definition SchemaValidator.h:275
int64_t getUnderlyingValidator()
Get the underlying Java object of the C++ schema validator.
Definition SchemaValidator.h:270
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:353
void registerSchemaFromNode(XdmNode *node)
Register the schema supplied as an XDM Node Object.
Definition SchemaValidator.cpp:117
void exportSchema(const char *fileName)
Export a precompiled Schema Component Model.
Definition SchemaValidator.cpp:174
XdmNode * getValidationReport()
Get the validation report.
Definition SchemaValidator.cpp:104
void validate(const char *sourceFile=nullptr)
Validate an instance document by a registered schema.
Definition SchemaValidator.cpp:219
const char * getErrorMessage()
Deprecated.
Definition SchemaValidator.cpp:290
const char * getOutputFile()
Get the output file that will be used by the validator.
Definition SchemaValidator.cpp:98
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition SchemaValidator.cpp:373
std::map< std::string, std::string > & getProperties()
Get all configuration properties specified on the processor as a std::map.
Definition SchemaValidator.cpp:378
void exceptionClear()
Deprecated.
Definition SchemaValidator.cpp:276
XdmNode * validateToNode(const char *sourceFile=nullptr)
Validate an instance document supplied as a Source object.
Definition SchemaValidator.cpp:247
void setLax(bool l)
Set the validation mode - which may be either strict or lax.
Definition SchemaValidator.cpp:102
void setSourceNode(XdmNode *source)
Set the source node for validation.
Definition SchemaValidator.cpp:310
bool exceptionOccurred()
Checks for pending exceptions without creating a local reference to the exception object.
Definition SchemaValidator.cpp:297
const char * getErrorCode()
Deprecated.
Definition SchemaValidator.cpp:283
const char * checkException()
Deprecated.
Definition SchemaValidator.cpp:301
bool removeParameter(const char *name)
Remove a parameter (name, value) pair.
Definition SchemaValidator.cpp:339
The class XdmItem represents an item in a sequence, as defined by the XDM data model.
Definition XdmItem.h:31
This class represents a node in the XDM data model.
Definition XdmNode.h:57
An XdmValue represents a value in the XDM data model.
Definition XdmValue.h:33