Saxon/C  1.2.1
Saxon Processor library for C/C++, PHP and Python
SchemaValidator.h
1 // Copyright (c) 2015 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 //#include "XdmValue.h"
14 //#include "XdmItem.h"
15 
16 #include <string>
17 
18 class SaxonProcessor;
19 class XdmValue;
20 class XdmNode;
21 class XdmItem;
22 
27 public:
28 
30 
34 
36 
41  SchemaValidator(SaxonProcessor* proc, std::string cwd="");
42 
44 
48  void setcwd(const char* cwd);
49 
51 
55  void registerSchemaFromFile(const char * xsd);
56 
57  void registerSchemaFromString(const char * schemaStr);
58 
63  void setOutputFile(const char * outputFile);
64 
65 
71  void validate(const char * sourceFile = NULL);
72 
74 
78  XdmNode * validateToNode(const char * sourceFile = NULL);
79 
80 
82 
86  void setSourceNode(XdmNode * source);
87 
89 
94 
95 
102  void setParameter(const char * name, XdmValue*value);
103 
104 
111  bool removeParameter(const char * name);
118  void setProperty(const char * name, const char * value);
119 
126  void clearParameters(bool deleteValues=false);
127 
131  void clearProperties();
132 
133 
137  std::map<std::string,XdmValue*>& getParameters();
138 
142  std::map<std::string,std::string>& getProperties();
143 
148  bool exceptionOccurred();
149 
150 
152 
155  const char* checkException();
156 
158  void exceptionClear();
159 
161 
164  int exceptionCount();
165 
167 
171  const char * getErrorMessage(int i);
172 
174 
178  const char * getErrorCode(int i);
179 
181 
188  void setLax(bool l){
189  lax = l;
190  }
191 
192 
193 private:
194  bool lax;
195  SaxonProcessor * proc;
196  XdmItem * sourceNode;
197  jclass cppClass;
198  jobject cppV;
199  std::string cwdV;
200  std::string outputFile;
201  std::map<std::string,XdmValue*> parameters;
202  std::map<std::string,std::string> properties;
204 };
205 
206 
207 
208 
209 #endif /* SAXON_XPATH_H */
std::map< std::string, std::string > & getProperties()
Definition: SchemaValidator.cpp:478
bool exceptionOccurred()
Definition: SchemaValidator.cpp:409
void setLax(bool l)
The validation mode may be either strict or lax.
Definition: SchemaValidator.h:188
void setParameter(const char *name, XdmValue *value)
Definition: SchemaValidator.cpp:433
SchemaValidator()
Default constructor.
Definition: SchemaValidator.cpp:8
Definition: XdmNode.h:21
std::map< std::string, XdmValue * > & getParameters()
Definition: SchemaValidator.cpp:473
void registerSchemaFromFile(const char *xsd)
Register the schema from file name.
Definition: SchemaValidator.cpp:72
Definition: SchemaValidator.h:26
Definition: XdmValue.h:46
bool removeParameter(const char *name)
Definition: SchemaValidator.cpp:440
void setProperty(const char *name, const char *value)
Definition: SchemaValidator.cpp:444
XdmNode * validateToNode(const char *sourceFile=NULL)
Validate an instance document supplied as a Source object.
Definition: SchemaValidator.cpp:311
const char * getErrorCode(int i)
Get the i&#39;th error code if there are any error.
Definition: SchemaValidator.cpp:399
const char * checkException()
Check for exception thrown.
Definition: SchemaValidator.cpp:413
void validate(const char *sourceFile=NULL)
Definition: SchemaValidator.cpp:225
void clearProperties()
Definition: SchemaValidator.cpp:469
Definition: SaxonProcessor.h:296
Definition: XdmItem.h:15
void clearParameters(bool deleteValues=false)
Definition: SchemaValidator.cpp:453
XdmNode * getValidationReport()
Get the Validation report.
Definition: SchemaValidator.cpp:52
void exceptionClear()
Clear any exception thrown.
Definition: SchemaValidator.cpp:391
void setOutputFile(const char *outputFile)
Definition: SchemaValidator.cpp:48
void setSourceNode(XdmNode *source)
Set the source node for validation.
Definition: SchemaValidator.cpp:424
const char * getErrorMessage(int i)
Get the ith error message if there are any validation errors.
Definition: SchemaValidator.cpp:404
void setcwd(const char *cwd)
Set the Current working Directory.
Definition: SchemaValidator.cpp:42
int exceptionCount()
Get number of errors during validation of the source against the schema.
Definition: SchemaValidator.cpp:417