Merge lp:~zorba-coders/zorba/data-formatting-doc into lp:zorba/process-module
- data-formatting-doc
- Merge into process-module
Status: | Superseded |
---|---|
Proposed branch: | lp:~zorba-coders/zorba/data-formatting-doc |
Merge into: | lp:zorba/process-module |
Diff against target: |
1098 lines (+1023/-0) (has conflicts) 12 files modified
CMakeLists.txt (+56/-0) cmake_modules/FindJNI.cmake (+286/-0) cmake_modules/Windows/FindJNI.cmake (+37/-0) src/CMakeLists.txt (+20/-0) src/com/CMakeLists.txt (+17/-0) src/com/zorba-xquery/CMakeLists.txt (+17/-0) src/com/zorba-xquery/www/CMakeLists.txt (+17/-0) src/com/zorba-xquery/www/modules/CMakeLists.txt (+105/-0) src/com/zorba-xquery/www/modules/xsl-fo.xq (+161/-0) src/com/zorba-xquery/www/modules/xsl-fo.xq.src/xslfo.cpp (+280/-0) test/ExpQueryResults/data-formatting/xslfo.xml.res (+1/-0) test/Queries/data-formatting/xslfo.xq (+26/-0) Conflict adding file CMakeLists.txt. Moved existing file to CMakeLists.txt.moved. Conflict adding file src. Moved existing file to src.moved. Conflict adding file test. Moved existing file to test.moved. |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/data-formatting-doc |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cezar Andrei | Needs Fixing | ||
William Candillon | Approve | ||
Review via email: mp+126953@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-10-03.
Commit message
Minor documentation improvements.
Description of the change
Minor documentation improvements.
William Candillon (wcandillon) : | # |
Unmerged revisions
- 37. By William Candillon
-
Minor documentation improvement.
- 36. By Juan Zacarias
-
Changes to FindJNI.cmake to work with the Ubuntu Installer Approved: Juan Zacarias, Chris Hillery
- 35. By Chris Hillery
-
Don't depend on util-jvm to find Java for us; find it ourselves. Approved: Chris Hillery, Cezar Andrei
- 34. By Matthias Brantner
-
- improved search of dependent jars
- removed dead code Approved: Cezar Andrei, Matthias Brantner - 33. By Chris Hillery
-
Report gracefully if util-jvm module is not found. Approved: Nicolae Brinza, Chris Hillery
- 32. By Chris Hillery
-
Add util-jvm link libraries.
- 31. By Cezar Andrei <email address hidden>
-
Integrated dependency on util-jvm module.
- 30. By Rodolfo Ochoa
-
Fixes on CMakeList to avoid submitting a test when module is not active.
Also added functionality to avoid testing for Java if module is not active. Approved: Matthias Brantner, Chris Hillery, Cezar Andrei - 29. By Cezar Andrei <email address hidden>
-
Impl renaming getProperties to getPropertiesGl
obal. - 28. By Cezar Andrei <email address hidden>
-
Fix adding test only when XSL-FOP is built.
Preview Diff
1 | === added file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3 | +++ CMakeLists.txt 2012-09-28 12:58:20 +0000 | |||
4 | @@ -0,0 +1,56 @@ | |||
5 | 1 | # Copyright 2006-2010 The FLWOR Foundation. | ||
6 | 2 | # | ||
7 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
8 | 4 | # you may not use this file except in compliance with the License. | ||
9 | 5 | # You may obtain a copy of the License at | ||
10 | 6 | # | ||
11 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
12 | 8 | # | ||
13 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
14 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
15 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
16 | 12 | # See the License for the specific language governing permissions and | ||
17 | 13 | # limitations under the License. | ||
18 | 14 | |||
19 | 15 | MESSAGE (STATUS "******** BEGIN Configuring module Data-Formatting ********") | ||
20 | 16 | |||
21 | 17 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) | ||
22 | 18 | |||
23 | 19 | PROJECT (zorba_data-formatting_module) | ||
24 | 20 | |||
25 | 21 | FIND_PACKAGE (zorba_util-jvm_module QUIET) | ||
26 | 22 | |||
27 | 23 | IF (zorba_util-jvm_module_FOUND) | ||
28 | 24 | INCLUDE ("${zorba_util-jvm_module_USE_FILE}") | ||
29 | 25 | |||
30 | 26 | FIND_PACKAGE(JNI) | ||
31 | 27 | FIND_PACKAGE(Java) | ||
32 | 28 | FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}") | ||
33 | 29 | INCLUDE ("${Zorba_USE_FILE}") | ||
34 | 30 | |||
35 | 31 | IF (JNI_FOUND) | ||
36 | 32 | INCLUDE_DIRECTORIES (${zorba_util-jvm_module_INCLUDE_DIRS}) | ||
37 | 33 | |||
38 | 34 | ENABLE_TESTING () | ||
39 | 35 | INCLUDE (CTest) | ||
40 | 36 | |||
41 | 37 | SET_CMAKE_MODULE_PATH () | ||
42 | 38 | |||
43 | 39 | FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}") | ||
44 | 40 | INCLUDE ("${Zorba_USE_FILE}") | ||
45 | 41 | |||
46 | 42 | ADD_SUBDIRECTORY ("src") | ||
47 | 43 | #ADD_TEST_DIRECTORY ("${CMAKE_SOURCE_DIR}/test") | ||
48 | 44 | |||
49 | 45 | DONE_DECLARING_ZORBA_URIS () | ||
50 | 46 | |||
51 | 47 | ELSE (JNI_FOUND) | ||
52 | 48 | MESSAGE ( STATUS "Java and/or JNI not found; skipping data-formating module.") | ||
53 | 49 | ENDIF(JNI_FOUND) | ||
54 | 50 | |||
55 | 51 | ELSE (zorba_util-jvm_module_FOUND) | ||
56 | 52 | MESSAGE (STATUS "Zorba's util-jvm module not found; skipping data-formatting module.") | ||
57 | 53 | ENDIF (zorba_util-jvm_module_FOUND) | ||
58 | 54 | |||
59 | 55 | |||
60 | 56 | MESSAGE (STATUS "******** END Configuring module Data-Formatting ********") | ||
61 | 0 | 57 | ||
62 | === renamed file 'CMakeLists.txt' => 'CMakeLists.txt.moved' | |||
63 | === added directory 'cmake_modules' | |||
64 | === added file 'cmake_modules/FindJNI.cmake' | |||
65 | --- cmake_modules/FindJNI.cmake 1970-01-01 00:00:00 +0000 | |||
66 | +++ cmake_modules/FindJNI.cmake 2012-09-28 12:58:20 +0000 | |||
67 | @@ -0,0 +1,286 @@ | |||
68 | 1 | # - Find JNI java libraries. | ||
69 | 2 | # This module finds if Java is installed and determines where the | ||
70 | 3 | # include files and libraries are. It also determines what the name of | ||
71 | 4 | # the library is. This code sets the following variables: | ||
72 | 5 | # | ||
73 | 6 | # JNI_INCLUDE_DIRS = the include dirs to use | ||
74 | 7 | # JNI_LIBRARIES = the libraries to use | ||
75 | 8 | # JNI_FOUND = TRUE if JNI headers and libraries were found. | ||
76 | 9 | # JAVA_AWT_LIBRARY = the path to the jawt library | ||
77 | 10 | # JAVA_JVM_LIBRARY = the path to the jvm library | ||
78 | 11 | # JAVA_INCLUDE_PATH = the include path to jni.h | ||
79 | 12 | # JAVA_INCLUDE_PATH2 = the include path to jni_md.h | ||
80 | 13 | # JAVA_AWT_INCLUDE_PATH = the include path to jawt.h | ||
81 | 14 | # | ||
82 | 15 | |||
83 | 16 | #============================================================================= | ||
84 | 17 | # Copyright 2001-2009 Kitware, Inc. | ||
85 | 18 | # | ||
86 | 19 | # Distributed under the OSI-approved BSD License (the "License"); | ||
87 | 20 | # see accompanying file Copyright.txt for details. | ||
88 | 21 | # | ||
89 | 22 | # This software is distributed WITHOUT ANY WARRANTY; without even the | ||
90 | 23 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
91 | 24 | # See the License for more information. | ||
92 | 25 | #============================================================================= | ||
93 | 26 | # (To distribute this file outside of CMake, substitute the full | ||
94 | 27 | # License text for the above reference.) | ||
95 | 28 | |||
96 | 29 | # Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var} | ||
97 | 30 | MACRO(java_append_library_directories _var) | ||
98 | 31 | # Determine java arch-specific library subdir | ||
99 | 32 | # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk | ||
100 | 33 | # 1.6.0_18 + icedtea patches. However, it would be much better to base the | ||
101 | 34 | # guess on the first part of the GNU config.guess platform triplet. | ||
102 | 35 | IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") | ||
103 | 36 | SET(_java_libarch "amd64") | ||
104 | 37 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") | ||
105 | 38 | SET(_java_libarch "i386") | ||
106 | 39 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha") | ||
107 | 40 | SET(_java_libarch "alpha") | ||
108 | 41 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") | ||
109 | 42 | # Subdir is "arm" for both big-endian (arm) and little-endian (armel). | ||
110 | 43 | SET(_java_libarch "arm") | ||
111 | 44 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") | ||
112 | 45 | # mips* machines are bi-endian mostly so processor does not tell | ||
113 | 46 | # endianess of the underlying system. | ||
114 | 47 | SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb") | ||
115 | 48 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") | ||
116 | 49 | SET(_java_libarch "ppc64") | ||
117 | 50 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") | ||
118 | 51 | SET(_java_libarch "ppc") | ||
119 | 52 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc") | ||
120 | 53 | # Both flavours can run on the same processor | ||
121 | 54 | SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9") | ||
122 | 55 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)") | ||
123 | 56 | SET(_java_libarch "parisc" "parisc64") | ||
124 | 57 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390") | ||
125 | 58 | # s390 binaries can run on s390x machines | ||
126 | 59 | SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x") | ||
127 | 60 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh") | ||
128 | 61 | SET(_java_libarch "sh") | ||
129 | 62 | ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") | ||
130 | 63 | SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}") | ||
131 | 64 | ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") | ||
132 | 65 | |||
133 | 66 | # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or | ||
134 | 67 | # system is non-Linux (where the code above has not been well tested) | ||
135 | 68 | IF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux") | ||
136 | 69 | LIST(APPEND _java_libarch "i386" "amd64" "ppc") | ||
137 | 70 | ENDIF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux") | ||
138 | 71 | |||
139 | 72 | # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer | ||
140 | 73 | # current value to a hardcoded list. Remove possible duplicates. | ||
141 | 74 | LIST(REMOVE_DUPLICATES _java_libarch) | ||
142 | 75 | |||
143 | 76 | FOREACH(_path ${ARGN}) | ||
144 | 77 | IF(_path MATCHES "{libarch}") | ||
145 | 78 | FOREACH(_libarch ${_java_libarch}) | ||
146 | 79 | STRING(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}") | ||
147 | 80 | LIST(APPEND ${_var} "${_newpath}") | ||
148 | 81 | ENDFOREACH(_libarch) | ||
149 | 82 | ELSE(_path MATCHES "{libarch}") | ||
150 | 83 | LIST(APPEND ${_var} "${_path}") | ||
151 | 84 | ENDIF(_path MATCHES "{libarch}") | ||
152 | 85 | ENDFOREACH(_path) | ||
153 | 86 | ENDMACRO(java_append_library_directories) | ||
154 | 87 | |||
155 | 88 | GET_FILENAME_COMPONENT(java_install_version | ||
156 | 89 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME) | ||
157 | 90 | |||
158 | 91 | SET(JAVA_AWT_LIBRARY_DIRECTORIES | ||
159 | 92 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib" | ||
160 | 93 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib" | ||
161 | 94 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib" | ||
162 | 95 | ) | ||
163 | 96 | |||
164 | 97 | FILE(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME) | ||
165 | 98 | |||
166 | 99 | JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES | ||
167 | 100 | ${_JAVA_HOME}/jre/lib/{libarch} | ||
168 | 101 | ${_JAVA_HOME}/jre/lib | ||
169 | 102 | ${_JAVA_HOME}/lib | ||
170 | 103 | ${_JAVA_HOME} | ||
171 | 104 | /usr/lib/jvm/java-6-openjdk/jre/lib | ||
172 | 105 | /usr/lib/jvm/java-6-openjdk-i386/jre/lib | ||
173 | 106 | /usr/lib/jvm/java-6-openjdk-amd64/jre/lib | ||
174 | 107 | /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch} | ||
175 | 108 | /usr/lib/jvm/java-6-openjdk-i386/jre/lib/{libarch} | ||
176 | 109 | /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/{libarch} | ||
177 | 110 | /usr/lib | ||
178 | 111 | /usr/local/lib | ||
179 | 112 | /usr/lib/jvm/java/lib | ||
180 | 113 | /usr/lib/java/jre/lib/{libarch} | ||
181 | 114 | /usr/local/lib/java/jre/lib/{libarch} | ||
182 | 115 | /usr/local/share/java/jre/lib/{libarch} | ||
183 | 116 | /usr/lib/j2sdk1.4-sun/jre/lib/{libarch} | ||
184 | 117 | /usr/lib/j2sdk1.5-sun/jre/lib/{libarch} | ||
185 | 118 | /opt/sun-jdk-1.5.0.04/jre/lib/{libarch} | ||
186 | 119 | /usr/lib/jvm/java-6-sun/jre/lib/{libarch} | ||
187 | 120 | /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch} | ||
188 | 121 | /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch} # can this one be removed according to #8821 ? Alex | ||
189 | 122 | /usr/lib/jvm/java-openjdk/jre/lib/{libarch} | ||
190 | 123 | # Debian specific paths for default JVM | ||
191 | 124 | /usr/lib/jvm/default-java/jre/lib/{libarch} | ||
192 | 125 | /usr/lib/jvm/default-java/jre/lib | ||
193 | 126 | /usr/lib/jvm/default-java/lib | ||
194 | 127 | ) | ||
195 | 128 | |||
196 | 129 | SET(JAVA_JVM_LIBRARY_DIRECTORIES) | ||
197 | 130 | FOREACH(dir ${JAVA_AWT_LIBRARY_DIRECTORIES}) | ||
198 | 131 | SET(JAVA_JVM_LIBRARY_DIRECTORIES | ||
199 | 132 | ${JAVA_JVM_LIBRARY_DIRECTORIES} | ||
200 | 133 | "${dir}" | ||
201 | 134 | "${dir}/client" | ||
202 | 135 | "${dir}/server" | ||
203 | 136 | ) | ||
204 | 137 | ENDFOREACH(dir) | ||
205 | 138 | |||
206 | 139 | |||
207 | 140 | SET(JAVA_AWT_INCLUDE_DIRECTORIES | ||
208 | 141 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include" | ||
209 | 142 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include" | ||
210 | 143 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include" | ||
211 | 144 | ${_JAVA_HOME}/include | ||
212 | 145 | /usr/lib/jvm/java-6-openjdk/include | ||
213 | 146 | /usr/lib/jvm/java-6-openjdk-amd64/include | ||
214 | 147 | /usr/lib/jvm/java-6-openjdk-i386/include | ||
215 | 148 | /usr/include | ||
216 | 149 | /usr/local/include | ||
217 | 150 | /usr/lib/java/include | ||
218 | 151 | /usr/local/lib/java/include | ||
219 | 152 | /usr/lib/jvm/java/include | ||
220 | 153 | /usr/lib/jvm/java-6-sun/include | ||
221 | 154 | /usr/lib/jvm/java-1.5.0-sun/include | ||
222 | 155 | /usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex | ||
223 | 156 | /usr/lib/jvm/java-6-openjdk/include | ||
224 | 157 | /usr/local/share/java/include | ||
225 | 158 | /usr/lib/j2sdk1.4-sun/include | ||
226 | 159 | /usr/lib/j2sdk1.5-sun/include | ||
227 | 160 | /opt/sun-jdk-1.5.0.04/include | ||
228 | 161 | # Debian specific path for default JVM | ||
229 | 162 | /usr/lib/jvm/default-java/include | ||
230 | 163 | ) | ||
231 | 164 | |||
232 | 165 | FOREACH(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}") | ||
233 | 166 | GET_FILENAME_COMPONENT(jpath "${JAVA_PROG}" PATH) | ||
234 | 167 | FOREACH(JAVA_INC_PATH ../include ../java/include ../share/java/include) | ||
235 | 168 | IF(EXISTS ${jpath}/${JAVA_INC_PATH}) | ||
236 | 169 | SET(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}") | ||
237 | 170 | ENDIF(EXISTS ${jpath}/${JAVA_INC_PATH}) | ||
238 | 171 | ENDFOREACH(JAVA_INC_PATH) | ||
239 | 172 | FOREACH(JAVA_LIB_PATH | ||
240 | 173 | ../lib ../jre/lib ../jre/lib/i386 | ||
241 | 174 | ../java/lib ../java/jre/lib ../java/jre/lib/i386 | ||
242 | 175 | ../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386) | ||
243 | 176 | IF(EXISTS ${jpath}/${JAVA_LIB_PATH}) | ||
244 | 177 | SET(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}") | ||
245 | 178 | ENDIF(EXISTS ${jpath}/${JAVA_LIB_PATH}) | ||
246 | 179 | ENDFOREACH(JAVA_LIB_PATH) | ||
247 | 180 | ENDFOREACH(JAVA_PROG) | ||
248 | 181 | |||
249 | 182 | IF(APPLE) | ||
250 | 183 | IF(EXISTS ~/Library/Frameworks/JavaVM.framework) | ||
251 | 184 | SET(JAVA_HAVE_FRAMEWORK 1) | ||
252 | 185 | ENDIF(EXISTS ~/Library/Frameworks/JavaVM.framework) | ||
253 | 186 | IF(EXISTS /Library/Frameworks/JavaVM.framework) | ||
254 | 187 | SET(JAVA_HAVE_FRAMEWORK 1) | ||
255 | 188 | ENDIF(EXISTS /Library/Frameworks/JavaVM.framework) | ||
256 | 189 | IF(EXISTS /System/Library/Frameworks/JavaVM.framework) | ||
257 | 190 | SET(JAVA_HAVE_FRAMEWORK 1) | ||
258 | 191 | ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework) | ||
259 | 192 | |||
260 | 193 | IF(JAVA_HAVE_FRAMEWORK) | ||
261 | 194 | IF(NOT JAVA_AWT_LIBRARY) | ||
262 | 195 | SET (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE) | ||
263 | 196 | ENDIF(NOT JAVA_AWT_LIBRARY) | ||
264 | 197 | |||
265 | 198 | IF(NOT JAVA_JVM_LIBRARY) | ||
266 | 199 | SET (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE) | ||
267 | 200 | ENDIF(NOT JAVA_JVM_LIBRARY) | ||
268 | 201 | |||
269 | 202 | IF(NOT JAVA_AWT_INCLUDE_PATH) | ||
270 | 203 | IF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h) | ||
271 | 204 | SET (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE) | ||
272 | 205 | ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h) | ||
273 | 206 | ENDIF(NOT JAVA_AWT_INCLUDE_PATH) | ||
274 | 207 | |||
275 | 208 | # If using "-framework JavaVM", prefer its headers *before* the others in | ||
276 | 209 | # JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here) | ||
277 | 210 | # | ||
278 | 211 | SET(JAVA_AWT_INCLUDE_DIRECTORIES | ||
279 | 212 | ~/Library/Frameworks/JavaVM.framework/Headers | ||
280 | 213 | /Library/Frameworks/JavaVM.framework/Headers | ||
281 | 214 | /System/Library/Frameworks/JavaVM.framework/Headers | ||
282 | 215 | ${JAVA_AWT_INCLUDE_DIRECTORIES} | ||
283 | 216 | ) | ||
284 | 217 | ENDIF(JAVA_HAVE_FRAMEWORK) | ||
285 | 218 | ELSE(APPLE) | ||
286 | 219 | FIND_LIBRARY(JAVA_AWT_LIBRARY jawt | ||
287 | 220 | PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES} | ||
288 | 221 | ) | ||
289 | 222 | FIND_LIBRARY(JAVA_JVM_LIBRARY NAMES jvm JavaVM java | ||
290 | 223 | PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES} | ||
291 | 224 | ) | ||
292 | 225 | ENDIF(APPLE) | ||
293 | 226 | |||
294 | 227 | # add in the include path | ||
295 | 228 | FIND_PATH(JAVA_INCLUDE_PATH jni.h | ||
296 | 229 | ${JAVA_AWT_INCLUDE_DIRECTORIES} | ||
297 | 230 | ) | ||
298 | 231 | |||
299 | 232 | FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h | ||
300 | 233 | ${JAVA_INCLUDE_PATH} | ||
301 | 234 | ${JAVA_INCLUDE_PATH}/win32 | ||
302 | 235 | ${JAVA_INCLUDE_PATH}/linux | ||
303 | 236 | ${JAVA_INCLUDE_PATH}/freebsd | ||
304 | 237 | ${JAVA_INCLUDE_PATH}/solaris | ||
305 | 238 | ) | ||
306 | 239 | |||
307 | 240 | FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h | ||
308 | 241 | ${JAVA_INCLUDE_PATH} | ||
309 | 242 | ) | ||
310 | 243 | |||
311 | 244 | |||
312 | 245 | IF (APPLE) | ||
313 | 246 | # On Mac, the java headers files are broken symlinks if the Apple Developer Tools for Java are not installed | ||
314 | 247 | EXECUTE_PROCESS(COMMAND cat ${JAVA_INCLUDE_PATH}/jni.h | ||
315 | 248 | OUTPUT_QUIET | ||
316 | 249 | ERROR_QUIET | ||
317 | 250 | RESULT_VARIABLE SYMLINK_CHECK_RESULT_VARIABLE) | ||
318 | 251 | IF (SYMLINK_CHECK_RESULT_VARIABLE GREATER 0) | ||
319 | 252 | SET (JAVA_INCLUDE_PATH "JAVA_INCLUDE_PATH-NOTFOUND") | ||
320 | 253 | SET (JAVA_INCLUDE_PATH2 "JAVA_INCLUDE_PATH2-NOTFOUND") | ||
321 | 254 | SET (JAVA_AWT_INCLUDE_PATH "JAVA_AWT_INCLUDE_PATH-NOTFOUND") | ||
322 | 255 | ENDIF() | ||
323 | 256 | ENDIF (APPLE) | ||
324 | 257 | |||
325 | 258 | |||
326 | 259 | #INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") | ||
327 | 260 | #FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY | ||
328 | 261 | # JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) | ||
329 | 262 | |||
330 | 263 | MARK_AS_ADVANCED( | ||
331 | 264 | JAVA_AWT_LIBRARY | ||
332 | 265 | JAVA_JVM_LIBRARY | ||
333 | 266 | JAVA_AWT_INCLUDE_PATH | ||
334 | 267 | JAVA_INCLUDE_PATH | ||
335 | 268 | JAVA_INCLUDE_PATH2 | ||
336 | 269 | ) | ||
337 | 270 | |||
338 | 271 | IF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH) | ||
339 | 272 | SET(JNI_FOUND 1) | ||
340 | 273 | SET(JNI_LIBRARIES | ||
341 | 274 | ${JAVA_AWT_LIBRARY} | ||
342 | 275 | ${JAVA_JVM_LIBRARY} | ||
343 | 276 | ) | ||
344 | 277 | SET(JNI_INCLUDE_DIRS | ||
345 | 278 | ${JAVA_INCLUDE_PATH} | ||
346 | 279 | ${JAVA_INCLUDE_PATH2} | ||
347 | 280 | ${JAVA_AWT_INCLUDE_PATH} | ||
348 | 281 | ) | ||
349 | 282 | ELSE (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH) | ||
350 | 283 | SET(JNI_FOUND 0) | ||
351 | 284 | SET(JNI_LIBRARIES "") | ||
352 | 285 | SET(JNI_INCLUDE_DIRS "") | ||
353 | 286 | ENDIF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH) | ||
354 | 0 | 287 | ||
355 | === added directory 'cmake_modules/Windows' | |||
356 | === added file 'cmake_modules/Windows/FindJNI.cmake' | |||
357 | --- cmake_modules/Windows/FindJNI.cmake 1970-01-01 00:00:00 +0000 | |||
358 | +++ cmake_modules/Windows/FindJNI.cmake 2012-09-28 12:58:20 +0000 | |||
359 | @@ -0,0 +1,37 @@ | |||
360 | 1 | # Copyright 2010 The FLWOR Foundation. | ||
361 | 2 | # | ||
362 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
363 | 4 | # you may not use this file except in compliance with the License. | ||
364 | 5 | # You may obtain a copy of the License at | ||
365 | 6 | # | ||
366 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
367 | 8 | # | ||
368 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
369 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
370 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
371 | 12 | # See the License for the specific language governing permissions and | ||
372 | 13 | # limitations under the License. | ||
373 | 14 | |||
374 | 15 | # - Try to find the JNI libraries on Windows | ||
375 | 16 | # | ||
376 | 17 | # See the FindJNI.cmake module shipped with Zorba for more information. | ||
377 | 18 | |||
378 | 19 | FIND_PACKAGE_WIN32_NO_PROXY (JNI JNI_FOUND) | ||
379 | 20 | |||
380 | 21 | IF (JNI_FOUND) | ||
381 | 22 | |||
382 | 23 | STRING (REPLACE "/jvm.lib" "" JAVA_JVM_LIBRARY_PATH "${JAVA_JVM_LIBRARY}") | ||
383 | 24 | |||
384 | 25 | IF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client") | ||
385 | 26 | SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client") | ||
386 | 27 | # find the needed DLL's | ||
387 | 28 | FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm") | ||
388 | 29 | ELSEIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server") | ||
389 | 30 | SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server") | ||
390 | 31 | # find the needed DLL's | ||
391 | 32 | FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm") | ||
392 | 33 | ELSE (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client") | ||
393 | 34 | MESSAGE (WARNING "Could not find the jvm.dll for the JVM library: ${JAVA_JVM_LIBRARY}. Please extend this module to find the jvm.dll somewhere in your JVM directory or make sure that jvm.dll is in the PATH.") | ||
394 | 35 | ENDIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client") | ||
395 | 36 | |||
396 | 37 | ENDIF (JNI_FOUND) | ||
397 | 0 | 38 | ||
398 | === added directory 'src' | |||
399 | === renamed directory 'src' => 'src.moved' | |||
400 | === added file 'src/CMakeLists.txt' | |||
401 | --- src/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
402 | +++ src/CMakeLists.txt 2012-09-28 12:58:20 +0000 | |||
403 | @@ -0,0 +1,20 @@ | |||
404 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
405 | 2 | # | ||
406 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
407 | 4 | # you may not use this file except in compliance with the License. | ||
408 | 5 | # You may obtain a copy of the License at | ||
409 | 6 | # | ||
410 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
411 | 8 | # | ||
412 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
413 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
414 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
415 | 12 | # See the License for the specific language governing permissions and | ||
416 | 13 | # limitations under the License. | ||
417 | 14 | |||
418 | 15 | # all external module libraries are generated in the directory | ||
419 | 16 | # of the corresponding .xq file | ||
420 | 17 | MESSAGE(STATUS "Add com") | ||
421 | 18 | ADD_SUBDIRECTORY(com) | ||
422 | 19 | |||
423 | 20 | MESSAGE(STATUS "End modules") | ||
424 | 0 | 21 | ||
425 | === added directory 'src/com' | |||
426 | === added file 'src/com/CMakeLists.txt' | |||
427 | --- src/com/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
428 | +++ src/com/CMakeLists.txt 2012-09-28 12:58:20 +0000 | |||
429 | @@ -0,0 +1,17 @@ | |||
430 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
431 | 2 | # | ||
432 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
433 | 4 | # you may not use this file except in compliance with the License. | ||
434 | 5 | # You may obtain a copy of the License at | ||
435 | 6 | # | ||
436 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
437 | 8 | # | ||
438 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
439 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
440 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
441 | 12 | # See the License for the specific language governing permissions and | ||
442 | 13 | # limitations under the License. | ||
443 | 14 | |||
444 | 15 | # all external module libraries are generated in the directory | ||
445 | 16 | # of the corresponding .xq file | ||
446 | 17 | ADD_SUBDIRECTORY(zorba-xquery) | ||
447 | 0 | 18 | ||
448 | === added directory 'src/com/zorba-xquery' | |||
449 | === added file 'src/com/zorba-xquery/CMakeLists.txt' | |||
450 | --- src/com/zorba-xquery/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
451 | +++ src/com/zorba-xquery/CMakeLists.txt 2012-09-28 12:58:20 +0000 | |||
452 | @@ -0,0 +1,17 @@ | |||
453 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
454 | 2 | # | ||
455 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
456 | 4 | # you may not use this file except in compliance with the License. | ||
457 | 5 | # You may obtain a copy of the License at | ||
458 | 6 | # | ||
459 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
460 | 8 | # | ||
461 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
462 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
463 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
464 | 12 | # See the License for the specific language governing permissions and | ||
465 | 13 | # limitations under the License. | ||
466 | 14 | |||
467 | 15 | # all external module libraries are generated in the directory | ||
468 | 16 | # of the corresponding .xq file | ||
469 | 17 | ADD_SUBDIRECTORY(www) | ||
470 | 0 | 18 | ||
471 | === added directory 'src/com/zorba-xquery/www' | |||
472 | === added file 'src/com/zorba-xquery/www/CMakeLists.txt' | |||
473 | --- src/com/zorba-xquery/www/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
474 | +++ src/com/zorba-xquery/www/CMakeLists.txt 2012-09-28 12:58:20 +0000 | |||
475 | @@ -0,0 +1,17 @@ | |||
476 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
477 | 2 | # | ||
478 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
479 | 4 | # you may not use this file except in compliance with the License. | ||
480 | 5 | # You may obtain a copy of the License at | ||
481 | 6 | # | ||
482 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
483 | 8 | # | ||
484 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
485 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
486 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
487 | 12 | # See the License for the specific language governing permissions and | ||
488 | 13 | # limitations under the License. | ||
489 | 14 | |||
490 | 15 | # all external module libraries are generated in the directory | ||
491 | 16 | # of the corresponding .xq file | ||
492 | 17 | ADD_SUBDIRECTORY(modules) | ||
493 | 0 | 18 | ||
494 | === added directory 'src/com/zorba-xquery/www/modules' | |||
495 | === added file 'src/com/zorba-xquery/www/modules/CMakeLists.txt' | |||
496 | --- src/com/zorba-xquery/www/modules/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
497 | +++ src/com/zorba-xquery/www/modules/CMakeLists.txt 2012-09-28 12:58:20 +0000 | |||
498 | @@ -0,0 +1,105 @@ | |||
499 | 1 | # Copyright 2006-2010 The FLWOR Foundation. | ||
500 | 2 | # | ||
501 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
502 | 4 | # you may not use this file except in compliance with the License. | ||
503 | 5 | # You may obtain a copy of the License at | ||
504 | 6 | # | ||
505 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
506 | 8 | # | ||
507 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
508 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
509 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
510 | 12 | # See the License for the specific language governing permissions and | ||
511 | 13 | # limitations under the License. | ||
512 | 14 | |||
513 | 15 | IF (NOT DEFINED XSL_FOP_HOME) | ||
514 | 16 | IF (DEFINED ENV{XSL_FOP_HOME}) | ||
515 | 17 | SET(XSL_FOP_HOME $ENV{XSL_FOP_HOME}) | ||
516 | 18 | ENDIF (DEFINED ENV{XSL_FOP_HOME}) | ||
517 | 19 | ENDIF (NOT DEFINED XSL_FOP_HOME) | ||
518 | 20 | |||
519 | 21 | IF (NOT DEFINED XSL_FOP_HOME) | ||
520 | 22 | IF (WIN32) | ||
521 | 23 | SET (XSL_FOP_HOME "C:\\dev\\libraries\\fop-1.0 C:\\dev\\libraries\\fop-1.0\\lib C:\\dev\\libraries\\fop-1.0\\build") | ||
522 | 24 | ELSE (WIN32) | ||
523 | 25 | SET (XSL_FOP_HOME /usr/share/java/ /usr/share/java/fop/ /opt/local/share/java/fop/1.0 /opt/local/share/java/fop/1.0 ${Java_LIBRARIES}) | ||
524 | 26 | ENDIF (WIN32) | ||
525 | 27 | MESSAGE (STATUS "XSL_FOP_HOME not defined, trying defaults: ${XSL_FOP_HOME}") | ||
526 | 28 | ENDIF (NOT DEFINED XSL_FOP_HOME) | ||
527 | 29 | |||
528 | 30 | STRING(REGEX REPLACE "\\\\" "/" XSL_FOP_HOME "${XSL_FOP_HOME}") | ||
529 | 31 | |||
530 | 32 | MESSAGE (STATUS "XSL-FOP HOME: ${XSL_FOP_HOME}") | ||
531 | 33 | ZORBA_FIND_JAR ( FOP_JAR NAMES fop | ||
532 | 34 | PATHS ${XSL_FOP_HOME} PATH_SUFFIXES build) | ||
533 | 35 | ZORBA_FIND_JAR ( FOP_D1_JAR NAMES avalon-framework | ||
534 | 36 | PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib ) | ||
535 | 37 | ZORBA_FIND_JAR ( FOP_D2_JAR NAMES batik-all | ||
536 | 38 | PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib ) | ||
537 | 39 | ZORBA_FIND_JAR ( FOP_D3_JAR NAMES commons-io | ||
538 | 40 | PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib ) | ||
539 | 41 | ZORBA_FIND_JAR ( FOP_D4_JAR NAMES commons-logging | ||
540 | 42 | PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib ) | ||
541 | 43 | ZORBA_FIND_JAR ( FOP_D5_JAR NAMES serializer | ||
542 | 44 | PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib ) | ||
543 | 45 | ZORBA_FIND_JAR ( FOP_D6_JAR NAMES xalan xalan2 | ||
544 | 46 | PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib ) | ||
545 | 47 | ZORBA_FIND_JAR ( FOP_D7_JAR NAMES xmlgraphics-commons | ||
546 | 48 | PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib ) | ||
547 | 49 | |||
548 | 50 | # Multiple "EXISTS" clauses can't be used in a single IF() command; | ||
549 | 51 | # looks like a bug in cmake. | ||
550 | 52 | SET(ALL_FOP FALSE) | ||
551 | 53 | IF ( EXISTS ${FOP_JAR} ) | ||
552 | 54 | IF ( EXISTS ${FOP_D1_JAR} ) | ||
553 | 55 | IF ( EXISTS ${FOP_D2_JAR} ) | ||
554 | 56 | IF ( EXISTS ${FOP_D3_JAR} ) | ||
555 | 57 | IF ( EXISTS ${FOP_D4_JAR} ) | ||
556 | 58 | IF ( EXISTS ${FOP_D5_JAR} ) | ||
557 | 59 | IF ( EXISTS ${FOP_D6_JAR} ) | ||
558 | 60 | IF ( EXISTS ${FOP_D7_JAR} ) | ||
559 | 61 | SET(ALL_FOP TRUE) | ||
560 | 62 | ENDIF ( EXISTS ${FOP_D7_JAR} ) | ||
561 | 63 | ENDIF ( EXISTS ${FOP_D6_JAR} ) | ||
562 | 64 | ENDIF ( EXISTS ${FOP_D5_JAR} ) | ||
563 | 65 | ENDIF ( EXISTS ${FOP_D4_JAR} ) | ||
564 | 66 | ENDIF ( EXISTS ${FOP_D3_JAR} ) | ||
565 | 67 | ENDIF ( EXISTS ${FOP_D2_JAR} ) | ||
566 | 68 | ENDIF ( EXISTS ${FOP_D1_JAR} ) | ||
567 | 69 | ENDIF ( EXISTS ${FOP_JAR} ) | ||
568 | 70 | |||
569 | 71 | IF ( ALL_FOP ) | ||
570 | 72 | MESSAGE(STATUS "FOP Libraries Found.") | ||
571 | 73 | INCLUDE (CMakeJavaInformation ) | ||
572 | 74 | EXECUTE_PROCESS ( | ||
573 | 75 | COMMAND ${JAVA_RUNTIME} -version | ||
574 | 76 | RESULT_VARIABLE JAVA_VERSION | ||
575 | 77 | OUTPUT_QUIET | ||
576 | 78 | ERROR_QUIET | ||
577 | 79 | ) | ||
578 | 80 | |||
579 | 81 | INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) | ||
580 | 82 | INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH}) | ||
581 | 83 | DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/xsl-fo" | ||
582 | 84 | VERSION 1.0 FILE "xsl-fo.xq" | ||
583 | 85 | LINK_LIBRARIES "${JAVA_JVM_LIBRARY}" ${zorba_util-jvm_module_LIBRARIES}) | ||
584 | 86 | |||
585 | 87 | DECLARE_ZORBA_JAR(FILE ${FOP_JAR} EXTERNAL) | ||
586 | 88 | DECLARE_ZORBA_JAR(FILE ${FOP_D1_JAR} EXTERNAL) | ||
587 | 89 | DECLARE_ZORBA_JAR(FILE ${FOP_D2_JAR} EXTERNAL) | ||
588 | 90 | DECLARE_ZORBA_JAR(FILE ${FOP_D3_JAR} EXTERNAL) | ||
589 | 91 | DECLARE_ZORBA_JAR(FILE ${FOP_D4_JAR} EXTERNAL) | ||
590 | 92 | DECLARE_ZORBA_JAR(FILE ${FOP_D5_JAR} EXTERNAL) | ||
591 | 93 | DECLARE_ZORBA_JAR(FILE ${FOP_D6_JAR} EXTERNAL) | ||
592 | 94 | DECLARE_ZORBA_JAR(FILE ${FOP_D7_JAR} EXTERNAL) | ||
593 | 95 | |||
594 | 96 | ADD_TEST_DIRECTORY("${PROJECT_SOURCE_DIR}/test") | ||
595 | 97 | |||
596 | 98 | ELSE ( ALL_FOP ) | ||
597 | 99 | MESSAGE (STATUS "fop.jar and/or all its dependecies (avalon-framework.jar, batik-all.jar, commons-io.jar, commons-logging.jar, serializer.jar, xalan2.jar, xmlgraphics-commons.jar) not found skiping data-formating module") | ||
598 | 100 | MESSAGE ( STATUS " fop: " ${FOP_JAR} "\n avalon: " ${FOP_D1_JAR} | ||
599 | 101 | "\n batik: " ${FOP_D2_JAR} "\n io: " ${FOP_D3_JAR} | ||
600 | 102 | "\n logging: " ${FOP_D4_JAR} "\n serializer: " ${FOP_D5_JAR} " " | ||
601 | 103 | "\n xalan: " ${FOP_D6_JAR} "\n xmlgraphics: " ${FOP_D7_JAR} ) | ||
602 | 104 | ENDIF ( ALL_FOP ) | ||
603 | 105 | |||
604 | 0 | 106 | ||
605 | === added file 'src/com/zorba-xquery/www/modules/xsl-fo.xq' | |||
606 | --- src/com/zorba-xquery/www/modules/xsl-fo.xq 1970-01-01 00:00:00 +0000 | |||
607 | +++ src/com/zorba-xquery/www/modules/xsl-fo.xq 2012-09-28 12:58:20 +0000 | |||
608 | @@ -0,0 +1,161 @@ | |||
609 | 1 | xquery version "3.0"; | ||
610 | 2 | |||
611 | 3 | (: | ||
612 | 4 | : Copyright 2006-2009 The FLWOR Foundation. | ||
613 | 5 | : | ||
614 | 6 | : Licensed under the Apache License, Version 2.0 (the "License"); | ||
615 | 7 | : you may not use this file except in compliance with the License. | ||
616 | 8 | : You may obtain a copy of the License at | ||
617 | 9 | : | ||
618 | 10 | : http://www.apache.org/licenses/LICENSE-2.0 | ||
619 | 11 | : | ||
620 | 12 | : Unless required by applicable law or agreed to in writing, software | ||
621 | 13 | : distributed under the License is distributed on an "AS IS" BASIS, | ||
622 | 14 | : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
623 | 15 | : See the License for the specific language governing permissions and | ||
624 | 16 | : limitations under the License. | ||
625 | 17 | :) | ||
626 | 18 | (:~ | ||
627 | 19 | : | ||
628 | 20 | : This module converts <a href="http://www.w3schools.com/xslfo/default.asp">XSL-FO</a> documents | ||
629 | 21 | : to various formats such as PDF, EPS, PCL, AFP, Text, PNG, Postscript, RTF, and TIFF. | ||
630 | 22 | : For instance, the following example converts a simple XSL-FO document to PDF: | ||
631 | 23 | : <br /> | ||
632 | 24 | : <pre class="ace-static" ace-mode="xquery"><![CDATA[import module namespace fop = "http://www.zorba-xquery.com/modules/xsl-fo"; | ||
633 | 25 | : import module namespace file = "http://expath.org/ns/file"; | ||
634 | 26 | : | ||
635 | 27 | : declare namespace fo = "http://www.w3.org/1999/XSL/Format"; | ||
636 | 28 | : | ||
637 | 29 | : let $xsl-fo := <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> | ||
638 | 30 | : <fo:layout-master-set> | ||
639 | 31 | : <fo:simple-page-master master-name="my-page"> | ||
640 | 32 | : <fo:region-body margin="1in"/> | ||
641 | 33 | : </fo:simple-page-master> | ||
642 | 34 | : </fo:layout-master-set> | ||
643 | 35 | : | ||
644 | 36 | : <fo:page-sequence master-reference="my-page"> | ||
645 | 37 | : <fo:flow flow-name="xsl-region-body"> | ||
646 | 38 | : <fo:block>Hello, world!</fo:block> | ||
647 | 39 | : </fo:flow> | ||
648 | 40 | : </fo:page-sequence> | ||
649 | 41 | : </fo:root> | ||
650 | 42 | : let $pdf := fop:generator($fop:PDF, $xsl-fo) | ||
651 | 43 | : return file:write-binary("simple.pdf", $pdf)]]></pre> | ||
652 | 44 | : <br /> | ||
653 | 45 | : This module uses Apache-FOP to generate content from an XSL-FO document. | ||
654 | 46 | : See <a href="http://xmlgraphics.apache.org/fop/">the Apache FOP documentation</a> for further information. | ||
655 | 47 | : <br /> | ||
656 | 48 | : <br /> | ||
657 | 49 | : <b>Note for Windows users</b>: On Windows, this module won't work out of the box, since | ||
658 | 50 | : this module uses Java. But the Java VM dll is not in the system path by default. To make | ||
659 | 51 | : this module work, you need to add the directory where the jvm.dll is located to the | ||
660 | 52 | : system path. This dll is located at JRE_DIR\bin\client. On a standard installation, this would | ||
661 | 53 | : be something a path like "C:\Program Files\Java\jre6\bin\client". | ||
662 | 54 | : | ||
663 | 55 | : @author Markus Pilman | ||
664 | 56 | : @see http://xmlgraphics.apache.org/fop/ | ||
665 | 57 | : @library <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">JDK - Java Development Kit</a> | ||
666 | 58 | : @project Zorba/Data Formatting/XSL-FO | ||
667 | 59 | :) | ||
668 | 60 | module namespace xsl-fo = "http://www.zorba-xquery.com/modules/xsl-fo"; | ||
669 | 61 | |||
670 | 62 | import module namespace util-jvm = "http://www.zorba-xquery.com/modules/util-jvm"; | ||
671 | 63 | |||
672 | 64 | declare namespace err = "http://www.w3.org/2005/xqt-errors"; | ||
673 | 65 | |||
674 | 66 | declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; | ||
675 | 67 | declare option ver:module-version "1.0"; | ||
676 | 68 | |||
677 | 69 | (:~ | ||
678 | 70 | : The mime type of IBMs AFP format (application/x-afp). | ||
679 | 71 | :) | ||
680 | 72 | declare variable $xsl-fo:AFP as xs:string := "application/x-afp"; | ||
681 | 73 | (:~ | ||
682 | 74 | : The mime type of the EPS format (application/postscript). | ||
683 | 75 | :) | ||
684 | 76 | declare variable $xsl-fo:EPS as xs:string := "application/postscript"; | ||
685 | 77 | (:~ | ||
686 | 78 | : The mime type of the PCL format (application/x-pcl). | ||
687 | 79 | :) | ||
688 | 80 | declare variable $xsl-fo:PCL as xs:string := "application/x-pcl"; | ||
689 | 81 | (:~ | ||
690 | 82 | : The mime type of the PDF format (application/pdf). | ||
691 | 83 | :) | ||
692 | 84 | declare variable $xsl-fo:PDF as xs:string := "application/pdf"; | ||
693 | 85 | (:~ | ||
694 | 86 | : The mime type for plain text files (text/plain). | ||
695 | 87 | :) | ||
696 | 88 | declare variable $xsl-fo:PLAIN_TEXT as xs:string := "text/plain"; | ||
697 | 89 | (:~ | ||
698 | 90 | : The mime type of the PNG format (image/png). | ||
699 | 91 | :) | ||
700 | 92 | declare variable $xsl-fo:PNG as xs:string := "image/png"; | ||
701 | 93 | (:~ | ||
702 | 94 | : The mime type of the postscript format (application/postscript). | ||
703 | 95 | :) | ||
704 | 96 | declare variable $xsl-fo:POSTSCRIPT as xs:string := "application/postscript"; | ||
705 | 97 | (:~ | ||
706 | 98 | : The mime type of the RTF format (application/rtf). | ||
707 | 99 | :) | ||
708 | 100 | declare variable $xsl-fo:RTF as xs:string := "application/rtf"; | ||
709 | 101 | (:~ | ||
710 | 102 | : The mime type of TIFF format (application/tiff). | ||
711 | 103 | :) | ||
712 | 104 | declare variable $xsl-fo:TIFF as xs:string := "image/tiff"; | ||
713 | 105 | |||
714 | 106 | (:~ | ||
715 | 107 | : Deprecated. This function has been deprecated, the JVM and it's classpath is handled diffrently.<br/> | ||
716 | 108 | : The generator function takes an XSL-FO document as input and generates output in the format given as input. | ||
717 | 109 | : The output format can be given as a MIME type - for example "application/pdf" - or one of the predefined | ||
718 | 110 | : variables can be used - like $xsl-fo:PDF. Please refer to the Apache FOP documentation for | ||
719 | 111 | : <a href="http://xmlgraphics.apache.org/fop/0.95/output.html">supported output formats</a>. | ||
720 | 112 | : | ||
721 | 113 | : Apache FOP does not support 100% of the XSL-FO standard. | ||
722 | 114 | : Please consult the <a href="http://xmlgraphics.apache.org/fop/">official documentation for further information</a>. | ||
723 | 115 | : | ||
724 | 116 | : @param $output-format The mime of the output format. | ||
725 | 117 | : @param $xsl-fo-document The XSL-FO document from which the output should be generated. <a href="http://www.w3schools.com/xslfo/xslfo_intro.asp">More information about XSL-FO documents.</a>. | ||
726 | 118 | : @param $classpath This parameter is not used, hence the deprecation of this function. | ||
727 | 119 | : @return The generated output document. | ||
728 | 120 | : @error xsl-fo:VM001 If zorba was unable to start the JVM. | ||
729 | 121 | : @error xsl-fo:JAVA-EXCEPTION If Apache FOP throws an exception - i.e. if the input format is not correct/supported. | ||
730 | 122 | : @deprecated | ||
731 | 123 | :) | ||
732 | 124 | declare function xsl-fo:generator($output-format as xs:string, $xsl-fo-document as node(), $classpath as xs:string+) as xs:base64Binary { | ||
733 | 125 | xsl-fo:generator-impl($output-format, $xsl-fo-document) | ||
734 | 126 | }; | ||
735 | 127 | |||
736 | 128 | (:~ | ||
737 | 129 | : The function behaves like <a href="#generator#3">generator#3</a>, but tries to find the needed Java libraries itself. | ||
738 | 130 | : <br /> | ||
739 | 131 | : On a Mac OS X computer, it should be sufficient to install Apache FOP via Mac Ports.<br /> | ||
740 | 132 | : On Ubuntu it should be sufficient to install the fop packages via apt-get.<br /> | ||
741 | 133 | : On Windows, the classpath needs to be set manually using <a href="#generator#3">generator#3</a>. | ||
742 | 134 | : <br /> | ||
743 | 135 | : This function tries to find the jar files via environment variables. The user can set the | ||
744 | 136 | : variable FOP_HOME to the root directory of an Apache FOP distribution. If you have all | ||
745 | 137 | : JAR files in the same directory, you can set the environment variable FOP_LIB_DIR to this | ||
746 | 138 | : directory. | ||
747 | 139 | : | ||
748 | 140 | : @param $output-format The mime of the output format, to tell Apache FOP which kind of document it should | ||
749 | 141 | : create. | ||
750 | 142 | : @param $xsl-fo-document The XSL-FO document from which the output should be generated. | ||
751 | 143 | : @return The generated output document. | ||
752 | 144 | : @error xsl-fo:VM001 If zorba was unable to start the JVM. | ||
753 | 145 | : @error xsl-fo:JAVA-EXCEPTION If Apache FOP throws an exception - i.e. if the input format is not correct/supported. | ||
754 | 146 | : @error xsl-fo:JAR-NOT-FOUND If a needed Java library could not be found. | ||
755 | 147 | :) | ||
756 | 148 | declare function xsl-fo:generator($output-format as xs:string, $xsl-fo-document as node()) as xs:base64Binary { | ||
757 | 149 | xsl-fo:generator-impl($output-format, $xsl-fo-document) | ||
758 | 150 | }; | ||
759 | 151 | |||
760 | 152 | |||
761 | 153 | (:~ | ||
762 | 154 | : Internal function used to format XSL-FO documents. | ||
763 | 155 | : | ||
764 | 156 | : @param $output-format The mime type of the output format. | ||
765 | 157 | : @param $xsl-fo-document The XSL-FO representation of the document. | ||
766 | 158 | : @return The base64Binary Representation of document. | ||
767 | 159 | :) | ||
768 | 160 | declare %private function xsl-fo:generator-impl($output-format as xs:string, $xsl-fo-document as node()) as xs:base64Binary external; | ||
769 | 161 | |||
770 | 0 | 162 | ||
771 | === added directory 'src/com/zorba-xquery/www/modules/xsl-fo.xq.src' | |||
772 | === added file 'src/com/zorba-xquery/www/modules/xsl-fo.xq.src/xslfo.cpp' | |||
773 | --- src/com/zorba-xquery/www/modules/xsl-fo.xq.src/xslfo.cpp 1970-01-01 00:00:00 +0000 | |||
774 | +++ src/com/zorba-xquery/www/modules/xsl-fo.xq.src/xslfo.cpp 2012-09-28 12:58:20 +0000 | |||
775 | @@ -0,0 +1,280 @@ | |||
776 | 1 | /* | ||
777 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
778 | 3 | * | ||
779 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
780 | 5 | * you may not use this file except in compliance with the License. | ||
781 | 6 | * You may obtain a copy of the License at | ||
782 | 7 | * | ||
783 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
784 | 9 | * | ||
785 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
786 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
787 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
788 | 13 | * See the License for the specific language governing permissions and | ||
789 | 14 | * limitations under the License. | ||
790 | 15 | */ | ||
791 | 16 | #include <sstream> | ||
792 | 17 | #include <iostream> | ||
793 | 18 | #include <cstdlib> | ||
794 | 19 | #include <list> | ||
795 | 20 | |||
796 | 21 | #include <zorba/base64.h> | ||
797 | 22 | #include <zorba/empty_sequence.h> | ||
798 | 23 | #include <zorba/diagnostic_list.h> | ||
799 | 24 | #include <zorba/function.h> | ||
800 | 25 | #include <zorba/external_module.h> | ||
801 | 26 | #include <zorba/user_exception.h> | ||
802 | 27 | #include <zorba/file.h> | ||
803 | 28 | #include <zorba/item_factory.h> | ||
804 | 29 | #include <zorba/serializer.h> | ||
805 | 30 | #include <zorba/singleton_item_sequence.h> | ||
806 | 31 | #include <zorba/vector_item_sequence.h> | ||
807 | 32 | #include <zorba/zorba.h> | ||
808 | 33 | |||
809 | 34 | #include "JavaVMSingleton.h" | ||
810 | 35 | |||
811 | 36 | #define XSL_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/xsl-fo" | ||
812 | 37 | |||
813 | 38 | class JavaException { | ||
814 | 39 | }; | ||
815 | 40 | |||
816 | 41 | #define CHECK_EXCEPTION(env) if ((lException = env->ExceptionOccurred())) throw JavaException() | ||
817 | 42 | |||
818 | 43 | namespace zorba { namespace xslfo { | ||
819 | 44 | |||
820 | 45 | class GeneratePDFFunction : public ContextualExternalFunction { | ||
821 | 46 | private: | ||
822 | 47 | const ExternalModule* theModule; | ||
823 | 48 | ItemFactory* theFactory; | ||
824 | 49 | public: | ||
825 | 50 | GeneratePDFFunction(const ExternalModule* aModule) : | ||
826 | 51 | theModule(aModule), theFactory(Zorba::getInstance(0)->getItemFactory()) {} | ||
827 | 52 | ~GeneratePDFFunction() {} | ||
828 | 53 | |||
829 | 54 | public: | ||
830 | 55 | virtual String getURI() const { return theModule->getURI(); } | ||
831 | 56 | |||
832 | 57 | virtual String getLocalName() const { return "generator-impl"; } | ||
833 | 58 | |||
834 | 59 | virtual ItemSequence_t | ||
835 | 60 | evaluate(const ExternalFunction::Arguments_t& args, | ||
836 | 61 | const zorba::StaticContext*, | ||
837 | 62 | const zorba::DynamicContext*) const; | ||
838 | 63 | }; | ||
839 | 64 | |||
840 | 65 | class XSLFOModule : public ExternalModule { | ||
841 | 66 | private: | ||
842 | 67 | ExternalFunction* generatePDF; | ||
843 | 68 | public: | ||
844 | 69 | XSLFOModule() : | ||
845 | 70 | generatePDF(new GeneratePDFFunction(this)) | ||
846 | 71 | {} | ||
847 | 72 | ~XSLFOModule() { | ||
848 | 73 | delete generatePDF; | ||
849 | 74 | } | ||
850 | 75 | |||
851 | 76 | virtual String getURI() const { return XSL_MODULE_NAMESPACE; } | ||
852 | 77 | |||
853 | 78 | virtual ExternalFunction* getExternalFunction(const String& localName); | ||
854 | 79 | |||
855 | 80 | virtual void destroy() { | ||
856 | 81 | delete this; | ||
857 | 82 | } | ||
858 | 83 | }; | ||
859 | 84 | |||
860 | 85 | ExternalFunction* XSLFOModule::getExternalFunction(const String& localName) { | ||
861 | 86 | if (localName == "generator-impl") { | ||
862 | 87 | return generatePDF; | ||
863 | 88 | } | ||
864 | 89 | return 0; | ||
865 | 90 | } | ||
866 | 91 | |||
867 | 92 | ItemSequence_t | ||
868 | 93 | GeneratePDFFunction::evaluate(const ExternalFunction::Arguments_t& args, | ||
869 | 94 | const zorba::StaticContext* aStaticContext, | ||
870 | 95 | const zorba::DynamicContext* aDynamincContext) const | ||
871 | 96 | { | ||
872 | 97 | Iterator_t lIter = args[0]->getIterator(); | ||
873 | 98 | lIter->open(); | ||
874 | 99 | Item outputFormat; | ||
875 | 100 | lIter->next(outputFormat); | ||
876 | 101 | lIter->close(); | ||
877 | 102 | jthrowable lException = 0; | ||
878 | 103 | static JNIEnv* env; | ||
879 | 104 | try { | ||
880 | 105 | env = zorba::jvm::JavaVMSingleton::getInstance(aStaticContext)->getEnv(); | ||
881 | 106 | jstring outFotmatString = env->NewStringUTF(outputFormat.getStringValue().c_str()); | ||
882 | 107 | // Local variables | ||
883 | 108 | std::ostringstream os; | ||
884 | 109 | Zorba_SerializerOptions_t lOptions; | ||
885 | 110 | Serializer_t lSerializer = Serializer::createSerializer(lOptions); | ||
886 | 111 | jclass fopFactoryClass; | ||
887 | 112 | jobject fopFactory; | ||
888 | 113 | jmethodID fopFactoryNewInstance; | ||
889 | 114 | jclass byteArrayOutputStreamClass; | ||
890 | 115 | jobject byteArrayOutputStream; | ||
891 | 116 | jobject fop; | ||
892 | 117 | jmethodID newFop; | ||
893 | 118 | jclass transformerFactoryClass; | ||
894 | 119 | jobject transformerFactory; | ||
895 | 120 | jobject transormer; | ||
896 | 121 | jclass stringReaderClass; | ||
897 | 122 | jobject stringReader; | ||
898 | 123 | jstring xmlUTF; | ||
899 | 124 | const char* xml; | ||
900 | 125 | std::string xmlString; | ||
901 | 126 | jclass streamSourceClass; | ||
902 | 127 | jobject streamSource; | ||
903 | 128 | jobject defaultHandler; | ||
904 | 129 | jclass saxResultClass; | ||
905 | 130 | jobject saxResult; | ||
906 | 131 | jboolean isCopy; | ||
907 | 132 | jbyteArray res; | ||
908 | 133 | Item base64; | ||
909 | 134 | String resStore; | ||
910 | 135 | jsize dataSize; | ||
911 | 136 | jbyte* dataElements; | ||
912 | 137 | |||
913 | 138 | Item item; | ||
914 | 139 | lIter = args[1]->getIterator(); | ||
915 | 140 | lIter->open(); | ||
916 | 141 | lIter->next(item); | ||
917 | 142 | lIter->close(); | ||
918 | 143 | // Searialize Item | ||
919 | 144 | SingletonItemSequence lSequence(item); | ||
920 | 145 | lSerializer->serialize(&lSequence, os); | ||
921 | 146 | xmlString = os.str(); | ||
922 | 147 | xml = xmlString.c_str(); | ||
923 | 148 | |||
924 | 149 | // Create an OutputStream | ||
925 | 150 | byteArrayOutputStreamClass = env->FindClass("java/io/ByteArrayOutputStream"); | ||
926 | 151 | CHECK_EXCEPTION(env); | ||
927 | 152 | byteArrayOutputStream = env->NewObject(byteArrayOutputStreamClass, | ||
928 | 153 | env->GetMethodID(byteArrayOutputStreamClass, "<init>", "()V")); | ||
929 | 154 | CHECK_EXCEPTION(env); | ||
930 | 155 | |||
931 | 156 | // Create a FopFactory instance | ||
932 | 157 | fopFactoryClass = env->FindClass("org/apache/fop/apps/FopFactory"); | ||
933 | 158 | CHECK_EXCEPTION(env); | ||
934 | 159 | fopFactoryNewInstance = env->GetStaticMethodID(fopFactoryClass, "newInstance", "()Lorg/apache/fop/apps/FopFactory;"); | ||
935 | 160 | CHECK_EXCEPTION(env); | ||
936 | 161 | fopFactory = env->CallStaticObjectMethod(fopFactoryClass, fopFactoryNewInstance); | ||
937 | 162 | CHECK_EXCEPTION(env); | ||
938 | 163 | |||
939 | 164 | // Create the Fop | ||
940 | 165 | newFop = env->GetMethodID(fopFactoryClass, "newFop", "(Ljava/lang/String;Ljava/io/OutputStream;)Lorg/apache/fop/apps/Fop;"); | ||
941 | 166 | CHECK_EXCEPTION(env); | ||
942 | 167 | fop = env->CallObjectMethod(fopFactory, | ||
943 | 168 | newFop, | ||
944 | 169 | outFotmatString, byteArrayOutputStream); | ||
945 | 170 | CHECK_EXCEPTION(env); | ||
946 | 171 | |||
947 | 172 | // Create the Transformer | ||
948 | 173 | transformerFactoryClass = env->FindClass("javax/xml/transform/TransformerFactory"); | ||
949 | 174 | CHECK_EXCEPTION(env); | ||
950 | 175 | transformerFactory = env->CallStaticObjectMethod(transformerFactoryClass, | ||
951 | 176 | env->GetStaticMethodID(transformerFactoryClass, "newInstance", "()Ljavax/xml/transform/TransformerFactory;")); | ||
952 | 177 | CHECK_EXCEPTION(env); | ||
953 | 178 | transormer = env->CallObjectMethod(transformerFactory, | ||
954 | 179 | env->GetMethodID(transformerFactoryClass, "newTransformer", "()Ljavax/xml/transform/Transformer;")); | ||
955 | 180 | CHECK_EXCEPTION(env); | ||
956 | 181 | |||
957 | 182 | // Create Source | ||
958 | 183 | xmlUTF = env->NewStringUTF(xml); | ||
959 | 184 | stringReaderClass = env->FindClass("java/io/StringReader"); | ||
960 | 185 | CHECK_EXCEPTION(env); | ||
961 | 186 | stringReader = env->NewObject(stringReaderClass, | ||
962 | 187 | env->GetMethodID(stringReaderClass, "<init>", "(Ljava/lang/String;)V"), xmlUTF); | ||
963 | 188 | CHECK_EXCEPTION(env); | ||
964 | 189 | streamSourceClass = env->FindClass("javax/xml/transform/stream/StreamSource"); | ||
965 | 190 | CHECK_EXCEPTION(env); | ||
966 | 191 | streamSource = env->NewObject(streamSourceClass, | ||
967 | 192 | env->GetMethodID(streamSourceClass, "<init>", "(Ljava/io/Reader;)V"), stringReader); | ||
968 | 193 | CHECK_EXCEPTION(env); | ||
969 | 194 | |||
970 | 195 | // Create the SAXResult | ||
971 | 196 | defaultHandler = env->CallObjectMethod(fop, | ||
972 | 197 | env->GetMethodID(env->FindClass("org/apache/fop/apps/Fop"), "getDefaultHandler", | ||
973 | 198 | "()Lorg/xml/sax/helpers/DefaultHandler;")); | ||
974 | 199 | CHECK_EXCEPTION(env); | ||
975 | 200 | saxResultClass = env->FindClass("javax/xml/transform/sax/SAXResult"); | ||
976 | 201 | CHECK_EXCEPTION(env); | ||
977 | 202 | saxResult = env->NewObject(saxResultClass, | ||
978 | 203 | env->GetMethodID(saxResultClass, "<init>", "(Lorg/xml/sax/ContentHandler;)V"), | ||
979 | 204 | defaultHandler); | ||
980 | 205 | CHECK_EXCEPTION(env); | ||
981 | 206 | |||
982 | 207 | // Transform | ||
983 | 208 | env->CallObjectMethod(transormer, | ||
984 | 209 | env->GetMethodID(env->FindClass("javax/xml/transform/Transformer"), | ||
985 | 210 | "transform", | ||
986 | 211 | "(Ljavax/xml/transform/Source;Ljavax/xml/transform/Result;)V"), | ||
987 | 212 | streamSource, saxResult); | ||
988 | 213 | CHECK_EXCEPTION(env); | ||
989 | 214 | |||
990 | 215 | // Close outputstream | ||
991 | 216 | env->CallObjectMethod(byteArrayOutputStream, | ||
992 | 217 | env->GetMethodID(env->FindClass("java/io/OutputStream"), | ||
993 | 218 | "close", "()V")); | ||
994 | 219 | CHECK_EXCEPTION(env); | ||
995 | 220 | saxResultClass = env->FindClass("javax/xml/transform/sax/SAXResult"); | ||
996 | 221 | CHECK_EXCEPTION(env); | ||
997 | 222 | |||
998 | 223 | // Get the byte array | ||
999 | 224 | res = (jbyteArray) env->CallObjectMethod(byteArrayOutputStream, | ||
1000 | 225 | env->GetMethodID(byteArrayOutputStreamClass, "toByteArray", "()[B")); | ||
1001 | 226 | CHECK_EXCEPTION(env); | ||
1002 | 227 | |||
1003 | 228 | // Create the result | ||
1004 | 229 | dataSize = env->GetArrayLength(res); | ||
1005 | 230 | dataElements = env->GetByteArrayElements(res, &isCopy); | ||
1006 | 231 | |||
1007 | 232 | std::string lBinaryString((const char*) dataElements, dataSize); | ||
1008 | 233 | std::stringstream lStream(lBinaryString); | ||
1009 | 234 | String base64S = encoding::Base64::encode(lStream); | ||
1010 | 235 | Item lRes = theFactory->createBase64Binary(base64S.c_str(), base64S.length()); | ||
1011 | 236 | return ItemSequence_t(new SingletonItemSequence(lRes)); | ||
1012 | 237 | } catch (zorba::jvm::VMOpenException&) { | ||
1013 | 238 | Item lQName = theFactory->createQName("http://www.zorba-xquery.com/modules/xsl-fo", | ||
1014 | 239 | "VM001"); | ||
1015 | 240 | throw USER_EXCEPTION(lQName, "Could not start the Java VM (is the classpath set?)"); | ||
1016 | 241 | } catch (JavaException&) { | ||
1017 | 242 | jclass stringWriterClass = env->FindClass("java/io/StringWriter"); | ||
1018 | 243 | jclass printWriterClass = env->FindClass("java/io/PrintWriter"); | ||
1019 | 244 | jclass throwableClass = env->FindClass("java/lang/Throwable"); | ||
1020 | 245 | jobject stringWriter = env->NewObject( | ||
1021 | 246 | stringWriterClass, | ||
1022 | 247 | env->GetMethodID(stringWriterClass, "<init>", "()V")); | ||
1023 | 248 | jobject printWriter = env->NewObject( | ||
1024 | 249 | printWriterClass, env->GetMethodID(printWriterClass, "<init>", "(Ljava/io/Writer;)V"), stringWriter); | ||
1025 | 250 | env->CallObjectMethod(lException, env->GetMethodID(throwableClass, "printStackTrace", "(Ljava/io/PrintWriter;)V"), printWriter); | ||
1026 | 251 | //env->CallObjectMethod(printWriter, env->GetMethodID(printWriterClass, "flush", "()V")); | ||
1027 | 252 | jmethodID toStringMethod = env->GetMethodID(stringWriterClass, "toString", "()Ljava/lang/String;"); | ||
1028 | 253 | jobject errorMessageObj = env->CallObjectMethod( | ||
1029 | 254 | stringWriter, toStringMethod); | ||
1030 | 255 | jstring errorMessage = (jstring) errorMessageObj; | ||
1031 | 256 | const char *errMsg = env->GetStringUTFChars(errorMessage, 0); | ||
1032 | 257 | std::stringstream s; | ||
1033 | 258 | s << "A Java Exception was thrown:" << std::endl << errMsg; | ||
1034 | 259 | env->ReleaseStringUTFChars(errorMessage, errMsg); | ||
1035 | 260 | std::string err(""); | ||
1036 | 261 | err += s.str(); | ||
1037 | 262 | env->ExceptionClear(); | ||
1038 | 263 | Item lQName = theFactory->createQName("http://www.zorba-xquery.com/modules/xsl-fo", | ||
1039 | 264 | "JAVA-EXCEPTION"); | ||
1040 | 265 | throw USER_EXCEPTION(lQName, err); | ||
1041 | 266 | } | ||
1042 | 267 | return ItemSequence_t(new EmptySequence()); | ||
1043 | 268 | } | ||
1044 | 269 | |||
1045 | 270 | }}; // namespace zorba, xslfo | ||
1046 | 271 | |||
1047 | 272 | #ifdef WIN32 | ||
1048 | 273 | # define DLL_EXPORT __declspec(dllexport) | ||
1049 | 274 | #else | ||
1050 | 275 | # define DLL_EXPORT __attribute__ ((visibility("default"))) | ||
1051 | 276 | #endif | ||
1052 | 277 | |||
1053 | 278 | extern "C" DLL_EXPORT zorba::ExternalModule* createModule() { | ||
1054 | 279 | return new zorba::xslfo::XSLFOModule(); | ||
1055 | 280 | } | ||
1056 | 0 | 281 | ||
1057 | === added directory 'test' | |||
1058 | === renamed directory 'test' => 'test.moved' | |||
1059 | === added directory 'test/ExpQueryResults' | |||
1060 | === added directory 'test/ExpQueryResults/data-formatting' | |||
1061 | === added file 'test/ExpQueryResults/data-formatting/xslfo.xml.res' | |||
1062 | --- test/ExpQueryResults/data-formatting/xslfo.xml.res 1970-01-01 00:00:00 +0000 | |||
1063 | +++ test/ExpQueryResults/data-formatting/xslfo.xml.res 2012-09-28 12:58:20 +0000 | |||
1064 | @@ -0,0 +1,1 @@ | |||
1065 | 1 | <pdf><len>true</len><start>JVBERi0xLj</start></pdf> | ||
1066 | 0 | 2 | ||
1067 | === added directory 'test/Queries' | |||
1068 | === added directory 'test/Queries/data-formatting' | |||
1069 | === added file 'test/Queries/data-formatting/xslfo.xq' | |||
1070 | --- test/Queries/data-formatting/xslfo.xq 1970-01-01 00:00:00 +0000 | |||
1071 | +++ test/Queries/data-formatting/xslfo.xq 2012-09-28 12:58:20 +0000 | |||
1072 | @@ -0,0 +1,26 @@ | |||
1073 | 1 | import module namespace fop = "http://www.zorba-xquery.com/modules/xsl-fo"; | ||
1074 | 2 | import module namespace file = "http://expath.org/ns/file"; | ||
1075 | 3 | |||
1076 | 4 | declare namespace fo = "http://www.w3.org/1999/XSL/Format"; | ||
1077 | 5 | |||
1078 | 6 | let $xsl-fo := <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> | ||
1079 | 7 | <fo:layout-master-set> | ||
1080 | 8 | <fo:simple-page-master master-name="my-page"> | ||
1081 | 9 | <fo:region-body margin="1in"/> | ||
1082 | 10 | </fo:simple-page-master> | ||
1083 | 11 | </fo:layout-master-set> | ||
1084 | 12 | |||
1085 | 13 | <fo:page-sequence master-reference="my-page"> | ||
1086 | 14 | <fo:flow flow-name="xsl-region-body"> | ||
1087 | 15 | <fo:block>Hello, world!</fo:block> | ||
1088 | 16 | </fo:flow> | ||
1089 | 17 | </fo:page-sequence> | ||
1090 | 18 | </fo:root> | ||
1091 | 19 | let $pdfBase64Binary := fop:generator($fop:PDF, $xsl-fo) | ||
1092 | 20 | let $pdf := xs:string($pdfBase64Binary) | ||
1093 | 21 | let $len := fn:string-length($pdf) | ||
1094 | 22 | return | ||
1095 | 23 | <pdf> | ||
1096 | 24 | <len> { $len gt 6000 }</len> | ||
1097 | 25 | <start>{ fn:substring($pdf, 1, 10)}</start> | ||
1098 | 26 | </pdf> |
William, I think you chose the wrong branch to merge into. Pls check again.