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