William Candillon has proposed merging 
lp:~zorba-coders/zorba/data-formatting-doc into lp:zorba/process-module.

Commit message:
Minor documentation improvements.

Requested reviews:
  William Candillon (wcandillon)
  Cezar Andrei (cezar-andrei)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/data-formatting-doc/+merge/126953

Minor documentation improvements.
-- 
https://code.launchpad.net/~zorba-coders/zorba/data-formatting-doc/+merge/126953
Your team Zorba Coders is subscribed to branch lp:zorba/process-module.
=== added file 'CMakeLists.txt'
--- CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ CMakeLists.txt	2012-09-28 12:58:20 +0000
@@ -0,0 +1,56 @@
+# 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)
+
+FIND_PACKAGE (zorba_util-jvm_module QUIET)
+
+IF (zorba_util-jvm_module_FOUND)
+  INCLUDE ("${zorba_util-jvm_module_USE_FILE}")
+
+  FIND_PACKAGE(JNI)
+  FIND_PACKAGE(Java)
+  FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}")
+  INCLUDE ("${Zorba_USE_FILE}")
+
+  IF (JNI_FOUND)
+    INCLUDE_DIRECTORIES (${zorba_util-jvm_module_INCLUDE_DIRS})
+
+    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 ()
+
+  ELSE (JNI_FOUND)
+    MESSAGE ( STATUS "Java and/or JNI not found; skipping data-formating module.")
+  ENDIF(JNI_FOUND)
+
+ELSE (zorba_util-jvm_module_FOUND)
+  MESSAGE (STATUS "Zorba's util-jvm module not found; skipping data-formatting module.")
+ENDIF (zorba_util-jvm_module_FOUND)
+
+
+MESSAGE (STATUS "******** END Configuring module Data-Formatting ********")

=== renamed file 'CMakeLists.txt' => 'CMakeLists.txt.moved'
=== added directory 'cmake_modules'
=== added file 'cmake_modules/FindJNI.cmake'
--- cmake_modules/FindJNI.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/FindJNI.cmake	2012-09-28 12:58:20 +0000
@@ -0,0 +1,286 @@
+# - 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/jvm/java-6-openjdk/jre/lib
+  /usr/lib/jvm/java-6-openjdk-i386/jre/lib
+  /usr/lib/jvm/java-6-openjdk-amd64/jre/lib
+  /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-openjdk-i386/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/{libarch}
+  /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-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/lib/jvm/java-6-openjdk/include
+  /usr/lib/jvm/java-6-openjdk-amd64/include
+  /usr/lib/jvm/java-6-openjdk-i386/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-09-28 12:58:20 +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-09-28 12:58:20 +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-09-28 12:58:20 +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-09-28 12:58:20 +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-09-28 12:58:20 +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-09-28 12:58:20 +0000
@@ -0,0 +1,105 @@
+# 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.
+
+  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)
+      SET (XSL_FOP_HOME "C:\\dev\\libraries\\fop-1.0 C:\\dev\\libraries\\fop-1.0\\lib C:\\dev\\libraries\\fop-1.0\\build")
+    ELSE (WIN32)
+      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})
+    ENDIF (WIN32)
+    MESSAGE (STATUS "XSL_FOP_HOME not defined, trying defaults: ${XSL_FOP_HOME}")
+  ENDIF (NOT DEFINED XSL_FOP_HOME)
+  
+  STRING(REGEX REPLACE "\\\\" "/" XSL_FOP_HOME "${XSL_FOP_HOME}")
+  
+  MESSAGE (STATUS "XSL-FOP HOME: ${XSL_FOP_HOME}")
+  ZORBA_FIND_JAR ( FOP_JAR    NAMES fop
+    PATHS ${XSL_FOP_HOME} PATH_SUFFIXES build)
+  ZORBA_FIND_JAR ( FOP_D1_JAR NAMES avalon-framework
+    PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib )
+  ZORBA_FIND_JAR ( FOP_D2_JAR NAMES batik-all
+    PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib )
+  ZORBA_FIND_JAR ( FOP_D3_JAR NAMES commons-io
+    PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib )
+  ZORBA_FIND_JAR ( FOP_D4_JAR NAMES commons-logging
+    PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib )
+  ZORBA_FIND_JAR ( FOP_D5_JAR NAMES serializer
+    PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib )
+  ZORBA_FIND_JAR ( FOP_D6_JAR NAMES xalan xalan2
+    PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib )
+  ZORBA_FIND_JAR ( FOP_D7_JAR NAMES xmlgraphics-commons
+    PATHS ${XSL_FOP_HOME} PATH_SUFFIXES lib )
+
+  # Multiple "EXISTS" clauses can't be used in a single IF() command;
+  # looks like a bug in 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} )
+  			
+  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}" ${zorba_util-jvm_module_LIBRARIES})
+
+    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/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")
+    MESSAGE ( STATUS " fop: " ${FOP_JAR} "\n    avalon: " ${FOP_D1_JAR}
+  			"\n    batik: " ${FOP_D2_JAR} "\n    io: " ${FOP_D3_JAR} 
+  			"\n    logging: " ${FOP_D4_JAR} "\n    serializer: " ${FOP_D5_JAR} "  " 
+  			"\n    xalan: " ${FOP_D6_JAR} "\n    xmlgraphics: " ${FOP_D7_JAR} )
+  ENDIF ( ALL_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-09-28 12:58:20 +0000
@@ -0,0 +1,161 @@
+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="ace-static" ace-mode="xquery"><![CDATA[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 Zorba/Data Formatting/XSL-FO
+ :)
+module namespace xsl-fo = "http://www.zorba-xquery.com/modules/xsl-fo";;
+
+import module namespace util-jvm = "http://www.zorba-xquery.com/modules/util-jvm";;
+
+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/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-09-28 12:58:20 +0000
@@ -0,0 +1,280 @@
+/*
+ * 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 "JavaVMSingleton.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 XSLFOModule : public ExternalModule {
+  private:
+    ExternalFunction* generatePDF;
+  public:
+    XSLFOModule() :
+      generatePDF(new GeneratePDFFunction(this))
+  {}
+    ~XSLFOModule() {
+      delete generatePDF;
+    }
+
+    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;
+  } 
+  return 0;
+}
+
+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::JavaVMSingleton::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-09-28 12:58:20 +0000
@@ -0,0 +1,1 @@
+<pdf><len>true</len><start>JVBERi0xLj</start></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-09-28 12:58:20 +0000
@@ -0,0 +1,26 @@
+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 gt 6000 }</len>
+    <start>{ fn:substring($pdf, 1, 10)}</start>
+  </pdf>

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to