zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #06526
[Merge] lp:~zorba-coders/zorba/bug955040 into lp:zorba
Rodolfo Ochoa has proposed merging lp:~zorba-coders/zorba/bug955040 into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Cezar Andrei (cezar-andrei)
Related bugs:
Bug #955040 in Zorba: "XSL-FO module test added even if module is not built"
https://bugs.launchpad.net/zorba/+bug/955040
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug955040/+merge/98006
Fix for bug955040
better validations for JAR identification
--
https://code.launchpad.net/~zorba-coders/zorba/bug955040/+merge/98006
Your team Zorba Coders is subscribed to branch lp:zorba.
=== added file 'CMakeLists.txt'
--- CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ CMakeLists.txt 2012-03-16 22:09:19 +0000
@@ -0,0 +1,34 @@
+# Copyright 2006-2010 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+MESSAGE (STATUS "******** BEGIN Configuring module Data-Formatting ********")
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT (zorba_data-formatting_module)
+ENABLE_TESTING ()
+INCLUDE (CTest)
+
+SET_CMAKE_MODULE_PATH ()
+
+FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}")
+INCLUDE ("${Zorba_USE_FILE}")
+
+ADD_SUBDIRECTORY ("src")
+#ADD_TEST_DIRECTORY ("${CMAKE_SOURCE_DIR}/test")
+
+
+DONE_DECLARING_ZORBA_URIS ()
+
+MESSAGE (STATUS "******** END Configuring module Data-Formatting ********")
=== renamed file 'CMakeLists.txt' => 'CMakeLists.txt.moved'
=== added directory 'cmake_modules'
=== renamed directory 'cmake_modules' => 'cmake_modules.moved'
=== added file 'cmake_modules/FindJNI.cmake'
--- cmake_modules/FindJNI.cmake 1970-01-01 00:00:00 +0000
+++ cmake_modules/FindJNI.cmake 2012-03-16 22:09:19 +0000
@@ -0,0 +1,279 @@
+# - Find JNI java libraries.
+# This module finds if Java is installed and determines where the
+# include files and libraries are. It also determines what the name of
+# the library is. This code sets the following variables:
+#
+# JNI_INCLUDE_DIRS = the include dirs to use
+# JNI_LIBRARIES = the libraries to use
+# JNI_FOUND = TRUE if JNI headers and libraries were found.
+# JAVA_AWT_LIBRARY = the path to the jawt library
+# JAVA_JVM_LIBRARY = the path to the jvm library
+# JAVA_INCLUDE_PATH = the include path to jni.h
+# JAVA_INCLUDE_PATH2 = the include path to jni_md.h
+# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
+#
+
+#=============================================================================
+# Copyright 2001-2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var}
+MACRO(java_append_library_directories _var)
+ # Determine java arch-specific library subdir
+ # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk
+ # 1.6.0_18 + icedtea patches. However, it would be much better to base the
+ # guess on the first part of the GNU config.guess platform triplet.
+ IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ SET(_java_libarch "amd64")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
+ SET(_java_libarch "i386")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
+ SET(_java_libarch "alpha")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
+ # Subdir is "arm" for both big-endian (arm) and little-endian (armel).
+ SET(_java_libarch "arm")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
+ # mips* machines are bi-endian mostly so processor does not tell
+ # endianess of the underlying system.
+ SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
+ SET(_java_libarch "ppc64")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
+ SET(_java_libarch "ppc")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
+ # Both flavours can run on the same processor
+ SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
+ SET(_java_libarch "parisc" "parisc64")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
+ # s390 binaries can run on s390x machines
+ SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
+ ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
+ SET(_java_libarch "sh")
+ ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}")
+ ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+
+ # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
+ # system is non-Linux (where the code above has not been well tested)
+ IF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+ LIST(APPEND _java_libarch "i386" "amd64" "ppc")
+ ENDIF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+
+ # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
+ # current value to a hardcoded list. Remove possible duplicates.
+ LIST(REMOVE_DUPLICATES _java_libarch)
+
+ FOREACH(_path ${ARGN})
+ IF(_path MATCHES "{libarch}")
+ FOREACH(_libarch ${_java_libarch})
+ STRING(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}")
+ LIST(APPEND ${_var} "${_newpath}")
+ ENDFOREACH(_libarch)
+ ELSE(_path MATCHES "{libarch}")
+ LIST(APPEND ${_var} "${_path}")
+ ENDIF(_path MATCHES "{libarch}")
+ ENDFOREACH(_path)
+ENDMACRO(java_append_library_directories)
+
+GET_FILENAME_COMPONENT(java_install_version
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
+
+SET(JAVA_AWT_LIBRARY_DIRECTORIES
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
+ )
+
+FILE(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME)
+
+JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+ ${_JAVA_HOME}/jre/lib/{libarch}
+ ${_JAVA_HOME}/jre/lib
+ ${_JAVA_HOME}/lib
+ ${_JAVA_HOME}
+ /usr/lib
+ /usr/local/lib
+ /usr/lib/jvm/java/lib
+ /usr/lib/java/jre/lib/{libarch}
+ /usr/local/lib/java/jre/lib/{libarch}
+ /usr/local/share/java/jre/lib/{libarch}
+ /usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
+ /usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
+ /opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
+ /usr/lib/jvm/java-6-sun/jre/lib/{libarch}
+ /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
+ /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch} # can this one be removed according to #8821 ? Alex
+ /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
+ /usr/lib/jvm/java-openjdk/jre/lib/{libarch}
+ # Debian specific paths for default JVM
+ /usr/lib/jvm/default-java/jre/lib/{libarch}
+ /usr/lib/jvm/default-java/jre/lib
+ /usr/lib/jvm/default-java/lib
+ )
+
+SET(JAVA_JVM_LIBRARY_DIRECTORIES)
+FOREACH(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
+ SET(JAVA_JVM_LIBRARY_DIRECTORIES
+ ${JAVA_JVM_LIBRARY_DIRECTORIES}
+ "${dir}"
+ "${dir}/client"
+ "${dir}/server"
+ )
+ENDFOREACH(dir)
+
+
+SET(JAVA_AWT_INCLUDE_DIRECTORIES
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
+ ${_JAVA_HOME}/include
+ /usr/include
+ /usr/local/include
+ /usr/lib/java/include
+ /usr/local/lib/java/include
+ /usr/lib/jvm/java/include
+ /usr/lib/jvm/java-6-sun/include
+ /usr/lib/jvm/java-1.5.0-sun/include
+ /usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex
+ /usr/lib/jvm/java-6-openjdk/include
+ /usr/local/share/java/include
+ /usr/lib/j2sdk1.4-sun/include
+ /usr/lib/j2sdk1.5-sun/include
+ /opt/sun-jdk-1.5.0.04/include
+ # Debian specific path for default JVM
+ /usr/lib/jvm/default-java/include
+ )
+
+FOREACH(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
+ GET_FILENAME_COMPONENT(jpath "${JAVA_PROG}" PATH)
+ FOREACH(JAVA_INC_PATH ../include ../java/include ../share/java/include)
+ IF(EXISTS ${jpath}/${JAVA_INC_PATH})
+ SET(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}")
+ ENDIF(EXISTS ${jpath}/${JAVA_INC_PATH})
+ ENDFOREACH(JAVA_INC_PATH)
+ FOREACH(JAVA_LIB_PATH
+ ../lib ../jre/lib ../jre/lib/i386
+ ../java/lib ../java/jre/lib ../java/jre/lib/i386
+ ../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
+ IF(EXISTS ${jpath}/${JAVA_LIB_PATH})
+ SET(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}")
+ ENDIF(EXISTS ${jpath}/${JAVA_LIB_PATH})
+ ENDFOREACH(JAVA_LIB_PATH)
+ENDFOREACH(JAVA_PROG)
+
+IF(APPLE)
+ IF(EXISTS ~/Library/Frameworks/JavaVM.framework)
+ SET(JAVA_HAVE_FRAMEWORK 1)
+ ENDIF(EXISTS ~/Library/Frameworks/JavaVM.framework)
+ IF(EXISTS /Library/Frameworks/JavaVM.framework)
+ SET(JAVA_HAVE_FRAMEWORK 1)
+ ENDIF(EXISTS /Library/Frameworks/JavaVM.framework)
+ IF(EXISTS /System/Library/Frameworks/JavaVM.framework)
+ SET(JAVA_HAVE_FRAMEWORK 1)
+ ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework)
+
+ IF(JAVA_HAVE_FRAMEWORK)
+ IF(NOT JAVA_AWT_LIBRARY)
+ SET (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
+ ENDIF(NOT JAVA_AWT_LIBRARY)
+
+ IF(NOT JAVA_JVM_LIBRARY)
+ SET (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
+ ENDIF(NOT JAVA_JVM_LIBRARY)
+
+ IF(NOT JAVA_AWT_INCLUDE_PATH)
+ IF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
+ SET (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE)
+ ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
+ ENDIF(NOT JAVA_AWT_INCLUDE_PATH)
+
+ # If using "-framework JavaVM", prefer its headers *before* the others in
+ # JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here)
+ #
+ SET(JAVA_AWT_INCLUDE_DIRECTORIES
+ ~/Library/Frameworks/JavaVM.framework/Headers
+ /Library/Frameworks/JavaVM.framework/Headers
+ /System/Library/Frameworks/JavaVM.framework/Headers
+ ${JAVA_AWT_INCLUDE_DIRECTORIES}
+ )
+ ENDIF(JAVA_HAVE_FRAMEWORK)
+ELSE(APPLE)
+ FIND_LIBRARY(JAVA_AWT_LIBRARY jawt
+ PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES}
+ )
+ FIND_LIBRARY(JAVA_JVM_LIBRARY NAMES jvm JavaVM java
+ PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES}
+ )
+ENDIF(APPLE)
+
+# add in the include path
+FIND_PATH(JAVA_INCLUDE_PATH jni.h
+ ${JAVA_AWT_INCLUDE_DIRECTORIES}
+)
+
+FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h
+ ${JAVA_INCLUDE_PATH}
+ ${JAVA_INCLUDE_PATH}/win32
+ ${JAVA_INCLUDE_PATH}/linux
+ ${JAVA_INCLUDE_PATH}/freebsd
+ ${JAVA_INCLUDE_PATH}/solaris
+)
+
+FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h
+ ${JAVA_INCLUDE_PATH}
+)
+
+IF (APPLE)
+ # On Mac, the java headers files are broken symlinks if the Apple Developer Tools for Java are not installed
+ EXECUTE_PROCESS(COMMAND cat ${JAVA_INCLUDE_PATH}/jni.h
+ OUTPUT_QUIET
+ ERROR_QUIET
+ RESULT_VARIABLE SYMLINK_CHECK_RESULT_VARIABLE)
+ IF (SYMLINK_CHECK_RESULT_VARIABLE GREATER 0)
+ SET (JAVA_INCLUDE_PATH "JAVA_INCLUDE_PATH-NOTFOUND")
+ SET (JAVA_INCLUDE_PATH2 "JAVA_INCLUDE_PATH2-NOTFOUND")
+ SET (JAVA_AWT_INCLUDE_PATH "JAVA_AWT_INCLUDE_PATH-NOTFOUND")
+ ENDIF()
+ENDIF (APPLE)
+
+
+#INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake")
+#FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
+# JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
+
+MARK_AS_ADVANCED(
+ JAVA_AWT_LIBRARY
+ JAVA_JVM_LIBRARY
+ JAVA_AWT_INCLUDE_PATH
+ JAVA_INCLUDE_PATH
+ JAVA_INCLUDE_PATH2
+)
+
+IF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH)
+ SET(JNI_FOUND 1)
+ SET(JNI_LIBRARIES
+ ${JAVA_AWT_LIBRARY}
+ ${JAVA_JVM_LIBRARY}
+ )
+ SET(JNI_INCLUDE_DIRS
+ ${JAVA_INCLUDE_PATH}
+ ${JAVA_INCLUDE_PATH2}
+ ${JAVA_AWT_INCLUDE_PATH}
+ )
+ELSE (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH)
+ SET(JNI_FOUND 0)
+ SET(JNI_LIBRARIES "")
+ SET(JNI_INCLUDE_DIRS "")
+ENDIF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH)
+
+
=== added directory 'cmake_modules/Windows'
=== added file 'cmake_modules/Windows/FindJNI.cmake'
--- cmake_modules/Windows/FindJNI.cmake 1970-01-01 00:00:00 +0000
+++ cmake_modules/Windows/FindJNI.cmake 2012-03-16 22:09:19 +0000
@@ -0,0 +1,37 @@
+# Copyright 2010 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# - Try to find the JNI libraries on Windows
+#
+# See the FindJNI.cmake module shipped with Zorba for more information.
+
+FIND_PACKAGE_WIN32_NO_PROXY (JNI JNI_FOUND)
+
+IF (JNI_FOUND)
+
+ STRING (REPLACE "/jvm.lib" "" JAVA_JVM_LIBRARY_PATH "${JAVA_JVM_LIBRARY}")
+
+ IF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+ SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+ # find the needed DLL's
+ FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm")
+ ELSEIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server")
+ SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server")
+ # find the needed DLL's
+ FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm")
+ ELSE (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+ 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.")
+ ENDIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+
+ENDIF (JNI_FOUND)
=== added directory 'src'
=== renamed directory 'src' => 'src.moved'
=== added file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/CMakeLists.txt 2012-03-16 22:09:19 +0000
@@ -0,0 +1,20 @@
+# Copyright 2006-2008 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# all external module libraries are generated in the directory
+# of the corresponding .xq file
+MESSAGE(STATUS "Add com")
+ADD_SUBDIRECTORY(com)
+
+MESSAGE(STATUS "End modules")
=== added directory 'src/com'
=== added file 'src/com/CMakeLists.txt'
--- src/com/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/com/CMakeLists.txt 2012-03-16 22:09:19 +0000
@@ -0,0 +1,17 @@
+# Copyright 2006-2008 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# all external module libraries are generated in the directory
+# of the corresponding .xq file
+ADD_SUBDIRECTORY(zorba-xquery)
=== added directory 'src/com/zorba-xquery'
=== added file 'src/com/zorba-xquery/CMakeLists.txt'
--- src/com/zorba-xquery/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/com/zorba-xquery/CMakeLists.txt 2012-03-16 22:09:19 +0000
@@ -0,0 +1,17 @@
+# Copyright 2006-2008 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# all external module libraries are generated in the directory
+# of the corresponding .xq file
+ADD_SUBDIRECTORY(www)
=== added directory 'src/com/zorba-xquery/www'
=== added file 'src/com/zorba-xquery/www/CMakeLists.txt'
--- src/com/zorba-xquery/www/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/com/zorba-xquery/www/CMakeLists.txt 2012-03-16 22:09:19 +0000
@@ -0,0 +1,17 @@
+# Copyright 2006-2008 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# all external module libraries are generated in the directory
+# of the corresponding .xq file
+ADD_SUBDIRECTORY(modules)
=== added directory 'src/com/zorba-xquery/www/modules'
=== added file 'src/com/zorba-xquery/www/modules/CMakeLists.txt'
--- src/com/zorba-xquery/www/modules/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/com/zorba-xquery/www/modules/CMakeLists.txt 2012-03-16 22:09:19 +0000
@@ -0,0 +1,124 @@
+# Copyright 2006-2010 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SET (ZORBA_WITH_FOP ON CACHE BOOL "Compile Zorba with XSL-FO support" FORCE)
+IF (ZORBA_WITH_FOP)
+
+ IF (ZORBA_SUPPRESS_JAVA)
+ MESSAGE (STATUS "ZORBA_SUPPRESS_JNI is true - not searching for Java")
+ MESSAGE (STATUS "Building Zorba without XSL-FO support.")
+ ELSE (ZORBA_SUPPRESS_JAVA)
+
+ FIND_PACKAGE(Java)
+ FIND_PACKAGE(JNI)
+
+ IF (JNI_FOUND)
+
+ IF (NOT DEFINED XSL_FOP_HOME)
+ IF (DEFINED ENV{XSL_FOP_HOME})
+ SET(XSL_FOP_HOME $ENV{XSL_FOP_HOME})
+ ENDIF (DEFINED ENV{XSL_FOP_HOME})
+ ENDIF (NOT DEFINED XSL_FOP_HOME)
+
+ IF (NOT DEFINED XSL_FOP_HOME)
+ IF (WIN32)
+ MESSAGE (STATUS "Environment variable XSL_FOP_HOME not defined, trying default: C:\\dev\\libraries\\fop-1.0")
+ SET (XSL_FOP_HOME "C:\\dev\\libraries\\fop-1.0")
+ ELSE (WIN32)
+ MESSAGE (STATUS "Environment variable XSL_FOP_HOME not defined, trying defaults: " ${Java_LIBRARIES} " /usr/share/java/ /usr/share/java/fop/")
+ SET (XSL_FOP_HOME "/usr/share/java/ /usr/share/java/fop/ ${Java_LIBRARIES}")
+ ENDIF (WIN32)
+ ENDIF (NOT DEFINED XSL_FOP_HOME)
+
+ STRING(REGEX REPLACE "\\\\" "/" XSL_FOP_HOME "${XSL_FOP_HOME}")
+
+ MESSAGE (STATUS "XSL-FOP HOME: " ${XSL_FOP_HOME} )
+ FIND_FILE( FOP_JAR NAMES fop.jar
+ PATHS ${XSL_FOP_HOME} ${XSL_FOP_HOME}/build )
+ FIND_FILE( FOP_D1_JAR NAMES avalon-framework.jar
+ PATHS ${XSL_FOP_HOME} ${XSL_FOP_HOME}/lib )
+ FIND_FILE( FOP_D2_JAR NAMES batik-all.jar
+ PATHS ${XSL_FOP_HOME} ${XSL_FOP_HOME}/lib )
+ FIND_FILE( FOP_D3_JAR NAMES commons-io.jar
+ PATHS ${XSL_FOP_HOME} ${XSL_FOP_HOME}/lib )
+ FIND_FILE( FOP_D4_JAR NAMES commons-logging.jar
+ PATHS ${XSL_FOP_HOME} ${XSL_FOP_HOME}/lib )
+ FIND_FILE( FOP_D5_JAR NAMES serializer.jar
+ PATHS ${XSL_FOP_HOME} ${XSL_FOP_HOME}/lib )
+ FIND_FILE( FOP_D6_JAR NAMES xalan.jar xalan2.jar
+ PATHS ${XSL_FOP_HOME} ${XSL_FOP_HOME}/lib )
+ FIND_FILE( FOP_D7_JAR NAMES xmlgraphics-commons.jar
+ PATHS ${XSL_FOP_HOME} ${XSL_FOP_HOME}/lib )
+
+ #MULTIPLE EXISTS CAN'T BE USED IN AN *IF* COMMAND, LOOKS LIKE A BUG ON CMAKE
+ SET(ALL_FOP FALSE)
+ IF ( EXISTS ${FOP_JAR} )
+ IF ( EXISTS ${FOP_D1_JAR} )
+ IF ( EXISTS ${FOP_D2_JAR} )
+ IF ( EXISTS ${FOP_D3_JAR} )
+ IF ( EXISTS ${FOP_D4_JAR} )
+ IF ( EXISTS ${FOP_D5_JAR} )
+ IF ( EXISTS ${FOP_D6_JAR} )
+ IF ( EXISTS ${FOP_D7_JAR} )
+ SET(ALL_FOP TRUE)
+ ENDIF ( EXISTS ${FOP_D7_JAR} )
+ ENDIF ( EXISTS ${FOP_D6_JAR} )
+ ENDIF ( EXISTS ${FOP_D5_JAR} )
+ ENDIF ( EXISTS ${FOP_D4_JAR} )
+ ENDIF ( EXISTS ${FOP_D3_JAR} )
+ ENDIF ( EXISTS ${FOP_D2_JAR} )
+ ENDIF ( EXISTS ${FOP_D1_JAR} )
+ ENDIF ( EXISTS ${FOP_JAR} )
+ MESSAGE(STATUS "ALL_FOP:" ${ALL_FOP})
+
+ IF ( ALL_FOP )
+ MESSAGE(STATUS "FOP Libraries Found.")
+ INCLUDE (CMakeJavaInformation )
+ EXECUTE_PROCESS (
+ COMMAND ${JAVA_RUNTIME} -version
+ RESULT_VARIABLE JAVA_VERSION
+ OUTPUT_QUIET
+ ERROR_QUIET
+ )
+
+ INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
+ INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH})
+ DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/xsl-fo" VERSION 1.0 FILE "xsl-fo.xq" LINK_LIBRARIES "${JAVA_JVM_LIBRARY}")
+
+ DECLARE_ZORBA_JAR(FILE ${FOP_JAR} EXTERNAL)
+ DECLARE_ZORBA_JAR(FILE ${FOP_D1_JAR} EXTERNAL)
+ DECLARE_ZORBA_JAR(FILE ${FOP_D2_JAR} EXTERNAL)
+ DECLARE_ZORBA_JAR(FILE ${FOP_D3_JAR} EXTERNAL)
+ DECLARE_ZORBA_JAR(FILE ${FOP_D4_JAR} EXTERNAL)
+ DECLARE_ZORBA_JAR(FILE ${FOP_D5_JAR} EXTERNAL)
+ DECLARE_ZORBA_JAR(FILE ${FOP_D6_JAR} EXTERNAL)
+ DECLARE_ZORBA_JAR(FILE ${FOP_D7_JAR} EXTERNAL)
+ ADD_TEST_DIRECTORY("${PROJECT_SOURCE_DIR}/test")
+
+ ELSE ( ALL_FOP )
+ MESSAGE (STATUS "fop.jar and all its dependecies not found skiping data-formating module")
+ ENDIF ( ALL_FOP )
+
+ ELSE (JNI_FOUND)
+ IF (ZORBA_WITH_FOP)
+ MESSAGE(FATAL_ERROR "Could not find Java and/or JNI. Please install a JDK or compile Zorba with XSL-FO support by setting ZORBA_WITH_FOP to false.")
+ ENDIF (ZORBA_WITH_FOP)
+ MESSAGE ( STATUS "Not generating XSL-FO support: jni headers not found.")
+ ENDIF(JNI_FOUND)
+
+ ENDIF(ZORBA_SUPPRESS_JAVA)
+ELSEIF (ZORBA_WITH_FOP)
+ #SET(ZORBA_WITH_FOP OFF CACHE BOOL "Compile Zorba with XSL-FO support." FORCE)
+ MESSAGE(STATUS "Building Zorba without XSL-FO support.")
+ENDIF (ZORBA_WITH_FOP)
=== added file 'src/com/zorba-xquery/www/modules/xsl-fo.xq'
--- src/com/zorba-xquery/www/modules/xsl-fo.xq 1970-01-01 00:00:00 +0000
+++ src/com/zorba-xquery/www/modules/xsl-fo.xq 2012-03-16 22:09:19 +0000
@@ -0,0 +1,162 @@
+xquery version "3.0";
+
+(:
+ : Copyright 2006-2009 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+:)
+(:~
+ :
+ : This module converts <a href="http://www.w3schools.com/xslfo/default.asp">XSL-FO</a> documents
+ : to various formats such as PDF, EPS, PCL, AFP, Text, PNG, Postscript, RTF, and TIFF.
+ : For instance, the following example converts a simple XSL-FO document to PDF:
+ : <br />
+ : <pre class="brush: xquery;">
+ : import module namespace fop = "http://www.zorba-xquery.com/modules/xsl-fo";
+ : import module namespace file = "http://expath.org/ns/file";
+ :
+ : declare namespace fo = "http://www.w3.org/1999/XSL/Format";
+ :
+ : let $xsl-fo := <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ : <fo:layout-master-set>
+ : <fo:simple-page-master master-name="my-page">
+ : <fo:region-body margin="1in"/>
+ : </fo:simple-page-master>
+ : </fo:layout-master-set>
+ :
+ : <fo:page-sequence master-reference="my-page">
+ : <fo:flow flow-name="xsl-region-body">
+ : <fo:block>Hello, world!</fo:block>
+ : </fo:flow>
+ : </fo:page-sequence>
+ : </fo:root>
+ : let $pdf := fop:generator($fop:PDF, $xsl-fo)
+ : return file:write-binary("simple.pdf", $pdf)
+ : </pre>
+ : <br />
+ : This module uses Apache-FOP to generate content from an XSL-FO document.
+ : See <a href="http://xmlgraphics.apache.org/fop/">the Apache FOP documentation</a> for further information.
+ : <br />
+ : <br />
+ : <b>Note for Windows users</b>: On Windows, this module won't work out of the box, since
+ : this module uses Java. But the Java VM dll is not in the system path by default. To make
+ : this module work, you need to add the directory where the jvm.dll is located to the
+ : system path. This dll is located at JRE_DIR\bin\client. On a standard installation, this would
+ : be something a path like "C:\Program Files\Java\jre6\bin\client".
+ :
+ : @author Markus Pilman
+ : @see http://xmlgraphics.apache.org/fop/
+ : @library <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">JDK - Java Development Kit</a>
+ : @project data processing/data formatting
+ :)
+module namespace xsl-fo = "http://www.zorba-xquery.com/modules/xsl-fo";
+
+
+declare namespace err = "http://www.w3.org/2005/xqt-errors";
+
+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
+declare option ver:module-version "1.0";
+
+(:~
+ : The mime type of IBMs AFP format (application/x-afp).
+ :)
+declare variable $xsl-fo:AFP as xs:string := "application/x-afp";
+(:~
+ : The mime type of the EPS format (application/postscript).
+ :)
+declare variable $xsl-fo:EPS as xs:string := "application/postscript";
+(:~
+ : The mime type of the PCL format (application/x-pcl).
+ :)
+declare variable $xsl-fo:PCL as xs:string := "application/x-pcl";
+(:~
+ : The mime type of the PDF format (application/pdf).
+ :)
+declare variable $xsl-fo:PDF as xs:string := "application/pdf";
+(:~
+ : The mime type for plain text files (text/plain).
+ :)
+declare variable $xsl-fo:PLAIN_TEXT as xs:string := "text/plain";
+(:~
+ : The mime type of the PNG format (image/png).
+ :)
+declare variable $xsl-fo:PNG as xs:string := "image/png";
+(:~
+ : The mime type of the postscript format (application/postscript).
+ :)
+declare variable $xsl-fo:POSTSCRIPT as xs:string := "application/postscript";
+(:~
+ : The mime type of the RTF format (application/rtf).
+ :)
+declare variable $xsl-fo:RTF as xs:string := "application/rtf";
+(:~
+ : The mime type of TIFF format (application/tiff).
+ :)
+declare variable $xsl-fo:TIFF as xs:string := "image/tiff";
+
+(:~
+ : Deprecated. This function has been deprecated, the JVM and it's classpath is handled diffrently.<br/>
+ : The generator function takes an XSL-FO document as input and generates output in the format given as input.
+ : The output format can be given as a MIME type - for example "application/pdf" - or one of the predefined
+ : variables can be used - like $xsl-fo:PDF. Please refer to the Apache FOP documentation for
+ : <a href="http://xmlgraphics.apache.org/fop/0.95/output.html">supported output formats</a>.
+ :
+ : Apache FOP does not support 100% of the XSL-FO standard.
+ : Please consult the <a href="http://xmlgraphics.apache.org/fop/">official documentation for further information</a>.
+ :
+ : @param $output-format The mime of the output format.
+ : @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>.
+ : @param $classpath This parameter is not used, hence the deprecation of this function.
+ : @return The generated output document.
+ : @error xsl-fo:VM001 If zorba was unable to start the JVM.
+ : @error xsl-fo:JAVA-EXCEPTION If Apache FOP throws an exception - i.e. if the input format is not correct/supported.
+ : @deprecated
+ :)
+declare function xsl-fo:generator($output-format as xs:string, $xsl-fo-document as node(), $classpath as xs:string+) as xs:base64Binary {
+ xsl-fo:generator-impl($output-format, $xsl-fo-document)
+};
+
+(:~
+ : The function behaves like <a href="#generator#3">generator#3</a>, but tries to find the needed Java libraries itself.
+ : <br />
+ : On a Mac OS X computer, it should be sufficient to install Apache FOP via Mac Ports.<br />
+ : On Ubuntu it should be sufficient to install the fop packages via apt-get.<br />
+ : On Windows, the classpath needs to be set manually using <a href="#generator#3">generator#3</a>.
+ : <br />
+ : This function tries to find the jar files via environment variables. The user can set the
+ : variable FOP_HOME to the root directory of an Apache FOP distribution. If you have all
+ : JAR files in the same directory, you can set the environment variable FOP_LIB_DIR to this
+ : directory.
+ :
+ : @param $output-format The mime of the output format, to tell Apache FOP which kind of document it should
+ : create.
+ : @param $xsl-fo-document The XSL-FO document from which the output should be generated.
+ : @return The generated output document.
+ : @error xsl-fo:VM001 If zorba was unable to start the JVM.
+ : @error xsl-fo:JAVA-EXCEPTION If Apache FOP throws an exception - i.e. if the input format is not correct/supported.
+ : @error xsl-fo:JAR-NOT-FOUND If a needed Java library could not be found.
+ :)
+declare function xsl-fo:generator($output-format as xs:string, $xsl-fo-document as node()) as xs:base64Binary {
+ xsl-fo:generator-impl($output-format, $xsl-fo-document)
+};
+
+
+(:~
+ : Internal function used to format XSL-FO documents.
+ :
+ : @param $output-format The mime type of the output format.
+ : @param $xsl-fo-document The XSL-FO representation of the document.
+ : @return The base64Binary Representation of document.
+ :)
+declare %private function xsl-fo:generator-impl($output-format as xs:string, $xsl-fo-document as node()) as xs:base64Binary external;
+
=== added directory 'src/com/zorba-xquery/www/modules/xsl-fo.xq.src'
=== added file 'src/com/zorba-xquery/www/modules/xsl-fo.xq.src/JavaVMSingelton.cpp'
--- src/com/zorba-xquery/www/modules/xsl-fo.xq.src/JavaVMSingelton.cpp 1970-01-01 00:00:00 +0000
+++ src/com/zorba-xquery/www/modules/xsl-fo.xq.src/JavaVMSingelton.cpp 2012-03-16 22:09:19 +0000
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <fstream>
+#include <iostream>
+#include <istream>
+#include <string>
+#include <cstdlib>
+#include <cstring>
+#include <sstream>
+
+#include "JavaVMSingelton.h"
+#include <zorba/util/path.h>
+#include <zorba/util/file.h>
+#include <zorba/zorba.h>
+
+
+namespace zorba { namespace jvm {
+JavaVMSingelton* JavaVMSingelton::instance = NULL;
+
+JavaVMSingelton::JavaVMSingelton(const char* classPath)
+{
+ //std::cout << "JavaVMSingelton::JavaVMSingelton classPath: " << classPath << "\n"; std::cout.flush();
+
+ memset(&args, 0, sizeof(args));
+ jint r;
+ jint nOptions = 2;
+
+ std::string classpathOption;
+ std::ostringstream os;
+ os << "-Djava.class.path=" << classPath;
+ classpathOption = os.str();
+ classPathOption = new char[classpathOption.size() + 1];
+ memset(classPathOption, 0, sizeof(char) * (classpathOption.size() + 1));
+ memcpy(classPathOption, classpathOption.c_str(), classpathOption.size() * sizeof(char));
+ std::string lAwtArgStr = "-Djava.awt.headless=true";
+ awtOption = new char[lAwtArgStr.size() + 1];
+ memset(awtOption, 0, sizeof(char) * (lAwtArgStr.size() + 1));
+ memcpy(awtOption, lAwtArgStr.c_str(), sizeof(char) * lAwtArgStr.size());
+ awtOption[lAwtArgStr.size()] = 0;
+ options[0].optionString = classPathOption;
+ options[0].extraInfo = NULL;
+ options[1].optionString = awtOption;
+ options[1].extraInfo = NULL;
+ memset(&args, 0, sizeof(args));
+ args.version = JNI_VERSION_1_2;
+ args.nOptions = nOptions;
+ args.options = options;
+ args.ignoreUnrecognized = JNI_FALSE;
+
+ r = JNI_CreateJavaVM(&m_vm, (void **)&m_env, &args);
+ if (r != JNI_OK) {
+ throw VMOpenException();
+ }
+}
+
+JavaVMSingelton::~JavaVMSingelton()
+{
+ if (instance) {
+ delete instance;
+ instance = NULL;
+ }
+ m_vm->DestroyJavaVM();
+ if (awtOption)
+ delete[] awtOption;
+ if (classPathOption)
+ delete[] classPathOption;
+}
+
+JavaVMSingelton* JavaVMSingelton::getInstance(const char* classPath)
+{
+//#ifdef WIN32
+// // If pointer to instance of JavaVMSingelton exists (true) then return instance pointer else look for
+// // instance pointer in memory mapped pointer. If the instance pointer does not exist in
+// // memory mapped pointer, return a newly created pointer to an instance of Abc.
+
+// return instance ?
+// instance : (instance = (JavaVMSingelton*) MemoryMappedPointers::getPointer("JavaVMSingelton")) ?
+// instance : (instance = (JavaVMSingelton*) MemoryMappedPointers::createEntry("JavaVMSingelton",(void*)new JavaVMSingelton(classPath)));
+//#else
+
+
+ // If pointer to instance of JavaVMSingelton exists (true) then return instance pointer
+ // else return a newly created pointer to an instance of JavaVMSingelton.
+ if (instance == NULL)
+ {
+ JavaVM *jvms;
+ jsize nVMs;
+ if ( JNI_GetCreatedJavaVMs(&jvms, 1, &nVMs)==0 )
+ {
+ //std::cout << "Got JVMs " << nVMs << "\n"; std::cout.flush();
+ if (nVMs == 1)
+ {
+ JavaVM *jvm = jvms;
+ JNIEnv *env;
+ if( jvm->AttachCurrentThread((void **)&env, NULL) ==0 )
+ {
+ // if there is a jvm opened already by a diffrent dynamic lib
+ // make a singleton for this lib with that jvm
+ instance = new JavaVMSingelton(jvm, env);
+ }
+ }
+ }
+
+ if (instance == NULL)
+ {
+ instance = new JavaVMSingelton(classPath);
+ }
+ }
+
+ return instance;
+}
+
+JavaVMSingelton* JavaVMSingelton::getInstance(const zorba::StaticContext* aStaticContext)
+{
+ if (instance == NULL)
+ {
+ String cp = computeClassPath(aStaticContext);
+ return getInstance(cp.c_str());
+ }
+
+ return instance;
+}
+
+JavaVM* JavaVMSingelton::getVM()
+{
+ return m_vm;
+}
+
+JNIEnv* JavaVMSingelton::getEnv()
+{
+ return m_env;
+}
+
+
+String JavaVMSingelton::computeClassPath(const zorba::StaticContext* aStaticContext)
+{
+ String cp;
+
+ // get classpath from global Properties
+ PropertiesGlobal * properties = Zorba::getInstance(NULL)->getPropertiesGlobal();
+ std::string globalClassPath;
+ properties->getJVMClassPath(globalClassPath);
+ cp += globalClassPath;
+
+ std::vector<String> lCPV;
+ aStaticContext->getFullLibPath(lCPV);
+
+ String pathSeparator(filesystem_path::get_path_separator());
+ String dirSeparator(filesystem_path::get_directory_separator());
+
+ for (std::vector<String>::iterator lIter = lCPV.begin();
+ lIter != lCPV.end(); ++lIter)
+ {
+ // verify it contains a jars dir
+ const filesystem_path baseFsPath((*lIter).str());
+ const filesystem_path jarsFsPath(std::string("jars"));
+ filesystem_path jarsDirPath(baseFsPath, jarsFsPath);
+
+ file jarsDir(jarsDirPath);
+
+ if ( jarsDir.exists() && jarsDir.is_directory())
+ {
+ std::vector<std::string> list;
+ jarsDir.lsdir(list);
+
+ for (std::vector<std::string>::iterator itemIter = list.begin();
+ itemIter != list.end(); ++itemIter)
+ {
+ filesystem_path itemLocalFS(*itemIter);
+ filesystem_path itemFS(jarsDirPath, itemLocalFS);
+ file itemFile(itemFS);
+ if ( itemFile.exists() && itemFile.is_file() )
+ {
+ std::string itemName = itemFile.get_path();
+ std::string suffix = "-classpath.txt";
+ size_t found;
+ found = itemName.rfind(suffix);
+ if (found!=std::string::npos &&
+ found + suffix.length() == itemName.length() )
+ {
+ std::auto_ptr<std::istream> pathFile;
+ pathFile.reset(new std::ifstream (itemName.c_str ()));
+ if (!pathFile->good() || pathFile->eof() )
+ {
+ std::cerr << "file {" << itemName << "} not found or not readable." << std::endl;
+ throw itemName;
+ }
+
+ // read file
+ char line[1024];
+ while( !pathFile->eof() && !pathFile->bad() && !pathFile->fail())
+ {
+ pathFile->getline(line, sizeof(line));
+ std::string lineStr(line);
+
+ if ( lineStr.size() == 0 )
+ continue;
+
+ //std::cout << "line: '" << lineStr << "'" << std::endl; std::cout.flush();
+
+ const std::string normalizedPath =
+ filesystem_path::normalize_path( lineStr, jarsDirPath.get_path());
+
+ cp += pathSeparator + normalizedPath;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ properties->setJVMClassPath(cp.str());
+
+ //std::cout << "JavaVMSingelton::computeClassPath: '" << cp << "'" << std::endl; std::cout.flush();
+ return cp;
+}
+
+}} // namespace zorba, jvm
=== added file 'src/com/zorba-xquery/www/modules/xsl-fo.xq.src/JavaVMSingelton.h'
--- src/com/zorba-xquery/www/modules/xsl-fo.xq.src/JavaVMSingelton.h 1970-01-01 00:00:00 +0000
+++ src/com/zorba-xquery/www/modules/xsl-fo.xq.src/JavaVMSingelton.h 2012-03-16 22:09:19 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef JAVA_VM_SINGELTON
+#define JAVA_VM_SINGELTON
+
+#include <jni.h>
+#include <zorba/static_context.h>
+
+
+namespace zorba { namespace jvm {
+
+class VMOpenException {};
+
+class JavaVMSingelton
+{
+public:
+ static JavaVMSingelton* getInstance(const char* classPath);
+ static JavaVMSingelton* getInstance(const zorba::StaticContext* aStaticContext);
+
+ virtual ~JavaVMSingelton();
+ JavaVM* getVM();
+ JNIEnv* getEnv();
+
+protected:
+ JavaVMSingelton(const char* classPath);
+ JavaVMSingelton(JavaVM *jvm, JNIEnv *env) : m_vm(jvm), m_env(env) {}
+ static String computeClassPath(const zorba::StaticContext* aStaticContext);
+
+ static JavaVMSingelton* instance;
+ JavaVM* m_vm;
+ JNIEnv* m_env;
+ JavaVMInitArgs args;
+ JavaVMOption options[2];
+ char* awtOption;
+ char* classPathOption;
+};
+
+}} //namespace zorba, jvm
+
+#endif // JAVA_VM_SINGELTON
=== added file 'src/com/zorba-xquery/www/modules/xsl-fo.xq.src/xslfo.cpp'
--- src/com/zorba-xquery/www/modules/xsl-fo.xq.src/xslfo.cpp 1970-01-01 00:00:00 +0000
+++ src/com/zorba-xquery/www/modules/xsl-fo.xq.src/xslfo.cpp 2012-03-16 22:09:19 +0000
@@ -0,0 +1,440 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <sstream>
+#include <iostream>
+#include <cstdlib>
+#include <list>
+
+#include <zorba/base64.h>
+#include <zorba/empty_sequence.h>
+#include <zorba/diagnostic_list.h>
+#include <zorba/function.h>
+#include <zorba/external_module.h>
+#include <zorba/user_exception.h>
+#include <zorba/file.h>
+#include <zorba/item_factory.h>
+#include <zorba/serializer.h>
+#include <zorba/singleton_item_sequence.h>
+#include <zorba/vector_item_sequence.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingelton.h"
+
+#define XSL_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/xsl-fo"
+
+class JavaException {
+};
+
+#define CHECK_EXCEPTION(env) if ((lException = env->ExceptionOccurred())) throw JavaException()
+
+namespace zorba { namespace xslfo {
+
+class GeneratePDFFunction : public ContextualExternalFunction {
+ private:
+ const ExternalModule* theModule;
+ ItemFactory* theFactory;
+ public:
+ GeneratePDFFunction(const ExternalModule* aModule) :
+ theModule(aModule), theFactory(Zorba::getInstance(0)->getItemFactory()) {}
+ ~GeneratePDFFunction() {}
+
+ public:
+ virtual String getURI() const { return theModule->getURI(); }
+
+ virtual String getLocalName() const { return "generator-impl"; }
+
+ virtual ItemSequence_t
+ evaluate(const ExternalFunction::Arguments_t& args,
+ const zorba::StaticContext*,
+ const zorba::DynamicContext*) const;
+};
+
+class FindApacheFopFunction : public NonContextualExternalFunction {
+ private:
+ const ExternalModule* theModule;
+ ItemFactory* theFactory;
+ private:
+ void throwError(std::string aName) const;
+ public:
+ FindApacheFopFunction(const ExternalModule* aModule) :
+ theModule(aModule), theFactory(Zorba::getInstance(0)->getItemFactory()) {}
+
+ virtual String getURI() const { return theModule->getURI(); }
+
+ virtual String getLocalName() const { return "find-apache-fop"; }
+
+ virtual ItemSequence_t
+ evaluate(const ExternalFunction::Arguments_t& args) const;
+};
+
+class XSLFOModule : public ExternalModule {
+ private:
+ ExternalFunction* generatePDF;
+ ExternalFunction* findFop;
+ public:
+ XSLFOModule() :
+ generatePDF(new GeneratePDFFunction(this)),
+ findFop(new FindApacheFopFunction(this))
+ {}
+ ~XSLFOModule() {
+ delete generatePDF;
+ delete findFop;
+ }
+
+ virtual String getURI() const { return XSL_MODULE_NAMESPACE; }
+
+ virtual ExternalFunction* getExternalFunction(const String& localName);
+
+ virtual void destroy() {
+ delete this;
+ }
+};
+
+ExternalFunction* XSLFOModule::getExternalFunction(const String& localName) {
+ if (localName == "generator-impl") {
+ return generatePDF;
+ } else if (localName == "find-apache-fop") {
+ return findFop;
+ }
+ return 0;
+}
+
+void FindApacheFopFunction::throwError(std::string aName) const {
+ Item lQName = theFactory->createQName("http://www.zorba-xquery.com/modules/xsl-fo",
+ "JAR-NOT-FOUND");
+ throw USER_EXCEPTION(lQName, aName);
+}
+
+ItemSequence_t FindApacheFopFunction::evaluate(const ExternalFunction::Arguments_t& args) const
+{
+ std::string lDirectorySeparator(File::getDirectorySeparator());
+ std::string lFopHome;
+ {
+ char* lFopHomeEnv = getenv("FOP_HOME");
+ if (lFopHomeEnv != 0) {
+ lFopHome = lFopHomeEnv;
+ }
+#ifdef APPLE
+ else {
+ // If Apache FOP is installed with Mac Ports, FOP
+ // is typicaly installed in /opt/local/share/java/fop,
+ // so we check here, if the installation directory can
+ // be found in this directory.
+ std::string lFopPath("/opt/local/share/java/fop/");
+ File_t lRootDir = File::createFile(lFopPath);
+ if (lRootDir->exists() && lRootDir->isDirectory()) {
+ DirectoryIterator_t lFiles = lRootDir->files();
+ std::string lFileName;
+ // The FOP directory is in a subdirectory with the version
+ // number - so we check all subdirectories to get the final
+ // path.
+ while (lFiles->next(lFileName)) {
+ File_t lFile = File::createFile(lFopPath + lFileName);
+ if (lFile->isDirectory()) {
+ std::stringstream lStr(lFileName);
+ double lDirDouble = 0.0;
+ if (lStr >> lDirDouble) {
+ if (lDirDouble != 0.0) {
+ lFopHome = lFopPath + lFileName;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+ }
+ std::string lFopLibDir;
+ {
+ char* lEnv = getenv("FOP_LIB_DIR");
+ if (lEnv != 0) {
+ lFopLibDir = lEnv;
+ }
+#ifdef LINUX
+ // on a Ubuntu installation, all required
+ // jar files should be in /usr/share/java
+ // if Apache FOP is installed.
+ else {
+ lFopLibDir = "/usr/share/java";
+ }
+#endif
+ }
+ // If neither a path to the fop install dir, nor a path
+ // to the jar files was found so far, we throw an exception.
+ if (lFopHome == "" && lFopLibDir == "") {
+ throwError("None of the environment variables FOP_HOME and FOP_LIB_DIR have been set.");
+ }
+ std::string lFopJarFile;
+ {
+ // Here we look for the fop.jar file, which should be either in $FOP_HOME/build or
+ // in the directory, where all jar files are.
+ lFopJarFile = lFopHome + lDirectorySeparator + "build" + lDirectorySeparator + "fop.jar";
+ std::string lFopJarFile1 = lFopJarFile;
+ File_t lJarFile = File::createFile(lFopJarFile);
+ if (!lJarFile->exists()) {
+ lFopJarFile = lFopLibDir + lDirectorySeparator + "fop.jar";
+ lJarFile = File::createFile(lFopJarFile);
+ if (!lJarFile->exists()) {
+ std::string errmsg = "Could not find fop.jar. If you are using Ubuntu or Mac OS X, please make sure, ";
+ errmsg += "that you have installed it, else make sure, that you have set the envroinment variable ";
+ errmsg += "FOP_HOME or FOP_LIB_DIR correctly. Tried '";
+ errmsg += lFopJarFile1;
+ errmsg += "' and '";
+ errmsg += lFopJarFile;
+ errmsg += "'.";
+ throwError(errmsg);
+ }
+ }
+ }
+ std::vector<Item> lClassPath;
+ lClassPath.push_back(theFactory->createString(lFopJarFile));
+ {
+ std::string lJarDir = lFopLibDir;
+ if (lFopHome != "")
+ lJarDir = lFopHome + lDirectorySeparator + "lib";
+ // This is a list of all jar files, Apache Fop depends on.
+ std::list<std::string> lDeps;
+ lDeps.push_back("avalon-framework");
+ lDeps.push_back("batik-all");
+ lDeps.push_back("commons-io");
+ lDeps.push_back("commons-logging");
+ lDeps.push_back("serializer");
+ lDeps.push_back("xalan");
+ lDeps.push_back("xmlgraphics-commons");
+
+ File_t lJarDirF = File::createFile(lJarDir);
+ DirectoryIterator_t lFiles = lJarDirF->files();
+ std::string lFile; size_t count = 0;
+ // We check for all files, if it is a potential dependency and add it to
+ // the result
+ while (lFiles->next(lFile)) {
+ // If the file is not a jar file, we don't do anything
+ if (lFile.substr(lFile.size() - 4, std::string::npos) != ".jar")
+ continue;
+ for (std::list<std::string>::iterator i = lDeps.begin(); i != lDeps.end(); ++i) {
+ std::string lSub = lFile.substr(0, i->size());
+ if (lSub == *i) {
+ std::string lFull = lJarDir + lDirectorySeparator + lFile;
+ File_t f = File::createFile(lFull);
+ if (f->exists() && !f->isDirectory()) {
+ lClassPath.push_back(theFactory->createString(lFull));
+ // We count all jar files we add to the dependencies.
+ ++count;
+ break;
+ }
+ }
+ }
+ }
+ // Last, we check if all dependencies are found
+ if (count < lDeps.size()) {
+ std::string errmsg = "Could not find ";
+ errmsg += lDeps.front();
+ throwError(errmsg);
+ }
+ }
+ return ItemSequence_t(new VectorItemSequence(lClassPath));
+}
+
+ItemSequence_t
+GeneratePDFFunction::evaluate(const ExternalFunction::Arguments_t& args,
+ const zorba::StaticContext* aStaticContext,
+ const zorba::DynamicContext* aDynamincContext) const
+{
+ Iterator_t lIter = args[0]->getIterator();
+ lIter->open();
+ Item outputFormat;
+ lIter->next(outputFormat);
+ lIter->close();
+ jthrowable lException = 0;
+ static JNIEnv* env;
+ try {
+ env = zorba::jvm::JavaVMSingelton::getInstance(aStaticContext)->getEnv();
+ jstring outFotmatString = env->NewStringUTF(outputFormat.getStringValue().c_str());
+ // Local variables
+ std::ostringstream os;
+ Zorba_SerializerOptions_t lOptions;
+ Serializer_t lSerializer = Serializer::createSerializer(lOptions);
+ jclass fopFactoryClass;
+ jobject fopFactory;
+ jmethodID fopFactoryNewInstance;
+ jclass byteArrayOutputStreamClass;
+ jobject byteArrayOutputStream;
+ jobject fop;
+ jmethodID newFop;
+ jclass transformerFactoryClass;
+ jobject transformerFactory;
+ jobject transormer;
+ jclass stringReaderClass;
+ jobject stringReader;
+ jstring xmlUTF;
+ const char* xml;
+ std::string xmlString;
+ jclass streamSourceClass;
+ jobject streamSource;
+ jobject defaultHandler;
+ jclass saxResultClass;
+ jobject saxResult;
+ jboolean isCopy;
+ jbyteArray res;
+ Item base64;
+ String resStore;
+ jsize dataSize;
+ jbyte* dataElements;
+
+ Item item;
+ lIter = args[1]->getIterator();
+ lIter->open();
+ lIter->next(item);
+ lIter->close();
+ // Searialize Item
+ SingletonItemSequence lSequence(item);
+ lSerializer->serialize(&lSequence, os);
+ xmlString = os.str();
+ xml = xmlString.c_str();
+
+ // Create an OutputStream
+ byteArrayOutputStreamClass = env->FindClass("java/io/ByteArrayOutputStream");
+ CHECK_EXCEPTION(env);
+ byteArrayOutputStream = env->NewObject(byteArrayOutputStreamClass,
+ env->GetMethodID(byteArrayOutputStreamClass, "<init>", "()V"));
+ CHECK_EXCEPTION(env);
+
+ // Create a FopFactory instance
+ fopFactoryClass = env->FindClass("org/apache/fop/apps/FopFactory");
+ CHECK_EXCEPTION(env);
+ fopFactoryNewInstance = env->GetStaticMethodID(fopFactoryClass, "newInstance", "()Lorg/apache/fop/apps/FopFactory;");
+ CHECK_EXCEPTION(env);
+ fopFactory = env->CallStaticObjectMethod(fopFactoryClass, fopFactoryNewInstance);
+ CHECK_EXCEPTION(env);
+
+ // Create the Fop
+ newFop = env->GetMethodID(fopFactoryClass, "newFop", "(Ljava/lang/String;Ljava/io/OutputStream;)Lorg/apache/fop/apps/Fop;");
+ CHECK_EXCEPTION(env);
+ fop = env->CallObjectMethod(fopFactory,
+ newFop,
+ outFotmatString, byteArrayOutputStream);
+ CHECK_EXCEPTION(env);
+
+ // Create the Transformer
+ transformerFactoryClass = env->FindClass("javax/xml/transform/TransformerFactory");
+ CHECK_EXCEPTION(env);
+ transformerFactory = env->CallStaticObjectMethod(transformerFactoryClass,
+ env->GetStaticMethodID(transformerFactoryClass, "newInstance", "()Ljavax/xml/transform/TransformerFactory;"));
+ CHECK_EXCEPTION(env);
+ transormer = env->CallObjectMethod(transformerFactory,
+ env->GetMethodID(transformerFactoryClass, "newTransformer", "()Ljavax/xml/transform/Transformer;"));
+ CHECK_EXCEPTION(env);
+
+ // Create Source
+ xmlUTF = env->NewStringUTF(xml);
+ stringReaderClass = env->FindClass("java/io/StringReader");
+ CHECK_EXCEPTION(env);
+ stringReader = env->NewObject(stringReaderClass,
+ env->GetMethodID(stringReaderClass, "<init>", "(Ljava/lang/String;)V"), xmlUTF);
+ CHECK_EXCEPTION(env);
+ streamSourceClass = env->FindClass("javax/xml/transform/stream/StreamSource");
+ CHECK_EXCEPTION(env);
+ streamSource = env->NewObject(streamSourceClass,
+ env->GetMethodID(streamSourceClass, "<init>", "(Ljava/io/Reader;)V"), stringReader);
+ CHECK_EXCEPTION(env);
+
+ // Create the SAXResult
+ defaultHandler = env->CallObjectMethod(fop,
+ env->GetMethodID(env->FindClass("org/apache/fop/apps/Fop"), "getDefaultHandler",
+ "()Lorg/xml/sax/helpers/DefaultHandler;"));
+ CHECK_EXCEPTION(env);
+ saxResultClass = env->FindClass("javax/xml/transform/sax/SAXResult");
+ CHECK_EXCEPTION(env);
+ saxResult = env->NewObject(saxResultClass,
+ env->GetMethodID(saxResultClass, "<init>", "(Lorg/xml/sax/ContentHandler;)V"),
+ defaultHandler);
+ CHECK_EXCEPTION(env);
+
+ // Transform
+ env->CallObjectMethod(transormer,
+ env->GetMethodID(env->FindClass("javax/xml/transform/Transformer"),
+ "transform",
+ "(Ljavax/xml/transform/Source;Ljavax/xml/transform/Result;)V"),
+ streamSource, saxResult);
+ CHECK_EXCEPTION(env);
+
+ // Close outputstream
+ env->CallObjectMethod(byteArrayOutputStream,
+ env->GetMethodID(env->FindClass("java/io/OutputStream"),
+ "close", "()V"));
+ CHECK_EXCEPTION(env);
+ saxResultClass = env->FindClass("javax/xml/transform/sax/SAXResult");
+ CHECK_EXCEPTION(env);
+
+ // Get the byte array
+ res = (jbyteArray) env->CallObjectMethod(byteArrayOutputStream,
+ env->GetMethodID(byteArrayOutputStreamClass, "toByteArray", "()[B"));
+ CHECK_EXCEPTION(env);
+
+ // Create the result
+ dataSize = env->GetArrayLength(res);
+ dataElements = env->GetByteArrayElements(res, &isCopy);
+
+ std::string lBinaryString((const char*) dataElements, dataSize);
+ std::stringstream lStream(lBinaryString);
+ String base64S = encoding::Base64::encode(lStream);
+ Item lRes = theFactory->createBase64Binary(base64S.c_str(), base64S.length());
+ return ItemSequence_t(new SingletonItemSequence(lRes));
+ } catch (zorba::jvm::VMOpenException&) {
+ Item lQName = theFactory->createQName("http://www.zorba-xquery.com/modules/xsl-fo",
+ "VM001");
+ throw USER_EXCEPTION(lQName, "Could not start the Java VM (is the classpath set?)");
+ } catch (JavaException&) {
+ jclass stringWriterClass = env->FindClass("java/io/StringWriter");
+ jclass printWriterClass = env->FindClass("java/io/PrintWriter");
+ jclass throwableClass = env->FindClass("java/lang/Throwable");
+ jobject stringWriter = env->NewObject(
+ stringWriterClass,
+ env->GetMethodID(stringWriterClass, "<init>", "()V"));
+ jobject printWriter = env->NewObject(
+ printWriterClass, env->GetMethodID(printWriterClass, "<init>", "(Ljava/io/Writer;)V"), stringWriter);
+ env->CallObjectMethod(lException, env->GetMethodID(throwableClass, "printStackTrace", "(Ljava/io/PrintWriter;)V"), printWriter);
+ //env->CallObjectMethod(printWriter, env->GetMethodID(printWriterClass, "flush", "()V"));
+ jmethodID toStringMethod = env->GetMethodID(stringWriterClass, "toString", "()Ljava/lang/String;");
+ jobject errorMessageObj = env->CallObjectMethod(
+ stringWriter, toStringMethod);
+ jstring errorMessage = (jstring) errorMessageObj;
+ const char *errMsg = env->GetStringUTFChars(errorMessage, 0);
+ std::stringstream s;
+ s << "A Java Exception was thrown:" << std::endl << errMsg;
+ env->ReleaseStringUTFChars(errorMessage, errMsg);
+ std::string err("");
+ err += s.str();
+ env->ExceptionClear();
+ Item lQName = theFactory->createQName("http://www.zorba-xquery.com/modules/xsl-fo",
+ "JAVA-EXCEPTION");
+ throw USER_EXCEPTION(lQName, err);
+ }
+ return ItemSequence_t(new EmptySequence());
+}
+
+}}; // namespace zorba, xslfo
+
+#ifdef WIN32
+# define DLL_EXPORT __declspec(dllexport)
+#else
+# define DLL_EXPORT __attribute__ ((visibility("default")))
+#endif
+
+extern "C" DLL_EXPORT zorba::ExternalModule* createModule() {
+ return new zorba::xslfo::XSLFOModule();
+}
=== added directory 'test'
=== renamed directory 'test' => 'test.moved'
=== added directory 'test/ExpQueryResults'
=== added directory 'test/ExpQueryResults/data-formatting'
=== added file 'test/ExpQueryResults/data-formatting/xslfo.xml.res'
--- test/ExpQueryResults/data-formatting/xslfo.xml.res 1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/data-formatting/xslfo.xml.res 2012-03-16 22:09:19 +0000
@@ -0,0 +1,1 @@
+<pdf><len>6484</len><start>JVBERi0xLj</start><end>AolJUVPRgo=</end></pdf>
=== added directory 'test/Queries'
=== added directory 'test/Queries/data-formatting'
=== added file 'test/Queries/data-formatting/xslfo.xq'
--- test/Queries/data-formatting/xslfo.xq 1970-01-01 00:00:00 +0000
+++ test/Queries/data-formatting/xslfo.xq 2012-03-16 22:09:19 +0000
@@ -0,0 +1,27 @@
+import module namespace fop = "http://www.zorba-xquery.com/modules/xsl-fo";
+import module namespace file = "http://expath.org/ns/file";
+
+declare namespace fo = "http://www.w3.org/1999/XSL/Format";
+
+let $xsl-fo := <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="my-page">
+ <fo:region-body margin="1in"/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+
+ <fo:page-sequence master-reference="my-page">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>Hello, world!</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+let $pdfBase64Binary := fop:generator($fop:PDF, $xsl-fo)
+let $pdf := xs:string($pdfBase64Binary)
+let $len := fn:string-length($pdf)
+return
+ <pdf>
+ <len> { $len }</len>
+ <start>{ fn:substring($pdf, 1, 10)}</start>
+ <end> { fn:substring($pdf, $len -10, $len)}</end>
+ </pdf>
Follow ups