Project

Profile

Help

Revision 0e42f323

Added by O'Neil Delpratt almost 6 years ago

Saxon/C updates

View differences:

latest9.6/hec/Saxon.C.API/EEC/SaxonCGlue.c
70 70
#endif
71 71

  
72 72
    if (!hDll) {
73
        printf ("Unable to load %s\n", name);
73
        fprintf (stderr, "Unable to load %s\n", name);
74 74
	perror("Error: ");
75 75
        exit(1);
76 76
    }
77 77
#ifdef DEBUG
78
    printf ("%s loaded\n", name);
78
    fprintf (stderr, "%s loaded\n", name);
79 79
#endif
80 80

  
81 81
    return hDll;
......
98 98
 */
99 99
void initJavaRT(HANDLE myDllHandle, JavaVM** pjvm, JNIEnv** penv)
100 100
{
101
    //perror ("initJavaRT - load Saxon/C library\n");
101
if(jvmCreated==0) {
102
     jvmCreated=1;
103
#ifdef DEBUG
104
    perror ("initJavaRT - load Saxon/C library\n");
105
#endif
102 106
    int result;
103 107
    JavaVMInitArgs args;
104 108
    JNI_GetDefaultJavaVMInitArgs_func =
......
108 112
#else
109 113
    GetProcAddress (myDllHandle, "JNI_GetDefaultJavaVMInitArgs");
110 114
#endif
115
 
111 116
    
112 117
    JNI_CreateJavaVM_func =
113 118
    (jint (JNICALL *) (JavaVM **pvm, void **penv, void *args))
......
118 123
    GetProcAddress (myDllHandle, "JNI_CreateJavaVM");
119 124
    
120 125
#endif
126

  
121 127
    
122 128
    if(!JNI_GetDefaultJavaVMInitArgs_func) {
123
        printf ("%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
129
        fprintf (stderr,"%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
124 130
        exit (1);
125 131
    }
126 132
    
127 133
    if(!JNI_CreateJavaVM_func) {
128
        printf ("%s doesn't contain public JNI_CreateJavaVM\n", getDllname());
134
        fprintf (stderr,"%s doesn't contain public JNI_CreateJavaVM\n", getDllname());
129 135
        exit (1);
130 136
    }
131 137
    
......
134 140
    args.version = JNI_VERSION_1_2;
135 141
    result = JNI_GetDefaultJavaVMInitArgs_func(&args);
136 142
    if (result != JNI_OK) {
137
        printf("JNI_GetDefaultJavaVMInitArgs() failed with result\n");
143
        fprintf(stderr,"JNI_GetDefaultJavaVMInitArgs() failed with result\n");
138 144
        exit(1);
139
    }  
145
    }
146
  
140 147
    /*
141 148
     * NOTE: no JVM is actually created
142 149
     * this call to JNI_CreateJavaVM is intended for JET RT initialization
143 150
     */
144 151
    result = JNI_CreateJavaVM_func (pjvm, (void **)penv, &args);
145 152
    if (result != JNI_OK) {
146
        printf("JNI_CreateJavaVM() failed with result\n");
153
        fprintf(stderr,"JNI_CreateJavaVM() failed with result: %i\n",result);
147 154
        exit(1);
148 155
    }
149 156

  
150
#ifdef DEBUG
151
    printf ("JET RT initialized\n");
152 157

  
153
#endif
154 158
    fflush (stdout);
159
  } else {
160
#ifdef DEBUG
161
    perror ("initJavaRT - Saxon/C library loaded already\n");
162
#endif
163
	}
155 164
}
156 165

  
157 166

  
......
363 372
void finalizeJavaRT (JavaVM* jvm)
364 373
{
365 374

  
366
  if(!jvm){
367
	  printf("\njvm is null\n");	
375
  if(jvmCreated!= 0){
376
    (*jvm)->DestroyJavaVM (jvm);
377
    jvmCreated=0;	
368 378
  }
369
  (*jvm)->DestroyJavaVM (jvm);
370 379
}
371 380

  
372 381

  
latest9.6/hec/Saxon.C.API/EEC/SaxonCGlue.h
58 58

  
59 59
static char dllname[] =
60 60
    #ifdef __linux__
61
        "/usr/lib/libsaxoneec.so";  //rename according to product edition (-hec or -pec) Also make change in the c file
61
        "/usr/lib/libsaxoneec.so";  //rename according to product edition (hec or pec) Also make change in the c file
62 62
    #elif  defined (__APPLE__) && defined(__MACH__)
63 63
        "/usr/lib/libsaxoneec.dylib";
64 64
    #else
65
         "C:\\Program Files\\Saxonica\\SaxonEEC1.0.0\\libsaxoneec.dll";
65
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\libsaxoneec.dll";
66 66
    #endif
67 67

  
68 68
static char resources_dir[] = 
......
71 71
    #elif  defined (__APPLE__) && defined(__MACH__)
72 72
        "/usr/lib/saxon-data";
73 73
    #else
74
         "C:\\Program Files\\Saxonica\\SaxonEEC1.0.0\\saxon-data";
74
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\saxon-data";
75 75
    #endif
76 76

  
77
// Static variable used to track when jvm has been created. Used to prevent creation more than once.
78
static int jvmCreated =0;
79

  
77 80

  
78 81
//===============================================================================================//
79 82
/*! <code>Environment</code>. This struct captures the jni, JVM and handler to the cross compiled Saxon/C library.
latest9.6/hec/Saxon.C.API/HEC/SaxonCGlue.c
70 70
#endif
71 71

  
72 72
    if (!hDll) {
73
        printf ("Unable to load %s\n", name);
73
        fprintf (stderr, "Unable to load %s\n", name);
74 74
	perror("Error: ");
75 75
        exit(1);
76 76
    }
77 77
#ifdef DEBUG
78
    printf ("%s loaded\n", name);
78
    fprintf (stderr, "%s loaded\n", name);
79 79
#endif
80 80

  
81 81
    return hDll;
......
98 98
 */
99 99
void initJavaRT(HANDLE myDllHandle, JavaVM** pjvm, JNIEnv** penv)
100 100
{
101
    //perror ("initJavaRT - load Saxon/C library\n");
101
if(jvmCreated==0) {
102
     jvmCreated=1;
103
#ifdef DEBUG
104
    perror ("initJavaRT - load Saxon/C library\n");
105
#endif
102 106
    int result;
103 107
    JavaVMInitArgs args;
104 108
    JNI_GetDefaultJavaVMInitArgs_func =
......
108 112
#else
109 113
    GetProcAddress (myDllHandle, "JNI_GetDefaultJavaVMInitArgs");
110 114
#endif
115
 
111 116
    
112 117
    JNI_CreateJavaVM_func =
113 118
    (jint (JNICALL *) (JavaVM **pvm, void **penv, void *args))
......
118 123
    GetProcAddress (myDllHandle, "JNI_CreateJavaVM");
119 124
    
120 125
#endif
126

  
121 127
    
122 128
    if(!JNI_GetDefaultJavaVMInitArgs_func) {
123
        printf ("%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
129
        fprintf (stderr,"%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
124 130
        exit (1);
125 131
    }
126 132
    
127 133
    if(!JNI_CreateJavaVM_func) {
128
        printf ("%s doesn't contain public JNI_CreateJavaVM\n", getDllname());
134
        fprintf (stderr,"%s doesn't contain public JNI_CreateJavaVM\n", getDllname());
129 135
        exit (1);
130 136
    }
131 137
    
......
134 140
    args.version = JNI_VERSION_1_2;
135 141
    result = JNI_GetDefaultJavaVMInitArgs_func(&args);
136 142
    if (result != JNI_OK) {
137
        printf("JNI_GetDefaultJavaVMInitArgs() failed with result\n");
143
        fprintf(stderr,"JNI_GetDefaultJavaVMInitArgs() failed with result\n");
138 144
        exit(1);
139
    }  
145
    }
146
  
140 147
    /*
141 148
     * NOTE: no JVM is actually created
142 149
     * this call to JNI_CreateJavaVM is intended for JET RT initialization
143 150
     */
144 151
    result = JNI_CreateJavaVM_func (pjvm, (void **)penv, &args);
145 152
    if (result != JNI_OK) {
146
        printf("JNI_CreateJavaVM() failed with result\n");
153
        fprintf(stderr,"JNI_CreateJavaVM() failed with result: %i\n",result);
147 154
        exit(1);
148 155
    }
149 156

  
150
#ifdef DEBUG
151
    printf ("JET RT initialized\n");
152 157

  
153
#endif
154 158
    fflush (stdout);
159
  } else {
160
#ifdef DEBUG
161
    perror ("initJavaRT - Saxon/C library loaded already\n");
162
#endif
163
	}
155 164
}
156 165

  
157 166

  
......
363 372
void finalizeJavaRT (JavaVM* jvm)
364 373
{
365 374

  
366
  if(!jvm){
367
	  printf("\njvm is null\n");	
375
  if(jvmCreated!= 0){
376
    (*jvm)->DestroyJavaVM (jvm);
377
    jvmCreated=0;	
368 378
  }
369
  (*jvm)->DestroyJavaVM (jvm);
370 379
}
371 380

  
372 381

  
latest9.6/hec/Saxon.C.API/HEC/SaxonCGlue.h
60 60
    #ifdef __linux__
61 61
        "/usr/lib/libsaxonhec.so";  //rename according to product edition (hec or pec) Also make change in the c file
62 62
    #elif  defined (__APPLE__) && defined(__MACH__)
63
        "/usr/lib/libsaxoneec.dylib";
63
        "/usr/lib/libsaxonhec.dylib";
64 64
    #else
65
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.0\\libsaxonhec.dll";
65
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\libsaxonhec.dll";
66 66
    #endif
67 67

  
68 68
static char resources_dir[] = 
......
71 71
    #elif  defined (__APPLE__) && defined(__MACH__)
72 72
        "/usr/lib/saxon-data";
73 73
    #else
74
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.0\\saxon-data";
74
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\saxon-data";
75 75
    #endif
76 76

  
77
// Static variable used to track when jvm has been created. Used to prevent creation more than once.
78
static int jvmCreated =0;
79

  
77 80

  
78 81
//===============================================================================================//
79 82
/*! <code>Environment</code>. This struct captures the jni, JVM and handler to the cross compiled Saxon/C library.
latest9.6/hec/Saxon.C.API/PEC/SaxonCGlue.c
70 70
#endif
71 71

  
72 72
    if (!hDll) {
73
        printf ("Unable to load %s\n", name);
73
        fprintf (stderr, "Unable to load %s\n", name);
74 74
	perror("Error: ");
75 75
        exit(1);
76 76
    }
77 77
#ifdef DEBUG
78
    printf ("%s loaded\n", name);
78
    fprintf (stderr, "%s loaded\n", name);
79 79
#endif
80 80

  
81 81
    return hDll;
......
98 98
 */
99 99
void initJavaRT(HANDLE myDllHandle, JavaVM** pjvm, JNIEnv** penv)
100 100
{
101
    //perror ("initJavaRT - load Saxon/C library\n");
101
if(jvmCreated==0) {
102
     jvmCreated=1;
103
#ifdef DEBUG
104
    perror ("initJavaRT - load Saxon/C library\n");
105
#endif
102 106
    int result;
103 107
    JavaVMInitArgs args;
104 108
    JNI_GetDefaultJavaVMInitArgs_func =
......
108 112
#else
109 113
    GetProcAddress (myDllHandle, "JNI_GetDefaultJavaVMInitArgs");
110 114
#endif
115
 
111 116
    
112 117
    JNI_CreateJavaVM_func =
113 118
    (jint (JNICALL *) (JavaVM **pvm, void **penv, void *args))
......
118 123
    GetProcAddress (myDllHandle, "JNI_CreateJavaVM");
119 124
    
120 125
#endif
126

  
121 127
    
122 128
    if(!JNI_GetDefaultJavaVMInitArgs_func) {
123
        printf ("%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
129
        fprintf (stderr,"%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
124 130
        exit (1);
125 131
    }
126 132
    
127 133
    if(!JNI_CreateJavaVM_func) {
128
        printf ("%s doesn't contain public JNI_CreateJavaVM\n", getDllname());
134
        fprintf (stderr,"%s doesn't contain public JNI_CreateJavaVM\n", getDllname());
129 135
        exit (1);
130 136
    }
131 137
    
......
134 140
    args.version = JNI_VERSION_1_2;
135 141
    result = JNI_GetDefaultJavaVMInitArgs_func(&args);
136 142
    if (result != JNI_OK) {
137
        printf("JNI_GetDefaultJavaVMInitArgs() failed with result\n");
143
        fprintf(stderr,"JNI_GetDefaultJavaVMInitArgs() failed with result\n");
138 144
        exit(1);
139
    }  
145
    }
146
  
140 147
    /*
141 148
     * NOTE: no JVM is actually created
142 149
     * this call to JNI_CreateJavaVM is intended for JET RT initialization
143 150
     */
144 151
    result = JNI_CreateJavaVM_func (pjvm, (void **)penv, &args);
145 152
    if (result != JNI_OK) {
146
        printf("JNI_CreateJavaVM() failed with result\n");
153
        fprintf(stderr,"JNI_CreateJavaVM() failed with result: %i\n",result);
147 154
        exit(1);
148 155
    }
149 156

  
150
#ifdef DEBUG
151
    printf ("JET RT initialized\n");
152 157

  
153
#endif
154 158
    fflush (stdout);
159
  } else {
160
#ifdef DEBUG
161
    perror ("initJavaRT - Saxon/C library loaded already\n");
162
#endif
163
	}
155 164
}
156 165

  
157 166

  
......
363 372
void finalizeJavaRT (JavaVM* jvm)
364 373
{
365 374

  
366
  if(!jvm){
367
	  printf("\njvm is null\n");	
375
  if(jvmCreated!= 0){
376
    (*jvm)->DestroyJavaVM (jvm);
377
    jvmCreated=0;	
368 378
  }
369
  (*jvm)->DestroyJavaVM (jvm);
370 379
}
371 380

  
372 381

  
latest9.6/hec/Saxon.C.API/PEC/SaxonCGlue.h
58 58

  
59 59
static char dllname[] =
60 60
    #ifdef __linux__
61
        "/usr/lib/libsaxonpec.so";  //rename according to product edition (-hec or -pec) Also make change in the c file
61
        "/usr/lib/libsaxonpec.so";  //rename according to product edition (hec or pec) Also make change in the c file
62 62
    #elif  defined (__APPLE__) && defined(__MACH__)
63
        "/usr/lib/libsaxon-pec.dylib";
63
        "/usr/lib/libsaxonpec.dylib";
64 64
    #else
65
         "C:\\Program Files\\Saxonica\\SaxonPEC1.0.0\\libsaxonpec.dll";
65
         "C:\\Program Files\\Saxonica\\SaxonPEC1.0.1\\libsaxonpec.dll";
66 66
    #endif
67 67

  
68 68
static char resources_dir[] = 
......
71 71
    #elif  defined (__APPLE__) && defined(__MACH__)
72 72
        "/usr/lib/saxon-data";
73 73
    #else
74
         "C:\\Program Files\\Saxonica\\SaxonPEC1.0.0\\saxon-data";
74
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\saxon-data";
75 75
    #endif
76 76

  
77
// Static variable used to track when jvm has been created. Used to prevent creation more than once.
78
static int jvmCreated =0;
79

  
77 80

  
78 81
//===============================================================================================//
79 82
/*! <code>Environment</code>. This struct captures the jni, JVM and handler to the cross compiled Saxon/C library.
latest9.6/hec/Saxon.C.API/SaxonCGlue.c
112 112
#else
113 113
    GetProcAddress (myDllHandle, "JNI_GetDefaultJavaVMInitArgs");
114 114
#endif
115

  
116
#ifdef DEBUG
117
    fprintf (stderr,"initJavaRT - check point 0\n");
118
#endif 
115
 
119 116
    
120 117
    JNI_CreateJavaVM_func =
121 118
    (jint (JNICALL *) (JavaVM **pvm, void **penv, void *args))
......
127 124
    
128 125
#endif
129 126

  
130
#ifdef DEBUG
131
    fprintf (stderr,"initJavaRT - check point 1\n");
132
#endif
133 127
    
134 128
    if(!JNI_GetDefaultJavaVMInitArgs_func) {
135 129
        fprintf (stderr,"%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
......
149 143
        fprintf(stderr,"JNI_GetDefaultJavaVMInitArgs() failed with result\n");
150 144
        exit(1);
151 145
    }
152

  
153
#ifdef DEBUG
154
    fprintf (stderr,"initJavaRT - before JNI_CreateJavaVM_func\n");
155
#endif  
146
  
156 147
    /*
157 148
     * NOTE: no JVM is actually created
158 149
     * this call to JNI_CreateJavaVM is intended for JET RT initialization
......
163 154
        exit(1);
164 155
    }
165 156

  
166
#ifdef DEBUG
167
    fprintf (stderr, "JET RT initialized\n");
168
   fflush (stderr);
169
#endif
157

  
170 158
    fflush (stdout);
171 159
  } else {
172 160
#ifdef DEBUG
......
385 373
{
386 374

  
387 375
  if(jvmCreated!= 0){
388
    printf("\njvm is null\n");	
389 376
    (*jvm)->DestroyJavaVM (jvm);
390 377
    jvmCreated=0;	
391 378
  }
latest9.6/hec/Saxon.C.API/SaxonCGlue.h
62 62
    #elif  defined (__APPLE__) && defined(__MACH__)
63 63
        "/usr/lib/libsaxoneec.dylib";
64 64
    #else
65
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.0\\libsaxonhec.dll";
65
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\libsaxonhec.dll";
66 66
    #endif
67 67

  
68 68
static char resources_dir[] = 
......
71 71
    #elif  defined (__APPLE__) && defined(__MACH__)
72 72
        "/usr/lib/saxon-data";
73 73
    #else
74
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.0\\saxon-data";
74
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\saxon-data";
75 75
    #endif
76 76

  
77 77
// Static variable used to track when jvm has been created. Used to prevent creation more than once.
latest9.6/hec/Saxon.C.API/config.m4
6 6
    PHP_REQUIRE_CXX()
7 7
    PHP_SUBST(SAXON_SHARED_LIBADD)
8 8
    PHP_ADD_LIBRARY(stdc++, 1, SAXON_SHARED_LIBADD)
9
    PHP_ADD_LIBRARY(saxonhec, 1, SAXON_SHARED_LIBADD)
9
    PHP_ADD_LIBRARY(saxoneec, 1, SAXON_SHARED_LIBADD)
10 10
    PHP_ADD_LIBRARY(dl, 1, SAXON_SHARED_LIBADD)
11 11
    PHP_NEW_EXTENSION(saxon, php_saxon.cpp SaxonProcessor.cpp XQueryProcessor.cpp XsltProcessor.cpp XPathProcessor.cpp SchemaValidator.cpp XdmValue.cpp XdmItem.cpp XdmNode.cpp XdmAtomicValue.cpp SaxonCGlue.c SaxonCProcessor.c  SaxonCXPath.c, $ext_shared)
12 12
fi
latest9.6/hec/Saxon.C.API/php_saxon.cpp
3305 3305
{
3306 3306
    php_info_print_table_start();
3307 3307
    php_info_print_table_header(2, "Saxon/C", "enabled");
3308
    php_info_print_table_row(2, "Saxon/C EXT version", "1.0.0");
3308
    php_info_print_table_row(2, "Saxon/C EXT version", "1.0.1");
3309 3309
    php_info_print_table_row(2, "Saxon", "9.6.0.9");
3310
    php_info_print_table_row(2, "Excelsior JET", "11 MP1");
3310
    php_info_print_table_row(2, "Excelsior JET", "11 MP2");
3311 3311
    php_info_print_table_end();
3312 3312
    DISPLAY_INI_ENTRIES();
3313 3313
}
latest9.6/hec/Saxon.C.API/readme.md
7 7
4. [Technical](#tech)
8 8
5. [Limitations](#limitations)
9 9

  
10
Saxon/C 1.0.0 is the latest major release of Saxon-HE/PE/EE on the C/C++ programming platform. The APIs support the specifications XSLT 2.0/3.0, XQuery 1.0/3.0, Schema Validation 1.0/1.1 and XPath 2.0/3.0 from C/C++ or PHP applications.
10
Saxon/C 1.0.1 is the latest major release of Saxon-HE/PE/EE on the C/C++ programming platform. The APIs support the specifications XSLT 2.0/3.0, XQuery 1.0/3.0, Schema Validation 1.0/1.1 and XPath 2.0/3.0 from C/C++ or PHP applications.
11 11

  
12
Saxon/C is built from the Saxon 9.6.0.9 Java product using the Excelsior JET tool (version 11 MP1).
12
Saxon/C is built from the Saxon 9.6.0.9 Java product using the Excelsior JET tool (version 11 MP2).
13 13

  
14
Platforms supported: Linux Only.
14
Platforms supported: Linux Only. 
15 15
Windows will be supported shortly
16 16

  
17 17
Saxon/C is release in three separate editions which replicating the products on the Java platform: Enterprise (Saxon-EE/C), Professional Editon (Saxon-PE/C), and Home Edition (Saxon-HE/C)
......
20 20
## Installation: ##
21 21

  
22 22
#### Saxon-HE/C, Saxon-PE/C and Saxon-EE/C: ####
23
To install any of the Saxon/C releases, unzip the the file libsaxon-EDITION-setup-v1.0.0.zip and execute the command './libsaxon-EDITION-setup-v1.0.0'
23
To install any of the Saxon/C releases, unzip the the file libsaxon-EDITION-setup-v#.#.#.zip and execute the command './libsaxon-EDITION-setup-v#.#.#'
24 24
First step is to select the destination of where the product files will be installed.
25 25
The product files are unpacked in the directory 'Saxon-EDITIONC'
26 26

  
27 27
Link the dynamic saxon library so it can be found. For example:
28 28

  
29
	ln -s /usr/lib/Saxonica/Saxon-EDITIONC1.0.0/libsaxonEDITION.so /usr/lib/libsaxonEDITION.so
29
	ln -s /usr/lib/Saxonica/Saxon-EDITIONC#.#.#/libsaxonEDITION.so /usr/lib/libsaxonEDITION.so
30 30

  
31 31
You need to setup the environment for the jet jvm. The jvm is in the directory JET-home=Saxonica/Saxon-EDITION1.1.0/rt
32 32
The directory JET-home/lib/i386  or JET_home/lib/amd64 (for 64-bit machines) must be listed in the LD_LIBRARY_PATH environment variable. For instance, if you
......
38 38

  
39 39
Link the jetvm library so it can be found. For example:
40 40

  
41
	ln -s /usr/lib/Saxonica/Saxon-EDITIONC1.0.0/rt /usr/lib/rt
41
	ln -s /usr/lib/Saxonica/Saxon-EDITIONC#.#.#/rt /usr/lib/rt
42 42

  
43 43
The Saxon-EDITION API assumes the library is installed as follows: '/usr/lib/libsaxonhec.so', '/usr/lib/libsaxonpec.so' or '/usr/lib/libsaxoneec.so'
44 44
The directory 'saxon-data' must be linked ot copied to '/usr/lib', alternatively you can use the ennvironment variable SAXONC_HOME to locate directory.
......
101 101

  
102 102
The following files are required to build Saxon/C on C++:  SaxonCGlue.c, SaxonCXPath.c, XdmValue.cpp, XdmItem.cpp, XdmNode.cpp, XdmAtomicValue.cpp, SaxonProcessor.cpp, XsltProcessor.cpp and XQueryProcessor.cpp, XPathProcessor.cpp, SchemaValidator.cpp
103 103

  
104
To compile the sample test code in C++ execute the 'build.sh' file the directory 'cppTests'. This file builds executables for the test cases testing XSLT, XPath, XQuery and schema Validator. The command is similar to the following:
104
To compile the sample test code in C++ execute the 'build.sh' file the directory 'cppTests'. This file builds executables for the test cases testing XSLT, XPath, XQuery and schema Validator. The command is similar to the following: 
105 105

  
106 106
> g++ -m32  ../bin/SaxonCGlue.o ../bin/SaxonCXPath.o ../bin/SaxonProcessor.o ../bin/XQueryProcessor.o ../bin/XsltProcessor.o ../bin/XPathProcessor.o ../bin/XdmValue.o ../bin/XdmItem.o ../bin/XdmNode.o ../bin/XdmAtomicValue.o ../bin/SchemaValidator.o testXSLT.cpp -o testXSLT -ldl -lc -lsaxon $1 $2
107 107

  
......
114 114

  
115 115
The example below shows how we can set the configuration features on the processor before we create any of the processors (.e.g. XsltProcessor, XQueryProcess, etc):
116 116

  
117
> processor->setConfigurationProperty("xsdversion", "1.1");
117
> processor->setConfigurationProperty("xsdversion", "1.1"); 
118 118
or
119 119
> processor->setConfigurationProperty("http://saxon.sf.net/feature/multipleSchemaImports", "on");
120 120

  
......
149 149

  
150 150

  
151 151
Example 1:
152

  
152
 
153 153
<pre><code>
154 154
	SaxonProcessor *processor = new SaxonProcessor(true);
155 155
	XsltProcessor * xslt = processor->newTransformer();
......
166 166
        xslt->setSourceFile("xml/foo.xml");
167 167
	XdmAtomicValue * xdmvaluex =processor->makeStringValue("Hello to you");
168 168
	if(xdmvaluex !=NULL){
169
		cerr<< "xdmvaluex ok"<<endl;
169
		cerr<< "xdmvaluex ok"<<endl; 			
170 170
	}
171 171
	xslt->setParameter("a-param", xdmvaluex);
172 172
        const char * result = test->transformFileToString(NULL, "xsl/foo.xsl");
......
238 238
<pre><code>
239 239
	SaxonProcessor *processor = new SaxonProcessor();
240 240
	XPathProcessor * xpath = processor->newXPathProcessor();
241

  
241
 
242 242
	xpath->setContextFile("cat.xml");
243 243

  
244 244
	XdmValue * resultValues = xpath->evaluate("//person");
245

  
245
	
246 246
	if(resultValues == NULL) {
247 247
		 printf("result is null \n");
248 248
	} else {
......
253 253
				cout<<"Item at position "<<i<<" should not be null"<<endl;
254 254
				break;
255 255
			}
256
			cout<<"Item at "<<i<<" ="<<itemi->getStringValue(processor)<<endl;
256
			cout<<"Item at "<<i<<" ="<<itemi->getStringValue(processor)<<endl;		
257 257
		}
258 258
	}
259 259
	xpath->clearParameters(true);
......
264 264

  
265 265
| Name | Example | Comment |
266 266
| :---- | :---- | :---- |
267
| 'node'=xdmValue | setParameter("node",xdmNodeObj) | Sets the source document for query. We also accept the parameter names 'item'.|
267
| 'node'=xdmValue | setParameter("node",xdmNodeObj) | Sets the source document for the validation. We also accept the parameter names 'item'.|
268 268
| param=xdmValue | setParameter("numParam",value1) | Set the value of external variable defined in the query |
269 269

  
270 270
#### setProperty(string $name, string $propValue) Method ####
......
274 274
| :---- | :---- | :---- |
275 275
|![serialization name]=value  | setProperty("!INDENT","yes") | Influence the serialization of the XML by the parameters specified with a exclamation mark with a name and the value. See [Documentation](http://saxonica.com/documentation/index.html#!javadoc/net.sf.saxon.s9api/Serializer/Property) |
276 276
| 'o'=filename | setProperty("o", "output.xml") | Sets the destination for the result of the XQuery to the specificed filename  |
277
| 'string'=xml-string | setProperty("string",xml-string) | Sets the source document aas a string for validation. Parsing will happen when the validate method has been called.|
277 278
| 'dtd'=boolean | setProperty("dtd", "true") | Set whether DTD validation should be applied to documents loaded |
278 279
| 's'=filename | setProperty("s", "filename") | Identifies the source file or directory. Mandatory unless the -it option is used. |
279 280
| 'resources'=directory | setProperty("resources", "dir") | Specifies the directory where the resources file are found|
281
| 'report-node'=boolean | setProperty("report-node", "true") | Flag for validation reporting feature. Error validation failures are represented in an XML document |
282
| 'report-file'=filename | setProperty("report-file", "filename") | Switches on the validation reporting feature. Validation failures collected and saved in an XML format in a file.|
283
| 'verbose'=boolean | setProperty("verbose", "true") | Set verbose mode to output to the terminal validation exceptions. The default is on providing the reporting feature has not been enabled.|
284
| 'element-type'=string | setProperty("element-type", "{uri}local") | Set the name of the required type of the top-level element of the document to be validated. The string should be in the Clark notation: {uri}local|
285
| 'element-name'=string | setProperty("element-name", "{uri}local") | Set the name of the required top-level element of the document to be validated (that is, the name of the outermost element of the document). The string should be in the Clark notation: {uri}local|
286
| 'lax'=boolean | setProperty("lax", "true") | The validation mode may be either strict or lax. Default is strict. This property indicates that lax validation is required.|
280 287

  
281 288
Example:
282 289

  
......
286 293
	processor->setConfigurationProperty("http://saxon.sf.net/feature/multipleSchemaImports", "on");
287 294
	SchemaValidator * val = processor->newSchemaValidator();
288 295
	val->registerSchemaFromFile("family-ext.xsd");
289

  
296
      
290 297
	val->registerSchemaFromFile("family.xsd");
291
	val->setProperty("report-node", "true");
298
	val->setProperty("report-node", "true");	
292 299
	val->setProperty("verbose", "true");
293 300
	val->validate("family.xml");
294
	XdmNode * node = val->getValidationReport();
301
	XdmNode * node = val->getValidationReport(); 
295 302
	if(node != NULL) {
296 303
		cout<<endl<<"Validation Report"<<node->getStringValue()<<endl;
297 304
	} else {
......
400 407
| void | setProperty(string $name, string $value) <br> *Set properties for Query.* |
401 408
| void | clearParameters() <br> *Clear parameter values set* |
402 409
| void | clearProperties() <br> *Clear property values set* |
403
| void | exceptionClear() <br> *Clear any exception thrown*
410
| void | exceptionClear() <br> *Clear any exception thrown* 
404 411
| string | getErrorCode(int $i) <br> *Get the ith error code if there are any errors*  |
405 412
| string | getErrorMessage(int $i) <br> *Get the ith error message if there are any error* |
406
| int | getExceptionCount() <br> *Get number of error during execution or evaluate of stylesheet and query, respectively* |
413
| int | getExceptionCount() <br> *Get number of error during execution or evaluate of stylesheet and query, respectively* | 
407 414

  
408 415
#### Saxon\\SchemaValidator class ####
409 416
<sup>PHP API</sup>
......
414 421
| void | setOutputFile(string $fileName) <br> *The instance document to be validated. Supplied file name is resolved and accessed* |
415 422
| void | registerSchemaFromFile(string $fileName) <br> *Register the Schema which is given as file name.* |
416 423
| void | registerSchemaFromString(string $schemaStr) <br> *Register the Schema which is given as a string representation.* |
417
| void | validate() <br> *Validate an instance document supplied as a Source object. Assume source document has already been supplied through accessor methods* |
424
| void | validate() <br> *Validate an instance document supplied as a Source object. Assume source document has already been supplied through accessor methods* | 
418 425
| void | validate(string $fileName) <br> *Validate an instance document supplied as a Source object. $filename - The name of the file to be validated. $filename can be null* |
419 426
| XdmNode | validateToNode() <br> *Validate an instance document supplied as a Source object with the validated document returned to the calling program. Assume source document has already been supplied through accessor methods* |
420 427
| XdmNode | validateToNode(string $fileName) <br> *Validate an instance document supplied as a Source object with the validated document returned to the calling program. $filename - The name of the file to be validated. $filename can be null* |
......
423 430
| void | setProperty(string $name, string $value) <br> *Set properties for Schema Validator.* |
424 431
| void | clearParameters() <br> *Clear parameter values set* |
425 432
| void | clearProperties() <br> *Clear property values set* |
426
| void | exceptionClear() <br> *Clear any exception thrown*
433
| void | exceptionClear() <br> *Clear any exception thrown* 
427 434
| string | getErrorCode(int $i) <br> *Get the ith error code if there are any errors*  |
428 435
| string | getErrorMessage(int $i) <br> *Get the ith error message if there are any error* |
429 436
| int | getExceptionCount() <br> *Get number of error during execution of the validator* |
......
481 488

  
482 489
Example code XSLT processing:
483 490
<pre><code>
484
	<?php
491
	<?php 
485 492
	        $xmlfile = "xml/foo.xml";
486 493
	        $xslFile = "xsl/foo.xsl";
487 494
		$proc = new Saxon\\SaxonProcessor();
......
489 496
            	echo 'Saxon Processor version: '.$version;
490 497
		$xsltProc = $saxonProc->newXsltProcessor();
491 498
                $xsltProc->setSourceFromFile($xmlfile);
492
                $xsltProc->compileFromFile($xslFile);
493
                $result = $xsltProc->transformToString();
494
		if($result != null) {
499
                $xsltProc->compileFromFile($xslFile);      
500
                $result = $xsltProc->transformToString();               
501
		if($result != null) {               
495 502
		  echo '<b>exampleSimple1:</b><br/>';
496 503
		  echo 'Output:'.$result;
497 504
		} else {
498 505
			echo "Result is null";
499 506
		}
500 507
		$xsltProc->clearParameters();
501
		$xsltProc->clearProperties();
508
		$xsltProc->clearProperties(); 
502 509
	?>
503 510
</code></pre>
504 511

  
......
506 513
In the example below we show how to debug if something unexpected is happening. It is also very useful to examine the apache error.log file:
507 514

  
508 515
<pre><code>
509
	<?php
516
	<?php 
510 517
	        $xmlfile = "xml/foo.xml";
511 518
	        $xslFile = "xsl/foo.xsl";
512 519
		$proc = new Saxon\\SaxonProcessor();
513 520
		$xsltProc = $saxonProc->newXsltProcessor();
514 521
                $xsltProc->setSourceFromFile($xmlFile);
515 522
                $xsltProc->compileFromFile($xslFile);
516

  
523
                
517 524
                $result = $xsltProc->transformToString();
518

  
525
                
519 526
                if($result == NULL) {
520 527
                    $errCount = $xsltProc->getExceptionCount();
521
				    if($errCount > 0 ){
528
				    if($errCount > 0 ){ 
522 529
				        for($i = 0; $i < $errCount; $i++) {
523 530
					       $errCode = $xsltProc->getErrorCode(intval($i));
524 531
					       $errMessage = $xsltProc->getErrorMessage(intval($i));
525 532
					       echo 'Expected error: Code='.$errCode.' Message='.$errMessage;
526 533
					   }
527
						$xsltProc->exceptionClear();
534
						$xsltProc->exceptionClear();	
528 535
					}
529

  
530

  
531
                }
536
                
537
                
538
                }                
532 539
                echo $result;
533 540
            	$xsltProc->clearParameters();
534 541
		$xsltProc->clearProperties();
......
550 557
<div id='limitations'/>
551 558
## Limitations: ##
552 559

  
553
The following limitations apply to the the 1.0.0 release:
560
The following limitations apply to the the 1.0 release:
554 561

  
555 562
* No support for the XdmFunction type in the Xdm data model
556 563
* No supports for external functions in XSLT and XQuery
557 564

  
565

  
558 566
### Feedback/Comments: ###
559 567

  
560 568
Please use the help forums and bug trackers at [saxonica.plan.io](https://saxonica.plan.io/projects/saxon-c) if you need help or advice.
latest9.6/hec/samples/cTests/testXPath.c
38 38
    setProperty(&properties, &propLen, &propCap, "s", "cat.xml");
39 39
    
40 40

  
41
    sxnc_value * result = evaluate(*environ,&processor, "/home/ond1/work/svn/Saxon.C.Api/cTests/", "/out/person", 0, properties, 0, propLen);
41
    sxnc_value * result = evaluate(*environ,&processor, NULL, "/out/person", 0, properties, 0, propLen);
42 42

  
43
 bool resultBool = effectiveBooleanValue(*environ,&processor, "/home/ond1/work/svn/Saxon.C.Api/cTests/", "count(/out/person)>0", 0, properties, 0, propLen);
43
 bool resultBool = effectiveBooleanValue(*environ,&processor, NULL, "count(/out/person)>0", 0, properties, 0, propLen);
44 44
 
45 45
    if(!result) {
46 46
      printf("result is null");
latest9.6/hec/samples/cTests/testXQuery.c
42 42

  
43 43
    setProperty(&properties, &propLen, &propCap, "qs", "<out>{count(/out/person)}</out>");
44 44

  
45
    const char * result = executeQueryToString(*environ, &processor, "/home/ond1/work/svn/Saxon.C.Api/cTests/", 0,properties,0,propLen);
45
    const char * result = executeQueryToString(*environ, &processor, NULL, 0,properties,0,propLen);
46 46

  
47
    //executeQueryToFile(*environ, &processor, "/home/ond1/work/svn/Saxon.C.Api/ctests/", "xquerOut.txt", 0,properties,0,propLen);
48 47
    if(!result) {
49 48
      printf("result is null\n");
50 49
    }else {
latest9.6/hec/samples/cTests/testXSLT.c
40 40
    setParameter(&parameters, &parLen, &parCap,"", "numParam", num);
41 41
  
42 42

  
43
    const char *result = xsltApplyStylesheet(*environ, &processor, "/home/ond1/work/svn/Saxon.C.Api/cTests/", "ORP0301177AA__EE__30954_sinsello.xml","campos.xsl", 0 ,0, 0, 0);
43
    const char *result = xsltApplyStylesheet(*environ, &processor, NULL, "cat.xml","test.xsl", 0 ,0, 0, 0);
44 44
  
45
    /*xsltSaveResultToFile(*environ, &processor, "/home/ond1/work/svn/Saxon.C.Api/cTests/", "cat.xml","test.xsl", "output.txt", parameters ,0, parLen, 0);*/
46 45
	
47 46

  
48 47
    if(!result) {
latest9.6/hec/samples/cppTests/testXSLT.cpp
423 423

  
424 424
    SaxonProcessor * processor = new SaxonProcessor(true);
425 425
    cout<<"Test: XsltProcessor with Saxon version="<<processor->version()<<endl<<endl; 
426
    processor->setcwd("/home/ond1/work/svn/Saxon.C.Api/cppTests");
426
    //processor->setcwd("/home/");
427 427
    processor->setConfigurationProperty("http://saxon.sf.net/feature/generateByteCode", "off");
428 428

  
429 429
    XsltProcessor * trans = processor->newXsltProcessor();

Also available in: Unified diff