SaxonC  11.6
Saxon Processor library for C/C++, PHP and Python
SchemaValidator.h
1 // Copyright (c) 2022 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
7 
8 #ifndef SAXON_SCHEMA_H
9 #define SAXON_SCHEMA_H
10 
11 
12 #include "SaxonProcessor.h"
13 
14 #include <string>
15 
16 class SaxonProcessor;
17 class XdmValue;
18 class XdmNode;
19 class XdmItem;
20 
25 public:
26 
28 
32 
34 
39  SchemaValidator(SaxonProcessor* proc, std::string cwd="");
40 
42 
46  void setcwd(const char* cwd);
47 
49 
56  void registerSchemaFromFile(const char * xsd);
57 
59 
63  void registerSchemaFromString(const char * schemaStr);
64 
66 
70  void exportSchema(const char * fileName);
71 
73 
76  void setOutputFile(const char * outputFile);
77 
78 
80 
85  void validate(const char * sourceFile = nullptr);
86 
88 
92  XdmNode * validateToNode(const char * sourceFile = nullptr);
93 
94 
96 
99  void setSourceNode(XdmNode * source);
100 
102 
107 
108 
110 
116  void setParameter(const char * name, XdmValue*value);
117 
118 
120 
126  bool removeParameter(const char * name);
127 
129 
135  void setProperty(const char * name, const char * value);
137 
143  void clearParameters(bool deleteValues=false);
144 
146  void clearProperties();
147 
148 
150  std::map<std::string,XdmValue*>& getParameters();
151 
153  std::map<std::string,std::string>& getProperties();
154 
156 
160  bool exceptionOccurred();
161 
162 
164 
167  const char* checkException();
168 
170  void exceptionClear();
171 
173 
176  //int exceptionCount();
177 
179 
183  const char * getErrorMessage(int i);
184 
186 
190  const char * getErrorCode(int i);
191 
193 
200  void setLax(bool l){
201  lax = l;
202  }
203 
204 
207  return cppV;
208  }
209 
210 
211 private:
212  bool lax;
213  SaxonProcessor * proc;
214  XdmItem * sourceNode;
215  jclass cppClass;
216  jobject cppV;
217  std::string cwdV;
218  std::string outputFile;
219  std::map<std::string,XdmValue*> parameters;
220  std::map<std::string,std::string> properties;
221  SaxonApiException * exception;
222 };
223 
224 
225 
226 
227 #endif /* SAXON_SCHEMA_H */
Definition: SaxonApiException.h:19
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition: SaxonProcessor.h:119
Definition: SchemaValidator.h:24
void clearProperties()
Clear property values set.
Definition: SchemaValidator.cpp:519
void registerSchemaFromFile(const char *xsd)
Register the schema from file name.
Definition: SchemaValidator.cpp:87
void setcwd(const char *cwd)
Set the Current working Directory.
Definition: SchemaValidator.cpp:58
void setOutputFile(const char *outputFile)
Set the name of the output file that will be used by the validator.
Definition: SchemaValidator.cpp:64
jobject getUnderlyingValidator()
Get the underlying java object of the C++ schema validator.
Definition: SchemaValidator.h:206
const char * getErrorCode(int i)
Get the i'th error code if errors are reported.
Definition: SchemaValidator.cpp:440
SchemaValidator()
Default constructor.
Definition: SchemaValidator.cpp:12
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition: SchemaValidator.cpp:503
void exportSchema(const char *fileName)
Export a precompiled Schema Component Model containing all the components (except built-in components...
Definition: SchemaValidator.cpp:163
XdmNode * getValidationReport()
Get the Validation report.
Definition: SchemaValidator.cpp:68
void validate(const char *sourceFile=nullptr)
Validate an instance document by a registered schema.
Definition: SchemaValidator.cpp:267
const char * getErrorMessage(int i)
Get number of errors during validation of the source against the schema.
Definition: SchemaValidator.cpp:445
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition: SchemaValidator.cpp:523
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition: SchemaValidator.cpp:528
void exceptionClear()
Clear any exception thrown.
Definition: SchemaValidator.cpp:432
XdmNode * validateToNode(const char *sourceFile=nullptr)
Validate an instance document supplied as a Source object.
Definition: SchemaValidator.cpp:353
void setLax(bool l)
The validation mode may be either strict or lax.
Definition: SchemaValidator.h:200
void setParameter(const char *name, XdmValue *value)
Set a parameter value used in the validator.
Definition: SchemaValidator.cpp:474
void setSourceNode(XdmNode *source)
Set the source node for validation.
Definition: SchemaValidator.cpp:465
bool exceptionOccurred()
Checks for pending exceptions without creating a local reference to the exception object.
Definition: SchemaValidator.cpp:450
void registerSchemaFromString(const char *schemaStr)
Register the schema supplied as a string.
Definition: SchemaValidator.cpp:189
void setProperty(const char *name, const char *value)
Set a property.
Definition: SchemaValidator.cpp:494
const char * checkException()
Check for exception thrown.
Definition: SchemaValidator.cpp:454
bool removeParameter(const char *name)
Remove a parameter (name, value) pair.
Definition: SchemaValidator.cpp:490
Definition: XdmItem.h:29
Definition: XdmNode.h:31
Definition: XdmValue.h:50