← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/fread-pdf-trunk into lp:~zorba-coders/zorba/zorba-experimental

 

Cezar Andrei has proposed merging lp:~zorba-coders/zorba/fread-pdf-trunk into lp:~zorba-coders/zorba/zorba-experimental.

Commit message:
Testing doc for new read-pdf module.

Requested reviews:
  Cezar Andrei (cezar-andrei)
Related bugs:
  Bug #1012417 in Zorba: "PDF to XML data convertor"
  https://bugs.launchpad.net/zorba/+bug/1012417

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fread-pdf-trunk/+merge/126757

Testing doc.
-- 
The attached diff has been truncated due to its size.
https://code.launchpad.net/~zorba-coders/zorba/fread-pdf-trunk/+merge/126757
Your team Zorba Coders is subscribed to branch lp:~zorba-coders/zorba/fread-pdf-trunk.
=== added file '.bzrignore'
--- .bzrignore	1970-01-01 00:00:00 +0000
+++ .bzrignore	2012-09-27 18:04:43 +0000
@@ -0,0 +1,2 @@
+CMakeLists.txt.user
+build

=== modified file 'AUTHORS.txt'
--- AUTHORS.txt	2011-02-09 15:40:01 +0000
+++ AUTHORS.txt	2012-09-27 18:04:43 +0000
@@ -22,18 +22,24 @@
   * Matthias Brantner
   * Nicolae Brinza
   * William Candillon
-  * Dana Florescu                                                                                       
+  * Dana Florescu
   * David Graf
   * Chris Hillery
   * Donald Kossmann 
   * Tim Kraska
   * Paul Kunz
+  * Carlos Lopez
   * Paul Lucas
   * Dan Muresan
   * Sorin Nasoi
+  * Rodolfo Ochoa
   * Paul Pedersen
   * Gabriel Petrovay
   * Markus Pilman
   * Sam Rehman
+  * Luis Rodriguez
+  * Daniel Thomas
   * Daniel Turcanu
+  * Till Westmann
+  * Juan Zacarias
   * Markos Zaharioudakis

=== modified file 'CMakeCPack.cmake'
--- CMakeCPack.cmake	2009-10-30 16:24:51 +0000
+++ CMakeCPack.cmake	2012-09-27 18:04:43 +0000
@@ -17,6 +17,75 @@
 SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.txt")
 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
 
+
+SET(CPACK_NSIS_COMPONENT_INSTALL ON)
+SET(CPACK_COMPONENT_UNSPECIFIED_HIDDEN "FALSE")
+
+SET(CPACK_COMPONENT_UNSPECIFIED_DISPLAY_NAME "Zorba")
+SET(CPACK_COMPONENT_DOC_DISPLAY_NAME "Docs")
+SET(CPACK_COMPONENT_PHP_EXAMPLES_DISPLAY_NAME "PHP Examples")
+SET(CPACK_COMPONENT_CXX_EXAMPLES_DISPLAY_NAME "CXX Examples")
+SET(CPACK_COMPONENT_PYTHON_EXAMPLES_DISPLAY_NAME "Python Examples")
+SET(CPACK_COMPONENT_RUBY_EXAMPLES_DISPLAY_NAME "Ruby Examples")
+SET(CPACK_COMPONENT_JAVA_SWIG_DISPLAY_NAME "Java API")
+SET(CPACK_COMPONENT_PHP_SWIG_DISPLAY_NAME "PHP API")
+SET(CPACK_COMPONENT_PYTHON_SWIG_DISPLAY_NAME "Python API")
+SET(CPACK_COMPONENT_RUBY_SWIG_DISPLAY_NAME "Ruby API")
+SET(CPACK_COMPONENT_XQJ_SWIG_DISPLAY_NAME "Java XQJ API")
+SET(CPACK_COMPONENT_THESAURUS_DISPLAY_NAME "Thesaurus")
+SET(CPACK_COMPONENT_CSHARP_SWIG_DISPLAY_NAME "C# API")
+
+SET(CPACK_COMPONENT_UNSPECIFIED_DESCRIPTION "Zorba Required Files.")
+SET(CPACK_COMPONENT_DOC_DESCRIPTION "Files with the Description of different features of zorba.")
+SET(CPACK_COMPONENT_PHP_EXAMPLES_DESCRIPTION "Examples for the PHP extension.")
+SET(CPACK_COMPONENT_PYTHON_EXAMPLES_DESCRIPTION "Examples for the Python extension.")
+SET(CPACK_COMPONENT_RUBY_EXAMPLES_DESCRIPTION "Examples for the Ruby extension.")
+SET(CPACK_COMPONENT_CXX_EXAMPLES_DESCRIPTION "Examples for CXX.")
+SET(CPACK_COMPONENT_JAVA_SWIG_DESCRIPTION "API for Java")
+SET(CPACK_COMPONENT_PHP_SWIG_DESCRIPTION "API for PHP")
+SET(CPACK_COMPONENT_PYTHON_SWIG_DESCRIPTION "API for Python")
+SET(CPACK_COMPONENT_RUBY_SWIG_DESCRIPTION "API for Ruby")
+SET(CPACK_COMPONENT_XQJ_SWIG_DESCRIPTION "XQJ API for Java")
+SET(CPACK_COMPONENT_THESAURUS_DESCRIPTION "Thesaurus for Zorba")
+SET(CPACK_COMPONENT_CSHARP_SWIG_DESCRIPTION "API for C#")
+
+SET(CPACK_COMPONENT_DOC_GROUP "Documents")
+SET(CPACK_COMPONENT_PHP_EXAMPLES_GROUP "Documents")
+SET(CPACK_COMPONENT_PYTHON_EXAMPLES_GROUP "Documents")
+SET(CPACK_COMPONENT_RUBY_EXAMPLES_GROUP "Documents")
+SET(CPACK_COMPONENT_CXX_EXAMPLES_GROUP "Documents")
+
+SET(CPACK_COMPONENT_JAVA_SWIG_GROUP "APIs")
+SET(CPACK_COMPONENT_PHP_SWIG_GROUP "APIs")
+SET(CPACK_COMPONENT_PYTHON_SWIG_GROUP "APIs")
+SET(CPACK_COMPONENT_RUBY_SWIG_GROUP "APIs")
+SET(CPACK_COMPONENT_XQJ_SWIG_GROUP "APIs")
+SET(CPACK_COMPONENT_CSHARP_SWIG_GROUP "APIs")
+
+SET(CPACK_COMPONENT_GROUP_EXTERNAL_MODULES_DISPLAY_NAME "External Modules")
+SET(CPACK_COMPONENT_GROUP_EXTERNAL_MODULES_DESCRIPTION "Complete list of external modules.")
+SET(CPACK_COMPONENT_GROUP_DOCUMENTS_DESCRIPTION "Complete Documentation of Zorba and Modules.")
+SET(CPACK_COMPONENT_GROUP_APIS_DESCRIPTION "APIs to work with zorba.")
+
+SET(CPACK_ALL_INSTALL_TYPES Full Simple Lite)
+
+SET(CPACK_COMPONENT_DOC_INSTALL_TYPES Full Simple)
+SET(CPACK_COMPONENT_PHP_EXAMPLES_INSTALL_TYPES Full Simple)
+SET(CPACK_COMPONENT_PYTHON_EXAMPLES_INSTALL_TYPES Full Simple)
+SET(CPACK_COMPONENT_RUBY_EXAMPLES_INSTALL_TYPES Full Simple)
+SET(CPACK_COMPONENT_CXX_EXAMPLES_INSTALL_TYPES Full Simple)
+SET(CPACK_COMPONENT_JAVA_SWIG_INSTALL_TYPES Full)
+SET(CPACK_COMPONENT_PYTHON_SWIG_INSTALL_TYPES Full)
+SET(CPACK_COMPONENT_PHP_SWIG_INSTALL_TYPES Full)
+SET(CPACK_COMPONENT_RUBY_SWIG_INSTALL_TYPES Full)
+SET(CPACK_COMPONENT_XQJ_SWIG_INSTALL_TYPES Full)
+SET(CPACK_COMPONENT_UNSPECIFIED_INSTALL_TYPES Full Simple Lite)
+SET(CPACK_COMPONENT_THESAURUS_INSTALL_TYPES Full)
+SET(CPACK_COMPONENT_CSHARP_SWIG_INSTALL_TYPES Full)
+
+INCLUDE(${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake)
+
+
 CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/CMakeCPackOptions.cmake.in"
                "${CMAKE_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY)
 SET(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CMakeCPackOptions.cmake")

=== modified file 'CMakeCPackOptions.cmake.in'
--- CMakeCPackOptions.cmake.in	2011-06-28 17:47:40 +0000
+++ CMakeCPackOptions.cmake.in	2012-09-27 18:04:43 +0000
@@ -22,13 +22,23 @@
 
 # for Windows Null Soft Installer System ...
 if(CPACK_GENERATOR MATCHES "NSIS")
-  SET(CPACK_PACKAGE_EXECUTABLES "zorba" "Zorba Command Line Client" )
-
-  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\zoba.exe")
   SET(CPACK_NSIS_DISPLAY_NAME "Zorba XQuery Processor ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
   SET(CPACK_NSIS_HELP_LINK "http:\\\\http://www.zorba-xquery.org/";)
   SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\http://www.zorba-xquery.org/";)
   SET(CPACK_NSIS_CONTACT "info@xxxxxxxxxxxxxx")
+  
+  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
+    CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Zorba Command Line Client.lnk' 'cmd.exe' '/K set path=%path%;%JAVA_HOME%;%JAVA_HOME%\\client;%cd%\\bin;&echo Start using Zorba: zorba -q 1+1  or  zorba -f -q example.xq'
+    CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Zorba Documentation.lnk' '$INSTDIR\\\\share\\\\doc\\\\zorba-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\\\\zorba\\\\html\\\\index.html'
+    CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Modules Documentation.lnk' '$INSTDIR\\\\share\\\\doc\\\\zorba-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\\\\zorba\\\\xqdoc\\\\xhtml\\\\index.html'
+    ")
+  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
+    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
+    Delete '$SMPROGRAMS\\\\$MUI_TEMP\\\\Zorba Command Line Client.lnk'
+    Delete '$SMPROGRAMS\\\\$MUI_TEMP\\\\Zorba Documentation.lnk'
+    Delete '$SMPROGRAMS\\\\$MUI_TEMP\\\\Modules Documentation.lnk' 
+    ")
+  
   SET(CPACK_NSIS_MODIFY_PATH ON)
 endif(CPACK_GENERATOR MATCHES "NSIS")
 

=== modified file 'CMakeCompiler.txt'
--- CMakeCompiler.txt	2011-01-19 12:48:17 +0000
+++ CMakeCompiler.txt	2012-09-27 18:04:43 +0000
@@ -13,11 +13,18 @@
 # limitations under the License. 
 
 
-IF (${CMAKE_CXX_COMPILER} MATCHES "clang")
- SET (CLANG 1)
-ELSE (${CMAKE_CXX_COMPILER} MATCHES "clang")
- SET (CLANG 0)
-ENDIF(${CMAKE_CXX_COMPILER} MATCHES "clang")
+# check if clang is used to compile c++
+EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
+               ARGS --version
+               OUTPUT_VARIABLE CXX_COMPILER_VERSION_OUTPUT
+)
+STRING(REGEX MATCH "clang"
+  CXX_IS_CLANG "${CXX_COMPILER_VERSION_OUTPUT}")
+IF (CXX_IS_CLANG)
+  SET (CLANG 1)
+ELSE ()
+  SET (CLANG 0)
+ENDIF ()
 
 #-----------------------------------------------------------------------------
 # Let's use the highest warning level.
@@ -108,6 +115,9 @@
   IF(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
   ENDIF(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
+  IF(NOT CMAKE_CXX_FLAGS MATCHES "-D_FILE_OFFSET_BITS")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64")
+  ENDIF(NOT CMAKE_CXX_FLAGS MATCHES "-D_FILE_OFFSET_BITS")
   IF (UNIX AND NOT APPLE)
     IF (NOT CMAKE_SHARED_LINKER_FLAGS MATCHES "as-needed")
       SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
@@ -231,3 +241,24 @@
     ENDIF (NOT CMAKE_C_FLAGS MATCHES "-fvisibility")
   ENDIF ( ZORBA_GNUCOMPILER_MAJOR_VERSION GREATER 3 )
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
+
+IF (APPLE)
+  # Needed for CFUUID*() functions in util/uuid.c.
+  SET(CMAKE_SHARED_LINKER_FLAGS "-framework CoreFoundation ${CMAKE_SHARED_LINKER_FLAGS}")
+ELSEIF (WIN32)
+  # Needed for UuidCreateSequential() function in util/uuid.c.
+  SET(requiredlibs ${requiredlibs} "Rpcrt4")
+ELSEIF (ZORBA_HAVE_UUID_H)
+  # Needed for uuid_generate() function in util/uuid.c.
+  SET(requiredlibs ${requiredlibs} "uuid")
+  # Double-check that we can link against the required library.
+  CHECK_LIBRARY_EXISTS(uuid uuid_generate "" LIBUUID_EXISTS)
+  IF (NOT LIBUUID_EXISTS)
+    MESSAGE (FATAL_ERROR "Could not find libuuid - required on Linux!")
+  ENDIF (NOT LIBUUID_EXISTS)
+ELSE (APPLE)
+  # We're not Apple or Win32, and we didn't find uuid.h - can't compile
+  MESSAGE (FATAL_ERROR "Could not find uuid/uuid.h header, which is "
+    "required on Linux. On Ubuntu, the 'uuid-dev' package is required; "
+    "look for similar packages on other platforms.")
+ENDIF (APPLE)

=== modified file 'CMakeConfiguration.txt'
--- CMakeConfiguration.txt	2011-07-01 10:27:23 +0000
+++ CMakeConfiguration.txt	2012-09-27 18:04:43 +0000
@@ -70,10 +70,6 @@
 SET(ZORBA_FOR_ONE_THREAD_ONLY OFF CACHE BOOL "compile zorba for single threaded use")
 MESSAGE(STATUS "ZORBA_FOR_ONE_THREAD_ONLY:            " ${ZORBA_FOR_ONE_THREAD_ONLY})
 
-# by default the zorba command line client is deactivated until it gets to a more stable and userfriendly state
-SET(ZORBA_WITH_DEBUGGER_CLIENT OFF CACHE BOOL "build and install zorbas command line debugger client")
-MESSAGE(STATUS "ZORBA_WITH_DEBUGGER_CLIENT:           " ${ZORBA_WITH_DEBUGGER_CLIENT})
-
 IF (DEFINED UNIX)
   IF (NOT DEFINED ZORBA_HAVE_PTHREAD_H AND NOT DEFINED ZORBA_FOR_ONE_THREAD_ONLY)
     MESSAGE(FATAL_ERROR "pthread is not available")
@@ -96,11 +92,16 @@
 SET(ZORBA_TEST_TIMEOUT_VALUE 60 CACHE INTEGER "default test timeout value")
 MESSAGE(STATUS "ZORBA_TEST_TIMEOUT_VALUE:             " ${ZORBA_TEST_TIMEOUT_VALUE})
 
+SET(ZORBA_VERIFY_PEER_SSL_CERTIFICATE OFF CACHE BOOL "Disable root certificate validation")
+MESSAGE(STATUS "ZORBA_VERIFY_PEER_SSL_CERTIFICATE:    " ${ZORBA_VERIFY_PEER_SSL_CERTIFICATE})
+
 IF(${ZORBA_WITH_CODE_PROFILE})
   SET(ZORBA_BUILD_STATIC_LIBRARY ON CACHE BOOL "build a static library, e.g. when creating a profile")
 ELSE(${ZORBA_WITH_CODE_PROFILE})
   SET(ZORBA_BUILD_STATIC_LIBRARY OFF CACHE BOOL "build a static library, e.g. when creating a release")
 ENDIF(${ZORBA_WITH_CODE_PROFILE})
+MESSAGE(STATUS "ZORBA_WITH_CODE_PROFILE:              " ${ZORBA_WITH_CODE_PROFILE})
+
 MESSAGE(STATUS "ZORBA_BUILD_STATIC_LIBRARY:           " ${ZORBA_BUILD_STATIC_LIBRARY})
 
 IF(MSVC AND NOT ZORBA_BUILD_STATIC_LIBRARY)
@@ -112,28 +113,36 @@
 
 # We need the path to the zorba executable because it will be used during the
 # build to generate source code and documentation.
-SET(ZORBA_EXE_SCRIPT "${CMAKE_BINARY_DIR}/bin/zorba")
+SET(ZORBA_EXE "${CMAKE_BINARY_DIR}/bin/zorba")
 IF(WIN32)
-  SET(ZORBA_EXE_SCRIPT "${ZORBA_EXE_SCRIPT}.bat")
+  SET(ZORBA_EXE "${ZORBA_EXE}.bat")
 ENDIF(WIN32)
-SET(ZORBA_EXE_SCRIPT ${ZORBA_EXE_SCRIPT} CACHE STRING "executable used for generating the runtime")
-MESSAGE(STATUS "ZORBA_EXE_SCRIPT:                      " ${ZORBA_EXE_SCRIPT})
+SET(ZORBA_EXE ${ZORBA_EXE} CACHE STRING "executable used for generating the runtime")
+MESSAGE(STATUS "ZORBA_EXE:                            " ${ZORBA_EXE})
 
 # flags for debugging the parser
 SET(ZORBA_DEBUG_PARSER OFF CACHE BOOL "debug the parser")
 MESSAGE(STATUS "ZORBA_DEBUG_PARSER:                   " ${ZORBA_DEBUG_PARSER})
 
-SET(ZORBA_DEBUG_STRING OFF CACHE BOOL "debug strings")
-MESSAGE(STATUS "ZORBA_DEBUG_STRING:                   " ${ZORBA_DEBUG_STRING})
-
-SET(ZORBA_NO_UNICODE OFF CACHE BOOL "disable ICU")
-MESSAGE(STATUS "ZORBA_NO_UNICODE:                     " ${ZORBA_NO_UNICODE})
-
-IF (ZORBA_NO_UNICODE)
+# if not set by the user, set ZORBA_DEBUG_STRING to ON for Debug and RelWithDebInfo builds
+IF (NOT ZORBA_DEBUG_STRING)
+  IF (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
+    SET (ZORBA_DEBUG_STRING ON)
+  ELSE (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
+    SET (ZORBA_DEBUG_STRING OFF)
+  ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
+ENDIF (NOT ZORBA_DEBUG_STRING)
+SET (ZORBA_DEBUG_STRING ${ZORBA_DEBUG_STRING} CACHE BOOL "debug strings")
+MESSAGE (STATUS "ZORBA_DEBUG_STRING:                   " ${ZORBA_DEBUG_STRING})
+
+SET(ZORBA_NO_ICU OFF CACHE BOOL "disable ICU")
+MESSAGE(STATUS "ZORBA_NO_ICU:                         " ${ZORBA_NO_ICU})
+
+IF (ZORBA_NO_ICU)
   SET (no_full_text ON)
-ELSE (ZORBA_NO_UNICODE)
+ELSE (ZORBA_NO_ICU)
   SET (no_full_text OFF)
-ENDIF (ZORBA_NO_UNICODE)
+ENDIF (ZORBA_NO_ICU)
 SET (ZORBA_NO_FULL_TEXT ${no_full_text} CACHE BOOL "disable XQuery Full-Text support")
 MESSAGE(STATUS "ZORBA_NO_FULL_TEXT:                   " ${ZORBA_NO_FULL_TEXT})
 
@@ -143,13 +152,20 @@
 SET(ZORBA_WITH_BIG_INTEGER OFF CACHE BOOL "enable arbitrary precision integers")
 MESSAGE(STATUS "ZORBA_WITH_BIG_INTEGER:               " ${ZORBA_WITH_BIG_INTEGER})
 
-IF (SWIG_FOUND)
-  SET (use_swig ON)
-ELSE (SWIG_FOUND)
+SET(ZORBA_WITH_JSON ON CACHE BOOL "enable integrated JSON support")
+MESSAGE(STATUS "ZORBA_WITH_JSON:                      " ${ZORBA_WITH_JSON})
+
+SET(ZORBA_WITH_THESAURUS ON CACHE BOOL
+    "enable installation of default English Wordnet thesaurus")
+MESSAGE(STATUS "ZORBA_WITH_THESAURUS:                 " ${ZORBA_WITH_THESAURUS})
+
+IF (ZORBA_SUPPRESS_SWIG)
+  SET (no_swig ON)
+ELSE (ZORBA_SUPPRESS_SWIG)
   SET (no_swig OFF)
-ENDIF (SWIG_FOUND)
-SET(ZORBA_USE_SWIG ${no_swig} CACHE BOOL "use Swig to generate api for Python, Php and Ruby")
-MESSAGE(STATUS "ZORBA_USE_SWIG:                       " ${ZORBA_USE_SWIG})
+ENDIF (ZORBA_SUPPRESS_SWIG)
+SET(ZORBA_SUPPRESS_SWIG ${no_swig} CACHE BOOL "use Swig to generate api for Python, Php and Ruby")
+MESSAGE(STATUS "ZORBA_SUPPRESS_SWIG [ON/OFF]:         " ${no_swig})
 
 SET(ZORBA_XQUERYX OFF CACHE BOOL "Activate capability to compile XQueryX code (on/off)")
 MESSAGE(STATUS "ZORBA_XQUERYX:                        " ${ZORBA_XQUERYX})

=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2011-07-06 20:43:46 +0000
+++ CMakeLists.txt	2012-09-27 18:04:43 +0000
@@ -22,9 +22,6 @@
 SET(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 SET(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
-# Enable RPaths in installed binaries
-SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
-
 INCLUDE(${CMAKE_SOURCE_DIR}/cmake_modules/CMakeCompareVersionStrings.cmake)
 
 cmake_minimum_required(VERSION 2.6)
@@ -52,29 +49,29 @@
   MESSAGE(FATAL_ERROR "Please create a separate build directory and call CMake again")
 ENDIF(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
 
-IF (MSVC)
-  IF (CMAKE_BUILD_TYPE)
-    MESSAGE (STATUS "You provided CMAKE_BUILD_TYPE but the Visual Studio generator cannot make use of it. So I'd better clear it now! Sorry! :(")
-    SET (CMAKE_BUILD_TYPE)
-  ELSE (CMAKE_BUILD_TYPE)
-    MESSAGE (STATUS "No CMAKE_BUILD_TYPE was provided, which is exactly what the Visual Studio generator expects from you. Very good! Weiter machen! :)")
-  ENDIF(CMAKE_BUILD_TYPE)
-ELSE(MSVC)
-  # set the default build type to release
-  # NOTE: the "NMake Makefiles" generator will always set the default build type to "Debug"
-  IF(NOT CMAKE_BUILD_TYPE)
-    SET(CMAKE_BUILD_TYPE Release CACHE STRING
-        "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
-        FORCE)
-  ENDIF(NOT CMAKE_BUILD_TYPE)
-ENDIF(MSVC)
+# set the default build type to release
+# NOTE: the "NMake Makefiles" generator will always set the default build type to "Debug"
+IF (NOT CMAKE_BUILD_TYPE)
+  SET (CMAKE_BUILD_TYPE Release CACHE STRING
+       "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+       FORCE)
+ENDIF (NOT CMAKE_BUILD_TYPE)
 
 # set the default installation directory to "dist" in the build directory
 IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
-  SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/dist CACHE STRING
-      "Set the defalt installation directory to \"dist\" in the binary directory." FORCE)
-ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
-
+  SET (CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/dist CACHE STRING
+       "Set the defalt installation directory to \"dist\" in the binary directory." FORCE)
+ENDIF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+
+# Enable RPaths in installed binaries
+SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+# turn on the folder grouping used by IDEs (VS or XCode)
+SET(ZORBA_USE_TARGET_FOLDERS ON CACHE BOOL "Activate use of target grouping into folders")
+IF(ZORBA_USE_TARGET_FOLDERS)
+  SET_PROPERTY (GLOBAL PROPERTY USE_FOLDERS ON)
+ENDIF(ZORBA_USE_TARGET_FOLDERS)
 
 ###############################################################################
 # Check for system include files, features, etc.
@@ -104,6 +101,7 @@
   CHECK_INCLUDE_FILES ("execinfo.h"                   ZORBA_HAVE_EXECINFO_H)
 ENDIF (NOT APPLE OR ${CMAKE_SYSTEM_VERSION} VERSION_GREATER "10.4")
 CHECK_INCLUDE_FILE_CXX ("FlexLexer.h"               ZORBA_HAVE_FLEXLEXER_H)
+CHECK_INCLUDE_FILES ("uuid/uuid.h"                  ZORBA_HAVE_UUID_H)
 
 CHECK_FUNCTION_EXISTS (strtof                     ZORBA_HAVE_STRTOF_FUNCTION)
 CHECK_FUNCTION_EXISTS (strtoll                    ZORBA_HAVE_STRTOLL_FUNCTION)
@@ -126,23 +124,90 @@
 CHECK_TYPE_SIZE("__int32" ZORBA_HAVE_MS_INT32) 
 CHECK_TYPE_SIZE("int64_t" ZORBA_HAVE_INT64_T) 
 
-CHECK_CXX_SOURCE_COMPILES ("int main() { int *p = nullptr; }" ZORBA_CXX_NULLPTR)
-CHECK_CXX_SOURCE_COMPILES ("int main() { static_assert(1,\"\"); }" ZORBA_CXX_STATIC_ASSERT)
+# C++ built-in type sizes
+CHECK_TYPE_SIZE("double" ZORBA_SIZEOF_DOUBLE BUILTIN_TYPES_ONLY) 
+CHECK_TYPE_SIZE("float" ZORBA_SIZEOF_FLOAT BUILTIN_TYPES_ONLY) 
+CHECK_TYPE_SIZE("int" ZORBA_SIZEOF_INT BUILTIN_TYPES_ONLY) 
+CHECK_TYPE_SIZE("long" ZORBA_SIZEOF_LONG BUILTIN_TYPES_ONLY) 
+CHECK_TYPE_SIZE("long long" ZORBA_SIZEOF_LONG_LONG BUILTIN_TYPES_ONLY) 
+CHECK_TYPE_SIZE("void*" ZORBA_SIZEOF_POINTER BUILTIN_TYPES_ONLY) 
+CHECK_TYPE_SIZE("short" ZORBA_SIZEOF_SHORT BUILTIN_TYPES_ONLY) 
+CHECK_TYPE_SIZE("size_t" ZORBA_SIZEOF_SIZE_T) 
+SET(CMAKE_EXTRA_INCLUDE_FILES wchar.h)
+CHECK_TYPE_SIZE("wchar_t" ZORBA_SIZEOF_WCHAR_T)
+SET(CMAKE_EXTRA_INCLUDE_FILES)
+
+# C++11 langauge features
+CHECK_CXX_SOURCE_COMPILES(
+  "int main() { int *p = nullptr; }" ZORBA_CXX_NULLPTR)
+CHECK_CXX_SOURCE_COMPILES(
+  "int main() { static_assert(1,\"\"); }" ZORBA_CXX_STATIC_ASSERT)
+
+# C++11 standard library types
+CHECK_CXX_SOURCE_COMPILES (
+  "#include <type_traits>
+  int main() { std::enable_if<true,int> x; }" ZORBA_HAVE_ENABLE_IF)
+CHECK_CXX_SOURCE_COMPILES ("
+  #include <memory>
+  int main() { std::unique_ptr<int> p; }" ZORBA_HAVE_UNIQUE_PTR)
+CHECK_CXX_SOURCE_COMPILES (
+  "#include <unordered_map>
+  int main() { std::unordered_map<int,int> m; }" ZORBA_HAVE_UNORDERED_MAP)
+CHECK_CXX_SOURCE_COMPILES (
+  "#include <unordered_set>
+  int main() { std::unordered_set<int> s; }" ZORBA_HAVE_UNORDERED_SET)
 
 ################################################################################
 # Various cmake macros
 
-IF(WIN32)
+SET (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules ${CMAKE_MODULE_PATH})
+IF (WIN32)
   # On Windows we use proxy modules that try to guess first the location
   # of the required third party libraries. This will search in order in:
   # 1. the path pointed by ZORBA_THIRD_PARTY_REQUIREMENTS
   # 2. the Program Files directory available on the users computer
   # 3. the PATH environment variable
   # The logic is implemented by the macros in the ProxyFindModule.cmake module.
-  LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules/Windows")
-  INCLUDE(ProxyFindModule)
-ENDIF(WIN32)
-LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules")
+  SET (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/Windows ${CMAKE_MODULE_PATH})
+  INCLUDE (ProxyFindModule)
+ENDIF (WIN32)
+
+################################################################################
+# This section is used for batch script and Visual Studio Project file generation. 
+# Each executable on Windows needs a bat script and in the Visual Studio build a \
+# pre-generated Visual Studio Project file in order to set the PATH to the required DLLs.
+# For this we use CACHE variables to gather all the information generated
+# throughout the cmake execution (required DLLs, list of scripts to generate).
+# The generation occurs only at the end of CMake execution (through the macro
+# ZORBA_GENERATE_EXE_HELPERS_WIN32) when ALL the requirements have been found.
+# E.g. zorba.exe needs in PATH all the DLLs of all external modules, etc.
+IF (WIN32)
+  # Clear all the variables because they are used only for this build.
+  SET (ZORBA_REQUIRED_DLLS ""
+    CACHE STRING "List of DLLs that must be installed" FORCE
+  )
+  SET (ZORBA_REQUIRED_DLL_PATHS ""
+    CACHE STRING "List of paths executable require in order to find the required DLLs" FORCE
+  )
+  SET (ZORBA_EXE_SCRIPT_LIST ""
+    CACHE STRING "List of Windows batch scripts to be generated, one for each executable" FORCE
+  )
+  IF (MSVC_IDE)
+    SET (ZORBA_VC_PROJECT_FILE_LIST ""
+      CACHE STRING "List of Visual Studio project files to be generated, one for each executable" FORCE
+    )
+  ENDIF(MSVC_IDE)
+
+  # Moreover, mark it as advanced since the CMake GUI user should not see this.
+  MARK_AS_ADVANCED (FORCE ZORBA_REQUIRED_DLLS)
+  MARK_AS_ADVANCED (FORCE ZORBA_REQUIRED_DLL_PATHS)
+  MARK_AS_ADVANCED (FORCE ZORBA_EXE_SCRIPT_LIST)
+  IF (MSVC_IDE)
+    MARK_AS_ADVANCED (FORCE ZORBA_VC_PROJECT_FILE_LIST)
+  ENDIF(MSVC_IDE)
+ENDIF (WIN32)
+################################################################################
+
 
 # ZorbaModule includes a number of generally-useful utility functions,
 # including expected_failure().  Include it now (very early) to ensure
@@ -212,11 +277,21 @@
 MESSAGE(STATUS "Looking for LibXml2")
 FIND_PACKAGE(LibXml2)
 IF(LIBXML2_FOUND)
-  MESSAGE(STATUS "Found LIBXML2 library -- " ${LIBXML2_LIBRARIES})
-    
-  INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
-  SET(requiredlibs-store ${requiredlibs-store} ${LIBXML2_LIBRARIES})
-  SET(CXXFLAGS ${CXXFLAGS} ${LIBXML2_DEFINITONS})
+  # Now check LibXml2's version
+  FILE(STRINGS ${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h LIBXML2_VERSION_TMP REGEX 
+       "^#define[ \t]+LIBXML_DOTTED_VERSION[ \t]+\".*\"")
+  STRING(REGEX REPLACE "^#define[ \t]+LIBXML_DOTTED_VERSION[ \t]+\"(.*)\"" "\\1" 
+         LIBXML2_VERSION ${LIBXML2_VERSION_TMP})
+         
+  IF(LIBXML2_VERSION VERSION_EQUAL "2.7.0" OR LIBXML2_VERSION VERSION_GREATER "2.7.0")
+    MESSAGE(STATUS "Found LIBXML2 library -- " ${LIBXML2_LIBRARIES})
+    INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
+    SET(requiredlibs-store ${requiredlibs-store} ${LIBXML2_LIBRARIES})
+    SET(CXXFLAGS ${CXXFLAGS} ${LIBXML2_DEFINITONS})
+  ELSE(LIBXML2_VERSION VERSION_EQUAL "2.7.0" OR LIBXML2_VERSION VERSION_GREATER "2.7.0")
+    MESSAGE(FATAL_ERROR "The libxml2 library version 2.7.0 or higher is required in order to build Zorba.")
+  ENDIF(LIBXML2_VERSION VERSION_EQUAL "2.7.0" OR LIBXML2_VERSION VERSION_GREATER "2.7.0")
+
 ELSE(LIBXML2_FOUND)
   MESSAGE(FATAL_ERROR "The libxml2 library and headers are required in order to build simple store.")
 ENDIF(LIBXML2_FOUND)
@@ -265,15 +340,29 @@
 #
 # Xerces-C part 1 - finding in default locations
 #
-MESSAGE(STATUS "Looking for Xerces-C")
-FIND_PACKAGE(XercesC)
-MESSAGE(STATUS "")
+MESSAGE (STATUS "Looking for Xerces-C")
+FIND_PACKAGE (XercesC)
+MESSAGE (STATUS "")
+
+#
+# shlwapi
+#
+IF(WIN32)
+    SET(requiredlibs ${requiredlibs} "shlwapi")
+ENDIF(WIN32)
 
 #
 # SWIG
 #
 IF (NOT ZORBA_SUPPRESS_SWIG)
   FIND_PACKAGE (SWIG)
+
+  COMPARE_VERSION_STRINGS("${SWIG_VERSION}" "1.3.40" result)
+  IF(result LESS 0)
+    MESSAGE(WARNING "You need at least SWIG version 1.3.40")
+  ENDIF(result LESS 0)
+
+
   IF (SWIG_FOUND)
     # this will be used both in swig and doc sub-directories
 
@@ -281,13 +370,19 @@
     # PHP5
     #
     FIND_PACKAGE (PHP5)
+
+    #
+    # Python
+    #
+    FIND_PACKAGE (PythonInterp)
+    FIND_PACKAGE (PythonLibs)
+    
   ELSE (SWIG_FOUND)
     MESSAGE (STATUS "SWIG not found => no language bindings are generated.")  
   ENDIF (SWIG_FOUND)
 ELSE (NOT ZORBA_SUPPRESS_SWIG)
   MESSAGE (STATUS "SWIG is disabled => no language bindings are generated.")  
 ENDIF (NOT ZORBA_SUPPRESS_SWIG)
-MESSAGE (STATUS "")
 
 
 LIST(APPEND requiredlibs ${requiredlibs-store})
@@ -349,11 +444,14 @@
     " - build without XMLSchema support")
 ENDIF (NOT ZORBA_NO_XMLSCHEMA)
 
-LIST(APPEND requiredlibs ${requiredlibs-store})
-
-
 IF(WIN32)
   SET(requiredlibs ${requiredlibs} wsock32)
+  
+  # Clear those variables because this is used only for this build.
+  # A cache variable is needed since this must be modified by subdirectories
+  # and be visible at this level when ZORBA_GENERATE_EXE_HELPERS_WIN32 is called
+  SET(ZORBA_EXE_SCRIPT_LIST "" CACHE STRING "List of bat scripts" FORCE)
+  SET(ZORBA_VC_PROJECT_FILE_LIST "" CACHE STRING "List of VC project files" FORCE)
 ENDIF(WIN32)
 
 ################################################################################
@@ -373,12 +471,37 @@
 INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 # zorba versioning
-SET(ZORBA_MAJOR_NUMBER "1")
-SET(ZORBA_MINOR_NUMBER "5")
+SET(ZORBA_MAJOR_NUMBER "2")
+SET(ZORBA_MINOR_NUMBER "6")
 SET(ZORBA_PATCH_NUMBER "0")
 SET(ZORBA_VERSION ${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
 MESSAGE(STATUS "Zorba version number: ${ZORBA_VERSION}")
 
+SET(ZORBA_LIB_DIRNAME "lib" CACHE STRING
+  "directory name for libs (may want to set to 'lib64' on 64-bit Linux platforms)")
+
+# Directories for modules and schemas. "Core" are those which are
+# shipped with Zorba and must be present for correct Zorba
+# functionality. "Non-core" are developed independently of Zorba and
+# have different version lifecycles.
+#
+# URI dir is for things resolved by URI - specifically modules (.xq
+# files) and schemas (.xsd files) - which are platform-
+# independent. Lib dir is for platform-specific files, specifically
+# shared libraries for module external functions.
+SET(ZORBA_NONCORE_URI_DIR "share/zorba/uris"
+  CACHE STRING "Path (relative to installdir) to non-core modules/schemas")
+MARK_AS_ADVANCED(ZORBA_NONCORE_URI_DIR)
+SET(ZORBA_CORE_URI_DIR "${ZORBA_NONCORE_URI_DIR}/core/${ZORBA_VERSION}"
+  CACHE STRING "Path (relative to installdir) to core modules/schemas")
+MARK_AS_ADVANCED(ZORBA_CORE_URI_DIR)
+SET(ZORBA_NONCORE_LIB_DIR "${ZORBA_LIB_DIRNAME}/zorba"
+  CACHE STRING "Path (relative to installdir) to non-core libraries")
+MARK_AS_ADVANCED(ZORBA_NONCORE_LIB_DIR)
+SET(ZORBA_CORE_LIB_DIR "${ZORBA_NONCORE_LIB_DIR}/core/${ZORBA_VERSION}"
+  CACHE STRING "Path (relative to installdir) to core libraries")
+MARK_AS_ADVANCED(ZORBA_CORE_LIB_DIR)
+
 # add compiler variables
 ADD_DEFINITIONS(${DEFINITIONS})
 
@@ -405,37 +528,49 @@
 ENDIF(APPLE)
 
 
-################################################################################
-#                                                                              #
-# Tell CMake to process the sub-directories                                    #
-#                                                                              #
-################################################################################
-
 SET (ZORBA_MODULES_DIR "${CMAKE_SOURCE_DIR}/../zorba_modules"
   CACHE PATH "Path to directory (outside of Zorba svn root) containing external modules to add to the build")
 
+# Subdir of the installation directory for CMake files, relative to
+# CMAKE_INSTALL_PREFIX.
+IF (WIN32)
+  SET(ZORBA_CMAKE_DIR "cmake" CACHE STRING
+    "Relative path to CMake files in Zorba installation")
+ELSE (WIN32)
+  SET(ZORBA_CMAKE_DIR "share/cmake/zorba-${ZORBA_VERSION}" CACHE STRING
+    "Relative path to CMake files in Zorba installation")
+ENDIF (WIN32)
+
+################################################################################
+#                                                                              #
+# Tell CMake to process the sub-directories                                    #
+#                                                                              #
+################################################################################
+
 ADD_SUBDIRECTORY(scripts)
 ADD_SUBDIRECTORY(cmake_modules)
 
 # Subdirectory ordering: We need to include "test" before "config" so
 # ZorbaConfig knows about testdriver. We need to include "config"
 # before "modules" so external modules will be able to find
-# ZorbaConfig.cmake.
+# ZorbaConfig.cmake. We need to include "modules" before "include" so
+# config.h can know eg. whether we found CURL. We need to include "modules"
+# before "doc" so xqdoc can know what non-core modules are available.
 
 ADD_SUBDIRECTORY(test)
 ADD_SUBDIRECTORY(config)
-ADD_SUBDIRECTORY(include)
-ADD_SUBDIRECTORY(doc)
 ADD_SUBDIRECTORY(schemas)
 ADD_SUBDIRECTORY(modules)
+ADD_SUBDIRECTORY(doc)
+ADD_SUBDIRECTORY(include)
 
 ADD_DEFINITIONS(-Dzorba_EXPORTS)
 ADD_SUBDIRECTORY(src)
 REMOVE_DEFINITIONS(-Dzorba_EXPORTS)
 
-IF(ZORBA_USE_SWIG)
-  ADD_SUBDIRECTORY(swig)
-ENDIF(ZORBA_USE_SWIG)
+IF (SWIG_FOUND)
+  ADD_SUBDIRECTORY (swig)
+ENDIF (SWIG_FOUND)
 
 ADD_SUBDIRECTORY(bin)
 
@@ -466,5 +601,16 @@
 ENDIF (APPLE AND UNIVERSAL)
 
 IF (WIN32)
-  ZORBA_GENERATE_EXE_SCRIPTS_WIN32 ()
+  ZORBA_GENERATE_EXE_HELPERS_WIN32 ()
 ENDIF (WIN32)
+
+# This must be done last! Create the one top-level target which
+# depends on all generated (copied) module/schema files.
+DONE_DECLARING_ZORBA_URIS()
+
+# This dependency makes sure that the error and warning definition
+# modules are generated before trying to install them as zorba modules.
+# This dependency is zorba-only related, which is why it's added here
+# and not within zorba-modules, which is for general use in other
+# non-zorba modules.
+ADD_DEPENDENCIES(check_core_uris gen_diag_modules)

=== modified file 'CPackSourceConfig.cmake.in'
--- CPackSourceConfig.cmake.in	2009-10-30 16:24:51 +0000
+++ CPackSourceConfig.cmake.in	2012-09-27 18:04:43 +0000
@@ -19,7 +19,7 @@
 
 SET(CPACK_CMAKE_GENERATOR "Unix Makefiles")
 SET(CPACK_GENERATOR "TGZ;TZ")
-SET(CPACK_IGNORE_FILES "test/coverity/;dist/;_CPack_Packages/;build/;build./;CVS/;/\\.svn/;\\.swp$;\\.#;/#")
+SET(CPACK_IGNORE_FILES "test/coverity/;dist/;_CPack_Packages/;build/;build./;CVS/;/\\.svn/;\\.swp$;\\.#;/#;\\.bzr/")
 SET(CPACK_INSTALLED_DIRECTORIES "@CMAKE_SOURCE_DIR@;/")
 SET(CPACK_INSTALL_CMAKE_PROJECTS "")
 SET(CPACK_MODULE_PATH "")

=== modified file 'ChangeLog'
--- ChangeLog	2011-06-08 06:57:13 +0000
+++ ChangeLog	2012-09-27 18:04:43 +0000
@@ -1,27 +1,418 @@
 Zorba - The XQuery Processor
 
+version 2.7
+
+New Features:
+  * New XQuery 3.0 simple map operator http://www.w3.org/TR/xquery-30/#id-map-operator
+  * New node copy function added to the node module
+  * Allow prolog variables to be referenced before they are declared (XQuery 3.0 feature)
+  * xml:parse (fragment parsing) now allows for a DOCTYPE declaration at the
+    beginning of the XML document (requested in bug #1016606).
+  * New module http://jsoniq.org/modules/function-library with handy JSONiq
+    functions. jn:object is also supported.
+  * jn:parse-json can parse multiple top-level JSON items. Also, there is jn:parse-json#2 that
+    takes options to parameterize the parsing process (see bug #1047547)
+  * Roundtripping of JSON items has been moved from the serializer to encoding functions.
+  * Best-effort serialization of atomic values in JSON items.
+  * Implemented semantics of null for comparison and arithmetics operations.
+  * Positional pagination support for index probes 
+  * Recognize the no-copy pragma to avoid copying nodes before insertion into a collection.
+  * Added createUntypedAtomic to API's ItemFactory.
+  * new xqDoc feature; reporting collections and indexes
+  * new xqDoc function parameter to enable/disable xqDoc generation of
+	  certain components
+  * Adding new external module read-pdf, it converts PDF documents to text or rendered images.
+
+Optimizations:
+  * New memory management for compiler expressions (no more ref counting)
+  * Exteneded some optimization rules (variable inlining/elimination and positional
+    predicate rewrite) to general flwor expressions.
+  * Early optimization of positional predicates to subsequence expressions: now
+    done at translation time, if possible.
+  * For non-mutable global variables, assign a type based on their initializing expr.
+  * Use char* instead of zstring as the hashmap key in json objects
+  * Removed document-order sorting after the index value probe functions.
+  * Optimize positional predicates involving inequality (convert them to subsequence)
+  * Optimize positional predicate that is in CNF with other predicates.
+  * Optimized runtime group iterator based on latest group-by semantics.
+
+Bug Fixes/Other Changes:
+  * Fixed bug #950621 (Removed two-arg version of fn:parse-xml(); use XML module function xml:parse() instead)
+  * Fixed bug #867227 (Improved error message for missing commas)
+  * Fixed bug #1024033 and #1023170 (segfaults in parse-xml:parse())
+  * Fixed bug #898792 (Dynamically computed strings can now be cast to xs:QName)
+  * Fixed bug #1034990 (text serialization with jsoniq fails)
+  * Fixed bugs #899364 and 899363 (throw XQST0103 in case of non-distinct window
+    variables)
+  * Fixed bug #923686 (implicitly declare global context size and context position
+    variables in main module and provide api function to assign values to these
+    variables)
+  * Fixed bug #899366 (enforce the type declaration of a window variable)
+  * Now using native UUID libraries.
+  * Fixed bug in implementation of xqdoc functions
+  * Fixed bug #1034942 (improper variable inlining inside general flwor expr)
+  * Fixed bug #1024892 (index declaration references udf declared after the index)
+  * Fixed bug #1038410 (Memory leaks in parser, trace iterator, and general index)
+  * Fixed bug #1046411 (automatic boxing of mutli-item sequence appearing as the
+    value of an object pair)
+  * Fixed bug #1046410 (automatic conversion to null of empty sequence appearing
+    as the value of an object pair)
+  * Fixed bug #1039488 (inserting more than one pair at once in a JSON object)
+  * Fixed bug #1042840 (qname pool free-list corruption)
+  * Fixed bug #866984 (better error message for an eval error)
+  * Fixed bug #932374 (FOTS fn:matches failing tests)
+  * Fixed bug #1047538 (jsoniq: SourceFinder::findLocalNodeSources missing
+    json expressions)
+  * Fixed #1052383 (accessing context item in eval expr)
+  * Fixed bug #1046559 (dynamic resolution between function invocation and jsoniq
+    navigation)
+  * Fixed bug #932884 (HTML and XHTML serialization of empty elements)
+  * Fixed bug #1046415 (pair name cast to string)
+  * Fixed bug #1045902 (file:last-modified returns current date time)
+  * Fixed bug #1043976 (compiler warning in serialiser code)
+  * Fixed bug #866994 (a better error message when collection iterator not open)
+  * Fixed bug #1039254 (allow empty sequence as position value in positional LET
+    var iterator)
+
+
+version 2.6
+
+New Features:
+  * Include first-class support for JSON data by implementing the JSONiq spec
+  - see http://jsoniq.org/ for more information. This feature is enabled by default.
+  * Implemented the new EQName syntax (use Q{namespace}local instead of "namespace":local)
+  * New function Item::isSeekable for streamable content (xs:string and xs:base64Binary)
+  * Implemented the latest W3C specification for the group by clause (backwards incompatible)
+  * New ft:tokenize-nodes() function to full-text module
+  * New XQuery 3.0 function fn:parse-xml-fragment#1
+  * New ItemFactory function that allows creating dateTime items without timezone
+  * Added support for transient maps to the
+    http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.
+  * Added support for fragments to fn:path
+  * Positional pagination support for collections
+  * http://www.zorba-xquery.com/modules/archive module for creating,
+    reading, and updating various (compressed) archives (e.g. zip, tar.gz,
+    or tar.bz2)
+  * Incremental maintenance for general indexes
+  * New function in the http://www.zorba-xquery.com/modules/store/static/indexes/dml
+    module which returns the value of all keys contained in an index
+
+Optimizations:
+  * Optimization of comparison operations
+  * Tighter hoisting of expressions (also fixes bug #967428)
+  * Optimized hash sets used by fn:distinct-values and nodes-distinct
+  * Optimized hash function used for nodes (also fixes bug #1010051)
+  * Rewrite of plan serializer internals, resulting in big performance improvement
+  * Avoid treat expr for checking that the value of a non-external
+    global variable conforms to the type declaration of the variable
+  * Streaming execution for tumbling windows (also fixes bug #1010051)
+
+Bug Fixes/Other Changes:
+  * Fixed bug #1025622 (Incorrect JSON serialization of supplementary plane code points)
+  * Fixed bug #1016606 (DOCTYPE in the input of the parse-fragment function)
+  * Fixed bug #1002993 (bug during revalidation after update; improper condition
+    for calling TypeOps::get_atomic_type_code() from
+    SchemaValidatorImpl::isPossibleSimpleContentRevalImpl())
+  * Fixed bug #867357 (Improved parser error messages)
+  * Fixed bug #1026379 ("q" flag for fn:replace() is ignored)
+  * Fixed bug #932314 (non-comparable values must be treated as distinct by
+    fn:distinct-values)
+  * Fixed bug #1015580 (Add base64_streambuf / replace inefficient base64 code)
+  * Fixed bug #1022557 (subsequence function applied on window variable)
+  * Fixed bug #9910884 (raise XUST0001 in trycatch with mixed updating and simple clauses)
+  * Fixed bug #854506 (ugly type error messages) and partial fix for bug #867008
+  * Fixed bug #1008082 (bug in transform expr when a copy var is not used anywhere)
+  * Fixed bug #898066 (Stringstream & fn:trace)
+  * Fixed numbering of items in fn:trace starts with one
+  * Fixed bug #1003023$ (optimizer problems due to common subexpression after
+    var folding into if-then-else)
+  * Fixed bug #1006166 (disabling 2 functions with the same qname)
+  * Fixed bug #960083 (improper error handling of NaN comparisons)
+  * Fixed bug #878508 (JsonML serialization not escaping characters)
+  * The XML plan serialization format is not supported anymore
+
+
+version 2.5
+
+New Features:
+  * New XQuery 3.0 functions
+    - fn:available-environment-variables
+    - fn:environment-variables
+    - fn:uri-collection
+    - fn:unparsed-text
+    - fn:unparsed-text-available
+    - fn:has-children#0
+    - fn:nilled#0
+    - fn:path
+  * Added base64:decode#2 function which also does transcoding
+  * Extended API for Python, Java, PHP and Ruby
+  * Added JVM classpath to zorbacmd and to Zorba API
+  * Added full-text module
+  * Added support for NO_ICU (to not use ICU for unicode processing)
+  * Added XQJ support
+  * Added CollectionManager and DocumentManager support for XQJ
+  * Added new API EntityKind SOME_CONTENT
+  * Added new API StreamResource which is able to specify whether a
+    stream is seekable or not.
+  * Added new functions in the fetch module and the StaticContext to fetch
+    resources as binary
+  * Added non-core schema-tools module for getting sample XMLSchema from
+    XML instances and sample XML instances from XMLSchema.
+
+Optimizations:
+  * optimized insertion into a collection (don't copy it if the node was
+    created by an element constructor and is not used anywhere else in the query)
+  * Fixed performance problem with the findNodeSources function of the no-copy rule
+
+Bug Fixes/Other Changes:
+  * Fixed bug #867170 (Variables declared in Prolog are Overwritten inside the query)
+  * Fixed bug #1001463 (type not available during computation of function caching)
+  * Fixed bug #1002867 (resulting base64 in http-client is wrong)
+  * Fixed bugs #905028 (Allow to set base URI to undefined)
+  * Fixed bugs #931501 and #866987 (improved error messages for fn:format-number()
+  * fn:format-number raises FODF1310 instead of XTDE1310
+  * Fixed bug 955170 (Catch clause with URILiteral-based wilcard NameTest)
+  * Fixed bug #862971 (no error upon duplicate function declarations)
+  * Fixed bug 955135 (err:XQDY0044 not caught by try-catch expressions)
+  * Fixed bug #986075 (encountering flwor expr with no clauses)
+  * Fixed bug #967864 (var substitution did not update theFreeVars property)
+  * Fixed bug #891650 (context size var not always declared within path expr)
+  * Fixed bug #948879 (--uri-path doesn't work with fetch:content())
+  * Fixed bug in MarkNodeCopyProps rule (static cast to replace_expr without chaing the expr kind first)  
+  * Fixed bug in window iterator (binding the end vars in the output tuple stream)
+  * Fixed bug #866547 (protect index-join rule from general flwor)
+  * Fixed bug #867253 (cdml:delete-nodes should only remove root nodes)
+  * Fixed bug #967428 (do not hoist index creation outside a try-catch)
+  * Fixed bug #872234 (prevent a rewritting to take place in case of sequential expr)
+  * Fixed bug #966706 (key uniqueness of index not enforced during incremental refresh)
+  * Fixed bug #906494 (default compile with D_FILE_OFFSET_BITS=64)
+  * Fixed bug #988412 (date:current-dateTime daylight saving)
+  * Fixed bug #912586, #912593 and #912722 (assertion failures with lax validation)
+  * Fixed bug #986377 (do not apply any updates on collection if it is to be truncated)
+  * Fixed bug #921458 (file:read-text-lines() blocking)
+  * Fixed bug #981405 (do not hoist expr containing try-catch variables out of the associated try-catch expression)
+  * Fixed bug #996084 (crash in Streamable*Item with file module)
+  * Fixed bug #947627 (throw XQST0099 if more than one declarations of context item type in same module)
+  * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)
+  * Fixed bug #949910 (has-children may be invoked on all nodes)
+  * Fixed Bug #933490 (Error ItemFactoryImpl::createBase64Binary with istream)
+  * Fixed bug #867112 (Diagnostic Handler was not working on external APIs)
+  * Fixed bug #857842 (Assertion failed with simple content element with comments)
+  * Fixed bug #928626 (no setting classpath in xsl-fo module)
+
+version 2.2
+
+New Features:
+  * Add --compile-plan (-c) and --execute-plan (-e) options to zorba command line.
+  * Add XQuery 3.0 concat operator (http://www.w3.org/TR/xquery-30/#id-string-concat-expr) 
+  * New URI module providing percent-decoding functions.
+  * The core parse-xml module is now able to parse input files in a streaming mode. A number of new options have also been added.
+  * LibXml2 version 2.7.0 or higher is now required in order to build Zorba.  
+  * Added index management function to the C++ api's StaticCollectionManager.
+  * Added createDayTimeDuration, createYearMonthDuration, createDocumentNode, createCommentNode, createPiNode to api's ItemFactory.
+  * Fixed bug #905050 (setting and getting the context item type via the c++ api).
+  * Added split function to the string module that allows for streamable tokenization but doesn't have regular expression
+  * Add new XQuery interface for the PHP bindings.
+  * Added two API methods StaticContext::getFunctions to introspect the functions of a static context
+  * Added API method Item::getNamespaceBindings().
+  * Added a transcoding streambuffer to the API which allows transcoding arbitrary encodings
+    from and to UTF-8
+  * file:read-text is able to handle arbitrary encodings (fixes bug #867159)
+  * http:send-request is able to handle arbitrary encodings
+  * Added API method StaticContext::getNamespaceBindings() (see bug #905035)
+  * New version of the JSON converter module in the core of Zorba (no external dependencies anymore)
+  * Added truncate function to the collection modules for efficient deletion of all nodes in a collection.
+
+
+Optimization:
+  * No-copy optimization: avoids copying nodes during node-constructor expressions.
+  * Added external function annotations %ann:propagates-input-nodes and 
+    %ann:must-copy-input-nodes to be used by the no-copy optimization.
+  * Caching of results for recursive functions with atomic parameter and return types.
+  * Added %ann:cache and %ann:no-cache to enable or disable caching of results of functions with atomic parameter and return types.
+  * Types-related optimizations for runtime operators (comparisons, FnBoolean, Or, And,
+    Compare, instance-of, cast, castable, treat, promote).
+  * More efficient implementation for base64Binary items
+  * Preallocate and reuse temp sequence iterator for LetVarITerator
+    and CtxVarIterator.
+  * Enhanced push-down of positional predicate into LetVarITerator
+    and CtxVarIterator.
+  * Change the implementation of the free-vars annotation and got rid
+    of the annotations map in expressions.
+
+Bug Fixes/Other Changes:
+  * Fixed bug 923015 (clone() not implemented for full-text expressions)
+  * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context)
+  * Fixed bug 867509 (Can not handle largest xs:unsignedLong values)
+  * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator)
+  * Fixed bug 909126 (bug in cloning of var_expr)
+  * Fixed bug 928631 (external builtin function were not executed in the module they
+    were declared)
+  * Fixed bug in destruction of exit_catcher_expr
+  * Fixed bug #867024 (error messages)
+  * Fixed bug #957580 (stream read failure in StringToCodepointsIteartor)
+  * Fixed bug #911585 (management of variables during eval)
+  * Fixed bug #866423 (fn:empty and fn:exists iterators must reset their input in
+    case of early-out)
+  * Fixed bug #955574 (http-client "hangs" if following a POST request)
+  * Fixed bug #945241 (StaticCollectionManager::declaredIndexes() and temporary indexes)
+  * Fixed bug #872288 (reset recursive flag during node rename)
+  * Fixed bug #905041 (allow for the default element and function namespaces to be
+    set multiple times via the c++ api).
+  * Fixed bug #907872 (segfault when returning an input ItemSequence from an external function).
+  * Fixed bug in codegen: do not create a materialize clause if one exists already
+    support.
+  * Fixed bug involving positional var and groupby 
+  * Fixed bug #867266 (do not hoist updating expressions)
+  * Fixed bug #867022 (added location and params to some XPTY0004 errors)
+  * zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors
+  * Fixed bug #917981 (disallow declaring same module twice).
+  * Deprecated StaticContext:getNamespaceURIByPrefix()
+  * Fixed bug #943788 (streamable string is not seekable)
+  * Fixed bug #921624 (slow queries with bogus example.com schema URIs)
+  * Fixed bug #918211 (xqueryx fulltext w3c conformance generation)
+  * Fixed bug #918157 (Add XQFTTS to validation queue)
+  * Fixed bug with unversioned modules with C++ external functions
+  * Fixed bug #912579 (validate-in-place on non-root elements)
+  * Fixed bug #891209 (validation with xsi:type returns untyped)
+  * Fixed bug #952829 (Nondeterministic annotation doesn't seem to be checked)
+  * Fixed bug #951772 (Comment node crashes serialization)
+  * Fixed bug #945241 (StaticCollectionManager::declaredIndexes() and temporary indexes)
+
+	
+version 2.1
+
+New Features:
+  * New node-position module. This module allows to obtain a representation of a node position, which
+    can be used to assess structural relationships with other nodes.
+  * New node-reference module. References can be obtained for any node, and
+	different nodes cannot have the same identifier.
+  * Custom Full-text thesaurus using Zorba URI resolver mechanism.
+  * Modified C++ API to add isSequential, getExternalVariables, isBoundContextItem and 
+  isBoundExternalVariable Functions
+  * Collection allows to retrieve information about the type
+  and the annotations of a static collection.
+  * Implemented the probe-index-range-value for general indexes
+  * Added ExternalFunctionParameter class to be registered in the DynamicContext
+  * New module for compiling and executing XQueries from XQuery (xqxq)
+  * External functions are allowed to be updating (i.e. return a pending update list)
+
+Optimization:
+  * Optimization for positioned sequence access (e.g. $x[$x[1]] where $x is a
+  sequence of integers)
+  * Optimization for count(collection()) expressions
+  * Optimization of the fn:substring function in the case when its $start and $length arguments
+  are integers
+
+Bug Fixes/Other Changes:
+  * Fixed bug #3403291 (build for Fedora 15)
+  * Fixed bug #3397293 (Incorrect XQueryX error message)
+  * Fixed bug #3398637 (Nested element constructors cause loss of namespace bindings)
+  * Fixed bug #3401592 (Undo of Create Collection doesn't work)
+  * Fixed bug #3404689 (assignment problem in flwor)
+  * Fix for bug #3404450 (testdriver_mt problem: caching and validation of docs)
+  * Fixed installation bug to not install the .so for test modules
+  * Fixed bug #3390410 (Adding a node to a collection causes out of bound in vector)
+  * Fixed bug #3406200 (node types were not being moved to new tree during node detach)
+  * Fixed bug #3406191 (Namespace bindings lost after update due to bug in node detach)
+  * Fixed bug #3290122 (ZDST0003 needs collection name)
+  * Fixed bug #3406272 (merging of adjacent text nodes must be done after all
+    updates have been applied).
+  * Don't raise warnings for unknown annotations.
+  * Fixed bug #3409344 (during detach, if the node being detached is the root of
+    its tree, it should be detached from the tree as well; otherwise memory
+    corruption will occur)
+  * Fixed bug # (Should not destroy the parent of a node that is being detached
+    before the detach is done).
+  * Added const qualifier to StaticContext::getAuditEvent() 
+  * Fixed bug #3408181 (available-collection() returns undeclared collections)
+  * Fixed bug #859465 (Fatal error if a PUL contains two deactivate IC primitives)
+  * Fixed bug #859467 (Fatal error if a PUL contains two activate Foreign Key primitives)
+  * Fixed bug #859468 (Fatal error if a PUL contains two activate Simple IC primitives)
+  * Fixed bug #859522 (Fatal error if a PUL contains two delete document primitives)
+  * Fixed bug #859968 (Using put on an attribute produces an invalid XDM instance and may cause segmentation faults)
+  * Fixed bug #855314 (should not fold a constant expr that returns an error item)
+  * Fixed bug when parsing a document with a base-uri attribute.
+  * Fixed bug #863320 (Sentence is incorrectly incremented when token characters end without sentence terminator)
+  * Fixed bug #863730 (static delete-node* functions don't raise ZDDY0012)
+  * Implemented the probe-index-range-value for general indexes
+  * Removed ZSTR0005 and ZSTR0006 error codes
+  * Fixed bug #867662 ("nullptr" warning)
+  * Fixed bug #868258 (Assertion failure with two delete collection)
+  * Fixed bug #871623 and #871629 (assertion failures with insertions in dynamic collections)
+  * Fixed bug #867262 (allow reuse of iterator over ExtFuncArgItemSequence)
+  * Fixed bug #869024 (segmentation fault with node-reference)
+  * Fixed bug #869025 (segmentation fault with node-reference)
+  * New node-reference module. References can be obtained for any node, and
+	different nodes cannot have the same identifier.
+  * Fixed bug #872697  (segmentation fault with validation of NMTOKENS)
+  * General index cannot be declared as unique if the type of its key is
+    xs:anyAtomicType or xs:untypedAtomic.
+  * Added undo for node revalidation
+  * Optimization for count(collection()) expressions
+  * Fixed bug #872796  (validate-in-place can interfere with other update primitives)
+  * Fixed bug #872799 (validate-in-place can set incorrect types)
+  * Fixed bug #855715 (Invalid escaped characters in regex not caught)
+  * Fixed bug #868325 (fn:analyze-string fails with some recursive subgroups)
+  * Fixed bug #872697 (segmentation fault with validation of NMTOKENS)
+  * General index cannot be declared as unique if the type of its key is
+  xs:anyAtomicType or xs:untypedAtomic.
+  * Added undo for node revalidation
+  * Optimization for count(collection()) expressions
+  * Fixed bug #867133 (SWIG PHP build failure on Mac OSX)
+  * Fixed bug #872796 (validate-in-place can interfere with other update primitives)
+  * Fixed bug #872799 (validate-in-place can set incorrect types)
+  * Fixed bug #872850 (Serialization of Tumbling Window For fails)
+  * Fixed bug #855715 (Invalid escaped characters in regex not caught)
+  * Fixed bug #862089 (Split binary/xq install directories for modules) by
+  splitting "module path" into separate URI and Library paths
+  * New node-position module. This module allows to obtain a representation of a node position, which
+    can be used to assess structural relationships with other nodes.   
+  * Fixed bug #872502 (validation of the JSON module xqdoc fails)
+  * Fixed bug #897619 (testdriver_mt can not run the XQueryX tests)
+  * Fixed bug #867107 (xqdoc dependency to zorba is wrong)
+  * Fixed bug #897616 (Fix the generation of the XQFTTS report results for
+  W3C)
+
+version 2.0.3
+  * Fixed bug #867662 ("nullptr" warning)
+  * documentation improvements
+
+version 2.0.2
+  * Fixed bug #3401971 (node-by-reference on dynamic collections)
+  * documentation improvements
+  * installer improvements
+  * Fixed bug #3403291 (build for Fedora 15)
+  * Don't install the .so for test modules
+  * Fix for running ctest on Windows
+
+version 2.0.1
+
+  * Custom Full-text stemming.
+  * Custom Full-text tokenization.
+  * Fixed scripting bug where apply statement was considered a sequential expr even if the source expr was non-updating and non-sequential.
+  * Fixed bug #3394400 (Element replacement, really unexpected result)
+  * Fixed bug #3394588 (Unexpected error during pul undo)
+  * Fixed bugs #3398511 and #3398552 with "make install"
+  * Fixed bug #3398521 for compiling with ZORBA_NO_XMLSCHEMA
+
 version 2.0
-  * Removed the --install-path zorba command line argument. This functionality was duplicating
-    the existing --module-path argument
-  * zorba executable deletes the output file (if one is provided) in case the execution fails
-  * changed the error codes returned by the zorba executable (using different codes for
-    different locations where the execution might fail)
-  * Removed the XQuery 1.1 "outer for" construct, and replaced it with "allowing empty"
-  * Added the XQuery 1.1 functions and variables annotations. Removed the "deterministic" 
-    and "nondeterministic" keywords, which were replaced by the "%deterministic" and 
-    "%nondeterministic" annotations.
-  * Changed the singature of ExternalModule::getExternalFunction. The const modified was removed
-    to allow for lazy instantiation of the function objects. Also, the localname is passed as
-    as a const reference.
-  * renamed the fn:parse function (XQuery Functions and Operators 1.1) to fn:parse-xml
-    (XQuery Functions and Operators 3.0)
-  * added the fn:serialize function (XQuery Functions and Operators 3.0)
-  * removed the serialize module (http://www.zorba-xquery.com/modules/serialize) since this
-    functionality is now covered by the built-in function fn:serialize
-  * updated the file module to the new http://expath.org/ file module specification. The new module is now in the http://expath.org/ns/file namespace
-  * the XML Schema atomic types are now serialized including the "xs" prefix (used in sax2 serialization,
- debuger, etc.)
-  * zorba uses now DBGP as the debugger protocol
+  * Zorba 2.0 is a major rewrite of previous versions. It doesn't claim to
+    preserve backwards compatibility with any 1.X version.
+    Host language API changes have been made to the following components:
+    - External functions API
+    - XmlDataManager
+    - Error reporting
+    - Debugger API
+    XQuery language and API changes have been made to the following components:
+    - XQuery Scripting Extension
+    - Function APIs
+    - XQuery Data Definition Facility
+    - XQuery modules and module versioning
+    - Changes to conform with the latest XQuery 3.0
+    - Namespaces of annotations, errors, collations.
+  * In addition to host language API and XQuery language improvements,
+    plenty of bug fixes and optimizations have been made.
 
 version 1.4
   * added a datetime library module with nondeterministic functions

=== modified file 'KNOWN_ISSUES.txt'
--- KNOWN_ISSUES.txt	2011-07-01 14:37:20 +0000
+++ KNOWN_ISSUES.txt	2012-09-27 18:04:43 +0000
@@ -1,41 +1,52 @@
-  ----------------------------
-  FLWOR Foundation - Zorba 2.0
-  ----------------------------
+This is a list of issues that we are aware of but are not imlemeneted or fixed:
 
-This is a list of issues that we are aware of but are not fixed in this version:
+Zorba Version 2.0
 
 * Floating-point precision problems.
   For details, see the following bugs:
-  - 2204089 <https://sourceforge.net/tracker2/?func=detail&aid=2204089&group_id=226244&atid=1067586>
-  - 2205034 <https://sourceforge.net/tracker2/?func=detail&aid=2205034&group_id=226244&atid=1067586>
-  - 2210851 <https://sourceforge.net/tracker2/?func=detail&aid=2210851&group_id=226244&atid=1067586>
+  - 2204089 <https://bugs.launchpad.net/zorba/+bug/sf-2204089>
+  - 2205034 <https://bugs.launchpad.net/zorba/+bug/sf-2205034>
+  - 2210851 <https://bugs.launchpad.net/zorba/+bug/sf-2210851>
 
 * When using the (now default) xs:integer representation of a C++ "long long",
   the largest xs:unsignedLong values are not handled correctly.
   For details, see the following bug:
-  - 3323548 <https://sourceforge.net/tracker/?func=detail&aid=3323548&group_id=226244&atid=1067586>
+  - 3323548 <https://bugs.launchpad.net/zorba/+bug/sf-3323548>
 
 * Zorba uses ICU for regular expressions that does not support range
-  subtraction.
-  For details, see the following bug:
-  - 3150856 <https://sourceforge.net/tracker/?func=detail&aid=3150856&group_id=226244&atid=1067586>
+  subtraction.  For details, see the following bug:
+  - 3150856 <https://bugs.launchpad.net/zorba/+bug/sf-3150856>
 
 * If you link against ICU <= 3.8.1, you can get wrong results when using \s to
-  match a white space character.
-  For details, see following bug:
-  - 3155900 <https://sourceforge.net/tracker/?func=detail&aid=3155900&group_id=226244&atid=1067586>
+  match a white space character. For details, see following bug:
+  - 3155900 <https://bugs.launchpad.net/zorba/+bug/sf-3155900>
 
 * A known bug in Xerces < 3.0, when an .xsd contains an any wildcard with
   namespace #others and the instance contains an element without a namespace,
   there should still be an error.  See "Definitive XMLSchema" by Priscilla
   Wamsley, p. 279. This was fixed in Xerses > 3.0.
   For details, see following bug:
-  - 3137594 <https://sourceforge.net/tracker/index.php?func=detail&aid=3137594&group_id=226244&atid=1067586>
+  - 3137594 <https://bugs.launchpad.net/zorba/+bug/sf-3137594>
 
 * XQuery Full-Text is mostly, but not completely, implemented.
   For details, see following bugs:
-  - 3187470 <https://sourceforge.net/tracker/?func=detail&aid=3187470&group_id=226244&atid=1067586>
-  - 3187462 <https://sourceforge.net/tracker/?func=detail&aid=3187462&group_id=226244&atid=1067586>
+  - 3172383 <https://bugs.launchpad.net/zorba/+bug/sf-3172383>
+  - 3187470 <https://bugs.launchpad.net/zorba/+bug/sf-3187470>
+  - 3187462 <https://bugs.launchpad.net/zorba/+bug/sf-3187462>
 
 * The serializer currently doesn't implement character maps as specified
   (http://www.w3.org/TR/xslt-xquery-serialization/#character-maps)
+
+* In the 2.0 release, setting the CMake variables ZORBA_NO_ICU to
+  ON is not supported.
+
+* The PHP language binding is not supported on Mac OS X. For details,
+  see the following bug:
+  - <https://bugs.launchpad.net/zorba/+bug/sf-3371525>
+
+* Generating the XQDoc documentation on Windows using nmake is broken,
+  see the following bug:
+  - <https://bugs.launchpad.net/zorba/+bug/sf-3393173>
+
+* The Scripting Extension's features break and continue are not
+  implemented if used within a FLWOR Statement.

=== removed file 'NOTICE.txt'
--- NOTICE.txt	2011-04-26 08:59:08 +0000
+++ NOTICE.txt	1970-01-01 00:00:00 +0000
@@ -1,145 +0,0 @@
-Zorba XQuery Processor
-Copyright 2006-2008 The FLWOR Foundation
-
-   See LICENSE.txt for license information.
-
-   This product includes software developed at
-   The FLWOR Foundation (http://www.flworfound.org/).
-
-   Portions of this software were developed at the Systems
-   Group of the ETH Zurich, Switzerland.
-
-The file src/zorbatypes/m_apm.h and the directory src/zorbatypes/mapm/
-are copyright 1999-2007 Michael C. Ring. The original distribution
-contains the following notice:
-
-   This software is Freeware.                                              
-                                                                           
-   Permission to use, copy, and distribute this software and its           
-   documentation for any purpose with or without fee is hereby granted,    
-   provided that the above copyright notice appear in all copies and       
-   that both that copyright notice and this permission notice appear       
-   in supporting documentation.                                            
-                                                                           
-   Permission to modify the software is granted. Permission to distribute  
-   the modified code is granted. Modifications are to be distributed by    
-   using the file 'license.txt' as a template to modify the file header.   
-   'license.txt' is available in the official MAPM distribution.           
-                                                                           
-   To distribute modified source code, insert the file 'license.txt'       
-   at the top of all modified source code files and edit accordingly.      
-                                                                           
-   This software is provided "as is" without express or implied warranty.  
-
-
-The file src/common/config/stdint.h is copyright 2006 Alexander Chemeris and
-contains the following notice:
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions are met:
-   
-     1. Redistributions of source code must retain the above copyright notice,
-        this list of conditions and the following disclaimer.
-   
-     2. Redistributions in binary form must reproduce the above copyright
-        notice, this list of conditions and the following disclaimer in the
-        documentation and/or other materials provided with the distribution.
-   
-     3. The name of the author may be used to endorse or promote products
-        derived from this software without specific prior written permission.
-   
-   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-   EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-The files in src/runtime/full_text/stemmer is copyright 2001 Dr. Martin Porter
-and contains the following notice:
-
-   All the software given out on this Snowball site is covered by the BSD
-   License (see http://www.opensource.org/licenses/bsd-license.html), with
-   Copyright (c) 2001, Dr Martin Porter, and (for the Java developments)
-   Copyright (c) 2002, Richard Boulton.
-
-   Essentially, all this means is that you can do what you like with the code,
-   except claim another Copyright for it, or claim that it is issued under a
-   different license. The software is also issued without warranties, which
-   means that if anyone suffers through its use, they cannot come back and sue
-   you. You also have to alert anyone to whom you give the Snowball software to
-   the fact that it is covered by the BSD license.
-
-   We have not bothered to insert the licensing arrangement into the text of
-   the Snowball software.
-
-
-The file src/util/less.h is copyright 1998 Paul J. Lucas and contains the
-following notice:
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions are met:
-   
-    o  Redistributions of source code must retain the above copyright notice,
-       this list of conditions and the following disclaimer.
-  
-    o  Redistributions in binary form must reproduce the above copyright
-       notice, this list of conditions and the following disclaimer in the
-       documentation and/or other materials provided with the distribution.
-  
-    o  The name of the author may not be used to endorse or promote products
-       derived from this software without specific prior written permission.
-  
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-   POSSIBILITY OF SUCH DAMAGE.
-
-
-The file src/util/auto_vector.h is slightly modified from code
-originally copyright 2003 Reliable Software which contains the
-following notice:
-
-   Any use, commercial or noncommercial of this code
-   is hereby granted, under the condition
-   that this copyright notice be not removed.
-
-
-Furthermore, this software depends / makes use of:
-
-     * LIBXML2 2.2.16 or higher (http://xmlsoft.org/ ) 
-
-     * ICU4C 3.6 or higher (http://www.icu-project.org/)
-
-     * BOOST 1.32 or higher (http://www.boost.org/)
-       * boost_program_options
-       * boost_date_time
-       * boost_filesystem
-
-     * XERCES 2.7.0 or higher (http://xerces.apache.org/xerces-c/)
-
-     * ICONV 1.12 (used by LIBXML2; http://www.gnu.org/software/libiconv/)
-
-     * MAPM 4.9.5 (by Michael C. Ring; http://www.tc.umn.edu/~ringx004/mapm-main.html)
-
-     * Loki C++ Library (see http://loki-lib.sourceforge.net/index.php?n=Main.HomePage)
-
-Optional:
-
-     * FLEX 2.5.33 (http://flex.sourceforge.net/)
-
-     * BISON 2.4 or higher (http://www.gnu.org/software/bison/)
-
-     * CURL 7.12 (http://curl.haxx.se/)

=== added file 'NOTICE.xml'
--- NOTICE.xml	1970-01-01 00:00:00 +0000
+++ NOTICE.xml	2012-09-27 18:04:43 +0000
@@ -0,0 +1,686 @@
+<?xml version="1.0" encoding="utf-8"?>
+<notice xmlns="http://www.zorba-xquery.com/notice";>
+  <master-license>
+    <license>Apache 2</license>
+    <text>
+      Copyright 2006-2011 The FLWOR Foundation
+
+      See LICENSE.txt for license information.
+
+      ------------------------
+      This product includes software developed at
+      The FLWOR Foundation (http://www.flworfound.org/).
+
+      ------------------------
+      Portions of this software were developed at the Systems
+      Group of the ETH Zurich, Switzerland.
+    </text>
+  </master-license>
+  <foreign-files>
+    <file>src/zorbatypes/m_apm.h</file>
+    <file>src/zorbatypes/mapm/</file>
+    <copyright>1999-2007 Michael C. Ring</copyright>
+    <website>http://www.tc.umn.edu/~ringx004/mapm-main.html</website>
+    <foreign-notice>
+      This software is Freeware.
+
+      Permission to use, copy, and distribute this software and its
+      documentation for any purpose with or without fee is hereby granted,
+      provided that the above copyright notice appear in all copies and
+      that both that copyright notice and this permission notice appear
+      in supporting documentation.
+
+      Permission to modify the software is granted. Permission to distribute
+      the modified code is granted. Modifications are to be distributed by
+      using the file 'license.txt' as a template to modify the file header.
+      'license.txt' is available in the official MAPM distribution.
+
+      To distribute modified source code, insert the file 'license.txt'
+      at the top of all modified source code files and edit accordingly.
+
+      This software is provided "as is" without express or implied warranty.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>src/zorbamisc/config/stdint.h</file>
+    <copyright>2006 Alexander Chemeris</copyright>
+    <foreign-notice>
+      Redistribution and use in source and binary forms, with or without
+      modification, are permitted provided that the following conditions are met:
+
+      1. Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+      2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+      3. The name of the author may be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+      THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+      WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+      MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+      EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+      PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+      OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+      WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+      OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+      ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>src/zorbautils/stemmer/</file>
+    <copyright>2001 Dr. Martin Porter</copyright>
+    <foreign-notice>
+      All the software given out on this Snowball site is covered by the BSD
+      License (see http://www.opensource.org/licenses/bsd-license.html), with
+      Copyright (c) 2001, Dr Martin Porter, and (for the Java developments)
+      Copyright (c) 2002, Richard Boulton.
+
+      Essentially, all this means is that you can do what you like with the code,
+      except claim another Copyright for it, or claim that it is issued under a
+      different license. The software is also issued without warranties, which
+      means that if anyone suffers through its use, they cannot come back and sue
+      you. You also have to alert anyone to whom you give the Snowball software to
+      the fact that it is covered by the BSD license.
+
+      We have not bothered to insert the licensing arrangement into the text of
+      the Snowball software.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>src/util/less.h</file>
+    <copyright>1998 Paul J. Lucas</copyright>
+    <foreign-notice>
+      Redistribution and use in source and binary forms, with or without
+      modification, are permitted provided that the following conditions are met:
+
+      o  Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+      o  Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+      o  The name of the author may not be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+      AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+      IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+      ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+      LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+      CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+      SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+      INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+      CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+      ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+      POSSIBILITY OF SUCH DAMAGE.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file is-modified="true">src/util/auto_vector.h</file>
+    <copyright>2003 Reliable Software</copyright>
+    <foreign-notice>
+      Redistribution and use in source and binary forms, with or without
+      modification, are permitted provided that the following conditions are met:
+
+      o  Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+      o  Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+      o  The name of the author may not be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+      AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+      IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+      ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+      LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+      CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+      SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+      INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+      CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+      ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+      POSSIBILITY OF SUCH DAMAGE.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>cmake_modules/FindBoost.cmake</file>
+    <copyright>
+      2006-2008 Andreas Schneider &lt;mail@xxxxxxxxxxxx&gt;
+      2007      Wengo
+      2007      Mike Jackson
+      2008      Andreas Pakulat &lt;apaku@xxxxxx&gt;
+    </copyright>
+    <foreign-notice>
+      Redistribution AND use is allowed according to the terms of the New BSD license.
+      For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>cmake_modules/FindJNI.cmake</file>
+    <file>cmake_modules/FindPythonLibs.cmake</file>
+    <file>cmake_modules/FindSWIG.cmake</file>
+    <copyright>2001-2009 Kitware, Inc.</copyright>
+    <foreign-notice>
+      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.
+
+      CMake - Cross Platform Makefile Generator
+      Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+      All rights reserved.
+
+      Redistribution and use in source and binary forms, with or without
+      modification, are permitted provided that the following conditions
+      are met:
+
+      * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+      * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+      * Neither the names of Kitware, Inc., the Insight Software Consortium,
+      nor the names of their contributors may be used to endorse or promote
+      products derived from this software without specific prior written
+      permission.
+
+      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+      A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+      HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+      ------------------------------------------------------------------------------
+
+      The above copyright and license notice applies to distributions of
+      CMake in source and binary form.  Some source files contain additional
+      notices of original copyright by their contributors; see each source
+      for details.  Third-party software packages supplied with CMake under
+      compatible licenses provide their own copyright notices documented in
+      corresponding subdirectories.
+
+      ------------------------------------------------------------------------------
+
+      CMake was initially developed by Kitware with the following sponsorship:
+
+      * National Library of Medicine at the National Institutes of Health
+      as part of the Insight Segmentation and Registration Toolkit (ITK).
+
+      * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
+      Visualization Initiative.
+
+      * National Alliance for Medical Image Computing (NAMIC) is funded by the
+      National Institutes of Health through the NIH Roadmap for Medical Research,
+      Grant U54 EB005149.
+
+      * Kitware, Inc.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>/xml.xsd</file>
+    <copyright>2001 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)</copyright>
+    <foreign-notice>
+      All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+      W3C Software Notice and License
+
+      This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
+
+      License
+
+      By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
+
+      Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
+      •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+      •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
+      •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
+
+      Disclaimers
+
+      THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+      COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+      The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>schemas/xslt-xquery-serialization.xsd</file>
+    <copyright>2010 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)</copyright>
+    <foreign-notice>
+      All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+      W3C Software Notice and License
+
+      This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
+
+      License
+
+      By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
+
+      Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
+      •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+      •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
+      •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
+
+      Disclaimers
+
+      THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+      COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+      The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>modules/w3c/xpath-functions.xsd</file>
+    <copyright>2005 World Wide Web Consortium, (Massachusetts Institute of Technology, European Research Consortium for Informatics and Mathematics, Keio University)</copyright>
+    <foreign-notice>
+      All Rights Reserved. This work is distributed under the W3C Software License [1] in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+      W3C Software Notice and License
+
+      This work (and included software, documentation such as READMEs, or other related items) is being provided by the copyright holders under the following license.
+
+      License
+
+      By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
+
+      Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications:
+      •The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
+      •Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software Short Notice should be included (hypertext is preferred, text is permitted) within the body of any redistributed or derivative code.
+      •Notice of any changes or modifications to the files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived.)
+
+      Disclaimers
+
+      THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+      COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+      The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>include/xqc.h</file>
+    <copyright>2008, Matthias Brantner, John Snelson</copyright>
+    <foreign-notice>
+      * All rights reserved.
+      *
+      * Redistribution and use in source and binary forms, with or without
+      * modification, are permitted provided that the following conditions are met:
+      *
+      *     * Redistributions of source code must retain the above copyright notice,
+      *       this list of conditions and the following disclaimer.
+      *     * Redistributions in binary form must reproduce the above copyright
+      *       notice, this list of conditions and the following disclaimer in the
+      *       documentation and/or other materials provided with the distribution.
+      *     * Neither the name of the developers nor the names of contributors may be
+      *       used to endorse or promote products derived from this software without
+      *       specific prior written permission.
+      *
+      * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+      * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+      * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+      * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+      * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+      * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+      * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+      * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+      * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+      * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+      * POSSIBILITY OF SUCH DAMAGE.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>modules/functx/functx.xq</file>
+    <copyright>2007 Datypic</copyright>
+    <foreign-notice>
+      : This library is free software; you can redistribute it and/or
+      : modify it under the terms of the GNU Lesser General Public
+      : License as published by the Free Software Foundation; either
+      : version 2.1 of the License.
+
+      : This library is distributed in the hope that it will be useful,
+      : but WITHOUT ANY WARRANTY; without even the implied warranty of
+      : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+      : Lesser General Public License for more details.
+
+      : You should have received a copy of the GNU Lesser General Public
+      : License along with this library; if not, write to the Free Software
+      : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>src/compiler/parser/FlexLexer.h</file>
+    <copyright>1993 The Regents of the University of California</copyright>
+    <foreign-notice>
+      // All rights reserved.
+      //
+      // This code is derived from software contributed to Berkeley by
+      // Kent Williams and Tom Epperly.
+      //
+      //  Redistribution and use in source and binary forms, with or without
+      //  modification, are permitted provided that the following conditions
+      //  are met:
+
+      //  1. Redistributions of source code must retain the above copyright
+      //  notice, this list of conditions and the following disclaimer.
+      //  2. Redistributions in binary form must reproduce the above copyright
+      //  notice, this list of conditions and the following disclaimer in the
+      //  documentation and/or other materials provided with the distribution.
+
+      //  Neither the name of the University nor the names of its contributors
+      //  may be used to endorse or promote products derived from this software
+      //  without specific prior written permission.
+
+      //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+      //  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+      //  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+      //  PURPOSE.
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>src/diagnostics/StackWalker.cpp</file>
+    <file>src/diagnostics/StackWalker.h</file>
+    <copyright>2005 Jochen Kalmbach </copyright>
+    <license>BSD</license>
+    <foreign-notice>
+      Under BSD License: http://www.opensource.org/licenses/bsd-license.php
+    </foreign-notice>
+  </foreign-files>
+  <foreign-files>
+    <file>src/util/singleton.h</file>
+    <file>src/util/threads.h</file>
+    <copyright>2001 Andrei Alexandrescu</copyright>
+    <foreign-notice>
+      This code accompanies the book:
+      Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+          Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+      Permission to use, copy, modify, distribute and sell this software for any
+          purpose is hereby granted without fee, provided that the above copyright
+          notice appear in all copies and that both that copyright notice and this
+          permission notice appear in supporting documentation.
+      The author or Addison-Wesley Longman make no representations about the
+          suitability of this software for any purpose. It is provided "as is"
+          without express or implied warranty.
+    </foreign-notice>
+  </foreign-files>
+
+  <external-lib mandatory="true">
+    <name>LIBXML2</name>
+    <version>2.2.16 or higher</version>
+    <website>http://xmlsoft.org/</website>
+    <license>MIT</license>
+    <copyright>1998-2002 Daniel Veillard.  All Rights Reserved.</copyright>
+    <foreign-notice>
+      Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+      The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+      Except as contained in this notice, the name of Daniel Veillard shall not
+      be used in advertising or otherwise to promote the sale, use or other deal-
+      ings in this Software without prior written authorization from him.
+    </foreign-notice>
+  </external-lib>
+
+  <external-lib mandatory="false">
+    <name>LIBXSLT</name>
+    <version>1.1.26</version>
+    <website>http://xmlsoft.org/XSLT/</website>
+    <license>MIT</license>
+    <copyright>2001-2002 Daniel Veillard.  All Rights Reserved.</copyright>
+    <foreign-notice>
+      Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+      The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+      Except as contained in this notice, the name of Daniel Veillard shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from him.
+
+    </foreign-notice>
+  </external-lib>
+
+  <external-lib mandatory="true">
+    <name>ICU4C</name>
+    <version>3.6 or higher</version>
+    <license>ICU License</license>
+    <website>http://www.icu-project.org/</website>
+    <copyright>1995-2011 International Business Machines Corporation and others </copyright>
+    <foreign-notice>
+      Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
+
+      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+      Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
+    </foreign-notice>
+  </external-lib>
+
+  <external-lib mandatory="false">
+    <name>CURL</name>
+    <version>above 7.12</version>
+    <website>http://curl.haxx.se/</website>
+    <license>MIT/X derivate license</license>
+    <copyright>1996 - 2011, Daniel Stenberg, &lt;daniel@xxxxxxx&gt;.</copyright>
+    <foreign-notice>
+      All rights reserved.
+
+      Permission to use, copy, modify, and distribute this software for any purpose
+      with or without fee is hereby granted, provided that the above copyright
+      notice and this permission notice appear in all copies.
+
+      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
+      NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+      DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+      OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+      OR OTHER DEALINGS IN THE SOFTWARE.
+
+      Except as contained in this notice, the name of a copyright holder shall not
+      be used in advertising or otherwise to promote the sale, use or other dealings
+      in this Software without prior written authorization of the copyright holder.
+    </foreign-notice>
+  </external-lib>
+
+  <external-lib mandatory="true">
+    <name>ICONV</name>
+    <version>above 1.12</version>
+    <website>http://www.gnu.org/software/libiconv/</website>
+    <license>LGPL</license>
+    <copyright>1998, 2010 Free Software Foundation, Inc.</copyright>
+  </external-lib>
+
+  <external-lib mandatory="true">
+    <name>ZLIB</name>
+    <version>1.2.5</version>
+    <website>http://www.zlib.net/</website>
+    <copyright>1995-2004 Jean-loup Gailly and Mark Adler</copyright>
+    <foreign-notice>
+      This software is provided 'as-is', without any express or implied
+      warranty.  In no event will the authors be held liable for any damages
+      arising from the use of this software.
+
+      Permission is granted to anyone to use this software for any purpose,
+      including commercial applications, and to alter it and redistribute it
+      freely, subject to the following restrictions:
+
+      1. The origin of this software must not be misrepresented; you must not
+      claim that you wrote the original software. If you use this software
+      in a product, an acknowledgment in the product documentation would be
+      appreciated but is not required.
+      2. Altered source versions must be plainly marked as such, and must not be
+      misrepresented as being the original software.
+      3. This notice may not be removed or altered from any source distribution.
+
+      Jean-loup Gailly jloup@xxxxxxxx
+      Mark Adler madler@xxxxxxxxxxxxxxxxxx
+    </foreign-notice>
+  </external-lib>
+
+  <external-lib mandatory="true">
+    <name>XERCES</name>
+    <version>2.8.0 or higher</version>
+    <website>http://xerces.apache.org/xerces-c/</website>
+    <license>Apache 2</license>
+    <copyright>Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.</copyright>
+    <foreign-notice>
+      http://www.apache.org/licenses/LICENSE-2.0
+    </foreign-notice>
+  </external-lib>
+
+  <external-lib mandatory="false">
+    <name>BOOST (boost_filesystem)</name>
+    <version>1.32 or higher</version>
+    <website>http://www.boost.org/</website>
+    <license>Boost Software License v1.0</license>
+    <copyright>
+      Beman Dawes, David Abrahams, 1998-2005.
+      Rene Rivera 2004-2007
+    </copyright>
+    <foreign-notice>
+      Permission is hereby granted, free of charge, to any person or organization
+      obtaining a copy of the software and accompanying documentation covered by
+      this license (the "Software") to use, reproduce, display, distribute,
+      execute, and transmit the Software, and to prepare derivative works of the
+      Software, and to permit third-parties to whom the Software is furnished to
+      do so, all subject to the following:
+
+      The copyright notices in the Software and this entire statement, including
+      the above license grant, this restriction and the following disclaimer,
+      must be included in all copies of the Software, in whole or in part, and
+      all derivative works of the Software, unless such copies or derivative
+      works are solely in the form of machine-executable object code generated by
+      a source language processor.
+
+      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+      FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+      SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+      FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+      ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+      DEALINGS IN THE SOFTWARE.
+    </foreign-notice>
+  </external-lib>
+
+  <external-app mandatory="false">
+    <name>FLEX</name>
+    <version>2.5.33</version>
+    <website>http://flex.sourceforge.net/</website>
+    <copyright>
+      2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The Flex Project.
+      1990, 1997 The Regents of the University of California. All rights reserved.
+    </copyright>
+    <foreign-notice>
+      Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+      1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+      2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+      
+      Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+      THIS SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+    </foreign-notice>
+  </external-app>
+
+  <external-app mandatory="false">
+    <name>BISON</name>
+    <version>2.4 or higher</version>
+    <website>http://www.gnu.org/software/bison/</website>
+    <license>GPL</license>
+    <copyright>1998, 2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.</copyright>
+  </external-app>
+
+  <external-app mandatory="false">
+    <name>DOXYGEN</name>
+    <version>v1.7.4 </version>
+    <website>www.doxygen.org</website>
+    <license>GPL</license>
+    <copyright>1997-2011 by Dimitri van Heesch</copyright>
+    <foreign-notice>
+      Permission to use, copy, modify, and distribute this software and its documentation under the terms of the GNU General Public License is hereby granted.
+      No representations are made about the suitability of this software for any purpose. 
+      It is provided "as is" without express or implied warranty. 
+      See the GNU General Public License for more details.
+
+      Documents produced by doxygen are derivative works derived from the input used in their production; they are not affected by this license.
+    </foreign-notice>
+  </external-app>
+
+  <external-app mandatory="true">
+    <name>CMAKE</name>
+    <version>2.8.4</version>
+    <website>http://www.cmake.org/</website>
+    <license>Creative Commons Attribution-NoDerivs 3.0 Unported License</license>
+    <copyright>2000-2009 Kitware, Inc., Insight Software Consortium. All rights reserved.</copyright>
+    <foreign-notice>
+      Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+      Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+      Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+      Neither the names of Kitware, Inc., the Insight Software Consortium, nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+    </foreign-notice>
+  </external-app>
+
+  <external-app mandatory="false">
+    <name>SWIG</name>
+    <version>2.0.4 or above</version>
+    <website>http://www.swig.org/</website>
+    <license>GPL</license>
+    <copyright>
+      1995-2011 The SWIG Developers
+      2005-2006 Arizona Board of Regents (University of Arizona).
+      1998-2005 University of Chicago.
+      1995-1998 The University of Utah and the Regents of the University of California
+    </copyright>
+    <foreign-notice>
+      SWIG is free software: you can redistribute it and/or modify it
+      under the terms of the GNU General Public License as published by
+      the Free Software Foundation, either version 3 of the License, or
+      (at your option) any later version. See the LICENSE-GPL file for
+      the full terms of the GNU General Public license version 3.
+
+      Portions of SWIG are also licensed under the terms of the licenses
+      in the file LICENSE-UNIVERSITIES. You must observe the terms of
+      these licenses, as well as the terms of the GNU General Public License,
+      when you distribute SWIG.
+
+      The SWIG library and examples, under the Lib and Examples top level
+      directories, are distributed under the following terms:
+
+      You may copy, modify, distribute, and make derivative works based on
+      this software, in source code or object code form, without
+      restriction. If you distribute the software to others, you may do
+      so according to the terms of your choice. This software is offered as
+      is, without warranty of any kind.
+
+      See the COPYRIGHT file for a list of contributors to SWIG and their
+      copyright notices.
+    </foreign-notice>
+  </external-app>
+</notice>

=== modified file 'README.txt'
--- README.txt	2010-11-24 20:36:42 +0000
+++ README.txt	2012-09-27 18:04:43 +0000
@@ -11,19 +11,19 @@
   -------------
 
   The documentation is included in the doc directory, as well as 
-  on the website of the project at http://www.zorba-xquery.com/doc/zorba-latest/zorba/html/.
+  on the website of the project at http://www.zorba-xquery.org/html/documentation
 
   Build & Installation
   --------------------
 
-  Please see the documentation on the web site or the doc directory
+  Please see the documentation on the web site or in the doc directory
   of the package.
 
   Bugs and errors
   ---------------
 
   Bug or error reports should be sent to
-  https://sourceforge.net/tracker/?group_id=226244&atid=1067586
+  https://bugs.launchpad.net/zorba.
 
 
   Licensing
@@ -42,7 +42,7 @@
 
   o If you have a concrete bug report for Zorba please go to the
   Zorba's Bug Database and submit your report:
-  https://sourceforge.net/tracker/?group_id=226244&atid=1067586
+  https://bugs.launchpad.net/zorba.
 
   o If you want to participate in actively developing Zorba or
-  support Zorba, please write a mail to: zorba@xxxxxxxxxxxxxxxx
+  support Zorba, please write a mail to: zorba-dev@xxxxxxxxxxxxxxxx

=== modified file 'WIN32.cpack'
--- WIN32.cpack	2011-06-24 17:59:32 +0000
+++ WIN32.cpack	2012-09-27 18:04:43 +0000
@@ -14,5 +14,3 @@
 #
 
 INCLUDE(InstallRequiredSystemLibraries)
-
-INSTALL(PROGRAMS $ENV{ZORBA_REQUIRED_DLLS} DESTINATION bin)

=== modified file 'bin/CMakeLists.txt'
--- bin/CMakeLists.txt	2011-07-01 16:07:54 +0000
+++ bin/CMakeLists.txt	2012-09-27 18:04:43 +0000
@@ -15,33 +15,38 @@
 INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/src/)
 INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR})
 
-IF(ZORBA_WITH_DEBUGGER_CLIENT)
-  CONFIGURE_FILE (debug_client/event_handler_init.cpp.in debug_client/event_handler_init.cpp)
-  
-  SET(DEBUG_CLIENT_SRCS
-      debug_client/tuple.h
-      debug_client/main.cpp
-      debug_client/debug_command.h
-      debug_client/debug_command.cpp
-      debug_client/command_line_handler.h
-      debug_client/command_line_handler.cpp
-      debug_client/lock_free_queue.h
-      debug_client/event_handler.h
-      debug_client/event_handler.cpp
-      ${CMAKE_CURRENT_BINARY_DIR}/debug_client/event_handler_init.cpp
+IF (ZORBA_WITH_DEBUGGER)
+  IF (NOT WIN32)
+    FIND_PACKAGE (Libedit)
+    IF (LIBEDIT_FOUND)
+      INCLUDE_DIRECTORIES (${LIBEDIT_INCLUDE_DIRS})
+      SET (LIBEDIT_LIBS ${LIBEDIT_LIBRARIES})
+      SET (ZORBA_HAVE_LIBEDIT_H ${LIBEDIT_FOUND})
+    ENDIF (LIBEDIT_FOUND)
+  ENDIF (NOT WIN32)
+
+  CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/debugger/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/debugger/config.h)
+  MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/debugger/config.h.cmake --> ${CMAKE_CURRENT_BINARY_DIR}/debugger/config.h")
+  INCLUDE_DIRECTORIES (BEFORE ${CMAKE_CURRENT_BINARY_DIR}/debugger)
+
+  SET (DEBUG_CLIENT_SRCS
+    debugger/main.cpp
+    debugger/xqdb_client.cpp
+    debugger/process_listener.cpp
+    debugger/command_prompt.cpp
+    debugger/command_line_handler.cpp
+    debugger/event_handler.cpp
   )
   
-  CONFIGURE_FILE (debug_client/message-handler.xq message-handler.xq)
-  
-  ZORBA_GENERATE_EXE("debuggercmd" "${DEBUG_CLIENT_SRCS}" "" "debugger" "bin")
-ENDIF(ZORBA_WITH_DEBUGGER_CLIENT)
+  ZORBA_GENERATE_EXE ("xqdb" "${DEBUG_CLIENT_SRCS}" "${LIBEDIT_LIBS}" "xqdb" "bin")
+ENDIF (ZORBA_WITH_DEBUGGER)
 
 SET(SRCS
   zorbacmd.cpp
   zorbacmdproperties.cpp
   error_printer.cpp
   util.cpp
-  module_path.cpp
+  path_util.cpp
 )
 
 INCLUDE("${CMAKE_SOURCE_DIR}/cmake_modules/ZorbaGenerateExe.cmake")
@@ -71,16 +76,50 @@
 
 # test the compile-only option of the command line tool which is used for semantic checking in eclipse
 ZORBA_ADD_TEST(bin/zorba_compilechk1 zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/test/mymod.xq" -f -l)
-ZORBA_SET_TEST_PROPERTY(bin/zorba_compilechk1 PASS_REGULAR_EXPRESSION ".*mymod.xq>:6,8:.*:XPST0008.*")
+ZORBA_SET_TEST_PROPERTY(bin/zorba_compilechk1 PASS_REGULAR_EXPRESSION ".*mymod.xq>:22,8:.*:XPST0008.*")
 
 ZORBA_ADD_TEST(bin/zorba_compilechk2 zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/test/mymod.xq" -f -l -x)
-ZORBA_SET_TEST_PROPERTY(bin/zorba_compilechk2 PASS_REGULAR_EXPRESSION ".*XPST0008.*mymod.xq' line='6' column='8'.*")
+ZORBA_SET_TEST_PROPERTY(bin/zorba_compilechk2 PASS_REGULAR_EXPRESSION ".*XPST0008.*mymod.xq' lineStart='22' columnStart='8' lineEnd='22' columnEnd='10'.*")
 
 # test compile checking to work with library modules that have an invalid target namespace uri
 # test for bug #2934414
 ZORBA_ADD_TEST(bin/zorba_compilechk3 zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/test/mymod2.xq" -f -l -x)
-ZORBA_SET_TEST_PROPERTY(bin/zorba_compilechk3 PASS_REGULAR_EXPRESSION ".*XQST0046.*mymod2.xq' line='1' column='1'.*")
+ZORBA_SET_TEST_PROPERTY(bin/zorba_compilechk3 PASS_REGULAR_EXPRESSION ".*XQST0046.*mymod2.xq' lineStart='17' columnStart='1' lineEnd='17' columnEnd='26'.*")
 
 # test the --option option to set an option in the static context
 ZORBA_ADD_TEST(bin/zorba_option zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/test/option.xq" -f --option "{http://www.zorba-xquery.com}option=value";)
 ZORBA_SET_TEST_PROPERTY(bin/zorba_option PASS_REGULAR_EXPRESSION "value")
+
+# test the --uri-path, --lib-path, and --module-path args.
+# Use the versioning tests as they utilize test modules already.
+SET (_testdir
+  "${CMAKE_CURRENT_SOURCE_DIR}/../test/rbkt/Queries/zorba/versioning")
+SET (_uridir "${CMAKE_BINARY_DIR}/TEST_URI_PATH")
+SET (_libdir "${CMAKE_BINARY_DIR}/TEST_LIB_PATH")
+ZORBA_ADD_TEST(bin/zorba_uri_path_1 zorbacmd -f -q "${_testdir}/import1.xq"
+  --uri-path "${_uridir}")
+ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_1
+  PASS_REGULAR_EXPRESSION "hello, v2")
+
+ZORBA_ADD_TEST(bin/zorba_uri_path_2 zorbacmd -f -q "${_testdir}/external1.xq"
+  --uri-path "${_uridir}")
+ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_2
+  PASS_REGULAR_EXPRESSION "ZXQP0008")
+
+ZORBA_ADD_TEST(bin/zorba_uri_path_3 zorbacmd -f -q "${_testdir}/external1.xq"
+  --uri-path "${_uridir}" --lib-path "${_libdir}")
+ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_3
+  PASS_REGULAR_EXPRESSION "hello, v2")
+
+IF(WIN32)
+  SET(PATH_SEP ";")
+ELSE(WIN32)
+  SET(PATH_SEP ":")
+ENDIF(WIN32)
+ZORBA_ADD_TEST(bin/zorba_module_path_1 zorbacmd -f -q "${_testdir}/external1.xq"
+  --module-path "${_libdir}${PATH_SEP}${_uridir}")
+ZORBA_SET_TEST_PROPERTY(bin/zorba_module_path_1
+  PASS_REGULAR_EXPRESSION "hello, v2")
+
+# test compilation of the perf script
+ZORBA_ADD_TEST(bin/zorba_compilechk4 zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/../test/zperf/src/start.xq" -f --compile-only)

=== removed file 'bin/debug_client/debug_command.cpp'
--- bin/debug_client/debug_command.cpp	2011-07-01 01:53:24 +0000
+++ bin/debug_client/debug_command.cpp	1970-01-01 00:00:00 +0000
@@ -1,99 +0,0 @@
-/*
- * 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 <iostream>
-#include "debug_client/debug_command.h"
-
-namespace zorba { namespace debugclient {
-  
-  
-  void CommandLine::execute()
-  {
-    for (;;) {
-      std::cout << "zdb>> ";
-      std::string command;
-      std::getline(std::cin, command);
-      std::vector<std::string> args;
-      args << command;
-      std::map<std::string, UntypedCommand*>::iterator lIter = theCommands.find(args[0]);
-      if (lIter == theCommands.end()) {
-        std::cout << args[0] << ": Command not found" << std::endl;
-        continue;
-      }
-      if (!lIter->second->execute(args))
-        continue;
-      return;
-    }
-  }
-  
-  
-  CommandLine::~CommandLine()
-  {
-    for (std::map<std::string, UntypedCommand*>::iterator i = theCommands.begin();
-         i != theCommands.end(); ++i)
-    {
-      delete i->second;
-    }
-  }
-  
-  CommandLine& CommandLine::operator<<(UntypedCommand *aCommand)
-  {
-    theCommands.insert(std::make_pair(aCommand->get_name(), aCommand));
-    return *this;
-  }
-}}
-
-namespace std {
-  vector<string>& operator<< (vector<string>& vec, const string& str)
-  {
-    string::size_type before = 0;
-    string::size_type pos = str.find(" ", 0);
-    while (pos != str.npos) {
-      std::string lSub = str.substr(before, pos - before);
-      if (lSub[0] == '"') {
-        std::string::size_type lBeforeCopy = before;
-        do {
-          lBeforeCopy = str.find("\"", lBeforeCopy + 1);
-        } while (pos != str.npos && str.size() > pos + 1 && str[pos + 1] == '\\');
-        pos = lBeforeCopy;
-        lSub = str.substr(before + 1, pos - before - 1);
-      }
-      vec.push_back(lSub);
-      before = pos + 1;
-      pos = str.find(" ", before);
-    }
-    std::string lSub = str.substr(before);
-    if (lSub[0] == '"') {
-      pos = str.find("\"", before + 1);
-      lSub = str.substr(before + 1, pos - before - 1);
-    }
-    vec.push_back(lSub);
-    return vec;
-  }
-  
-  set<string>& operator<< (set<string>& vec, const string& str)
-  {
-    string::size_type before = 0;
-    string::size_type pos = str.find(" ", 0);
-    while (pos != str.npos) {
-      vec.insert(str.substr(before, pos));
-      before = pos + 1;
-      pos = str.find(" ", before);
-    }
-    vec.insert(str.substr(before));
-    return vec;
-  }
-
-}

=== removed file 'bin/debug_client/event_handler_init.cpp.in'
--- bin/debug_client/event_handler_init.cpp.in	2011-07-01 01:53:24 +0000
+++ bin/debug_client/event_handler_init.cpp.in	1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
-/*
- * 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 "debug_client/event_handler.h"
-
-namespace zorba { namespace debugclient {
-
-  std::istream* EventHandler::getCurrentDirectory() {
-    const char* build_dir = "@CMAKE_BINARY_DIR@/bin/message-handler.xq";
-    const char* install_dir = 
-#ifndef WIN32
-    "@CMAKE_INSTALL_PREFIX@/bin/";
-#else
-    "C:/Program Files/Zorba XQuery Processor @ZORBA_MAJOR_NUMBER@.@ZORBA_MINOR_NUMBER@.@ZORBA_PATCH_NUMBER@/bin/";
-#endif
-    std::auto_ptr<std::ifstream> stream(new std::ifstream(build_dir));
-    if (stream->good()) {
-      return stream.release();
-    }
-    stream.reset(new std::ifstream(install_dir));
-    if (stream->good()) {
-      return stream.release();
-    }
-    return 0;
-  }
-
-}} // end of namespace zorba::debugclient
-

=== removed file 'bin/debug_client/lock_free_queue.cpp'
--- bin/debug_client/lock_free_queue.cpp	2011-07-01 01:53:24 +0000
+++ bin/debug_client/lock_free_queue.cpp	1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
-/*
- * 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 "lock_free_queue.h"

=== removed file 'bin/debug_client/message-handler.xq'
--- bin/debug_client/message-handler.xq	2011-07-01 01:53:24 +0000
+++ bin/debug_client/message-handler.xq	1970-01-01 00:00:00 +0000
@@ -1,149 +0,0 @@
-import module namespace refl = 'http://www.zorba-xquery.com/modules/reflection';
-import module namespace sctx = "http://www.zorba-xquery.com/modules/introspection/sctx";;
-import module namespace base64 = "http://www.zorba-xquery.com/modules/converters/base64";;
-
-
-declare variable $local:localns as xs:string := 'http://www.w3.org/2005/xquery-local-functions';
-
-
-declare variable $local:endl as xs:string := '
-';
-
-declare function local:has-to-stop($resp as element())
-{
-  fn:not(($resp/@command/data(.) eq "stop" and $resp/@reason/data(.) eq "ok")
-    or ($resp/@status/data(.) eq "stopped")
-    or ($resp/@status/data(.) eq "stopping"))
-};
-
-declare function local:status($resp as element())
-{
-  fn:concat(
-    "Status: ", $resp/@status/data(.), $local:endl,
-    "Reason: ", $resp/@reason/data(.), $local:endl,
-    let $msg := $resp/text()
-    return
-      if (fn:empty($msg) or $msg eq "") then
-        ""
-      else
-        fn:concat($msg, $local:endl)
-  )
-};
-
-
-declare function local:run($resp as element()) {
-  if ($resp/@status/data(.) eq "starting") then
-    "Starting query"
-  else
-    local:status($resp)
-};
-
-declare function local:stop($resp as element())
-{
-  local:status($resp)
-};
-
-declare function local:breakpoint_set($resp as element())
-{
-  if ($resp/error) then
-    fn:concat("Error when setting a breakpoint: ", if ($resp/error/message) then $resp/error/message/text() else concat(" errcode: ", data($resp/error/@code)))
-  else
-    fn:concat("set breakpoint with id ", data($resp/@id), " and state ", data($resp/@state))
-};
-
-declare function local:breakpoint_list($resp as element())
-{
-  string-join(
-    for $b in $resp/breakpoint
-    return concat("Breakpoint ", data($b/@id), " at ", data($b/@filename), ":", data($b/@lineno), " ", data($b/@state)),
-    $local:endl
-  )
-};
-
-declare function local:breakpoint_remove($resp as element())
-{
-  "Breakpoint removed"
-};
-
-declare function local:stack_depth($resp as element())
-{
-  concat("Depth: ", data($resp/@depth))
-};
-
-declare function local:stack_get($resp as element())
-{
-  string-join(
-    for $s in $resp/stack
-    return concat("Level ", data($s/@level), " at ", data($s/@filename), ":", data($s/@lineno)),
-    $local:endl
-  )
-};
-
-
-declare function local:context_names($resp as element())
-{
-  string-join(
-    for $c in $resp/context
-    return concat("Context: ", data($c/@name), " id: ", data($c/@id)),
-    $local:endl
-  )
-};
-
-declare function local:context_get($resp as element())
-{
-  string-join(
-    for $p in $resp/property
-    return concat(data($p/@fullname), ": [", data($p/@type), "]",
-                  if ($p/text() ne "") then concat(": ", base64:decode($p/text())) else ""),
-    $local:endl
-  )
-};
-
-declare function local:eval($resp as element())
-{
-  if (data($resp/@success) eq "1") then
-    local:context_get($resp)
-  else
-    concat("Eval failed", ":", $resp/error/message/text())
-};
-
-declare function local:process-response($resp as element())
-{
-  if (data($resp/@command) eq "") then
-    (fn:true(), $resp/@transaction_id/data(.), local:status($resp))
-  else
-    let $fun-cont-name := fn:QName($local:localns, concat("local:", $resp/@command/data(.), "-cont"))
-    let $fun-msg-name := fn:QName($local:localns, concat("local:", $resp/@command/data(.)))
-    return (
-      if (sctx:function-arguments-count($fun-cont-name) = 1) then
-        refl:invoke-simple($fun-cont-name, $resp)
-      else
-        local:has-to-stop($resp),
-      $resp/@transaction_id/data(.),
-      if (sctx:function-arguments-count($fun-msg-name) = 1) then
-        refl:invoke-simple($fun-msg-name, $resp)
-      else
-        "Recieved a message - command not implemented"
-    )
-};
-
-declare function local:process-init($init as element())
-{
-  fn:true(),
-  0,
-  fn:concat(fn:string-join(
-  ('Established connection with', $init/@language/data(.), 'client', $init/@appid/data(.)), ' '), '
-')
-};
-
-declare function local:main($response as element()) {
-  let $process-fun as xs:QName := fn:QName($local:localns, concat("local:process-", node-name($response)))
-  return
-    if (sctx:function-arguments-count($process-fun) = 1) then
-      refl:invoke-simple($process-fun, $response)
-    else (
-          true(),
-          ($response/@transaction_id, 0)[1]/data(.),
-          "ERROR: Recieved unknown node from client"
-         )
-};

=== renamed directory 'bin/debug_client' => 'bin/debugger'
=== renamed file 'bin/debug_client/debug_command.h' => 'bin/debugger/command.h'
--- bin/debug_client/debug_command.h	2011-07-04 08:05:46 +0000
+++ bin/debugger/command.h	2012-09-27 18:04:43 +0000
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 #pragma once
-#include <zorba/config.h>
+#ifndef ZORBA_DEBUGGER_COMMAND_H
+#define ZORBA_DEBUGGER_COMMAND_H
+
 #include <string>
 #include <vector>
 #include <iostream>
@@ -23,151 +25,18 @@
 #include <sstream>
 #include <memory>
 #include <typeinfo>
-#include "debug_client/tuple.h"
-
-namespace zorba { namespace debugclient {
+
+#include <zorba/config.h>
+
+#include "command_arg.h"
+#include "tuple.h"
+
+
+namespace zorba { namespace debugger {
   
   class DebugClientParseException : public std::exception {
   };
   
-  template<typename Tuple>
-  class CommandArg;
-  
-  template<typename Tuple>
-  class CommandArgInstance {
-  public:
-    virtual int get_index() const = 0;
-    virtual const CommandArg<Tuple>* get_arg() const = 0;
-    virtual void insertValue(Tuple& t) = 0;
-    virtual bool isSet(Tuple& t) const = 0;
-  };
-  
-  template<typename T, int Idx, typename Tuple>
-  class TypedCommandArgInstance : public CommandArgInstance<Tuple>
-  {
-  public:
-    TypedCommandArgInstance(T aValue, const CommandArg<Tuple>* aArg)
-    : theValue(aValue), theArg(aArg) {}
-    virtual int get_index() const { return Idx; }
-    virtual const CommandArg<Tuple>* get_arg() const { return theArg; }
-    virtual void insertValue(Tuple& t)
-    {
-      ZORBA_TR1_NS::get<Idx>(t).first = true;
-      ZORBA_TR1_NS::get<Idx>(t).second = theValue;
-    }
-    virtual bool isSet(Tuple& t) const
-    {
-      return ZORBA_TR1_NS::get<Idx>(t).first;
-    }
-  private:
-    T theValue;
-    const CommandArg<Tuple>* theArg;
-  };
-  
-  template<typename Tuple>
-  class CommandArgType {
-  public:
-    virtual CommandArgInstance<Tuple>* parse(const std::string& str,
-                                             const CommandArg<Tuple>* arg) = 0;
-    virtual bool isVoid() const = 0;
-    virtual bool isSet(Tuple& t) const = 0;
-    virtual ~CommandArgType() {}
-  };
-  
-  template<typename T, int Idx, typename Tuple>
-  class TypedCommandArgType : public CommandArgType<Tuple> {
-  public:
-    typedef T Type;
-  public: // implementation
-    TypedCommandArgType(bool aIsVoid) : theIsVoid(aIsVoid) {}
-    TypedCommandArgType(const T& aValue,
-                        bool aIsVoid)
-    : theDefault(aValue), theIsVoid(aIsVoid) {}
-    virtual CommandArgInstance<Tuple>* parse(const std::string& str,
-                                             const CommandArg<Tuple>* arg)
-    {
-      T aValue;
-      std::stringstream stream(str);
-      stream >> aValue;
-      if (stream.fail()) {
-        std::cerr << "Could not parse argument of type "
-          << typeid(T).name()
-          << std::endl;
-        return 0;
-      }
-      return new TypedCommandArgInstance<T, Idx, Tuple>(aValue, arg);
-    }
-    virtual bool isVoid() const { return theIsVoid; }
-    virtual bool isSet(Tuple& t) const
-    {
-      return ZORBA_TR1_NS::get<Idx>(t).first;
-    }
-  private:
-    TypedCommandArgType<T, Idx, Tuple>() {}
-    T theDefault;
-    bool theIsVoid;
-  };
-
-  template<typename Tuple>
-  class CommandArg {
-  public:
-    CommandArg(unsigned aId,
-               CommandArgType<Tuple>* aType,
-               const std::set<std::string>& aFlags,
-               const std::string& aDescription,
-               bool aIsRequired)
-    : theId(aId),
-    theType(aType),
-    theFlags(aFlags),
-    theDescription(aDescription),
-    theIsRequired(aIsRequired)
-    {
-    }
-    ~CommandArg() { delete theType; }
-    unsigned get_id() const { return theId; }
-    bool canHandle(const std::string& arg) const
-    {
-      if (theFlags.find(arg) != theFlags.end()) {
-        return true;
-      }
-      return false;
-    }
-    CommandArgInstance<Tuple>* parse(const std::string& str) const
-    {
-      return theType->parse(str, this);
-    }
-    bool isVoid() const {
-      return theType->isVoid();
-    }
-    bool isRequired() const { return theIsRequired; }
-    std::string get_name() const {
-      return *(theFlags.begin());
-    }
-    bool isSet(Tuple& t) const
-    {
-      return theType->isSet(t);
-    }
-  private:
-    unsigned theId;
-    CommandArgType<Tuple>* theType;
-    std::set<std::string> theFlags;
-    std::string theDescription;
-    bool theIsRequired;
-  };
-}} // end namespace zorba
-
-namespace std {
-  
-  /**
-   * This is a helper split function
-   */
-  vector<string>& operator<< (vector<string>& vec, const string& str);
-  
-  set<string>& operator<< (set<string>& vec, const string& str);
-} //end namespace std
-
-namespace zorba { namespace debugclient {
-
   template<typename Func, typename Tuple, int CommandIdx>
   class CommandInstance
   {
@@ -188,8 +57,11 @@
   
   class UntypedCommand {
   public:
-    virtual std::string get_name() const = 0;
-    virtual std::string get_description() const = 0;
+    virtual ~UntypedCommand() {}
+    virtual std::string getName() const = 0;
+    virtual std::set<std::string> getAliases() const = 0;
+    virtual std::string getDescription() const = 0;
+    virtual void printHelp() const = 0;
     virtual bool execute(const std::vector<std::string>& args) = 0;
   };
   
@@ -197,77 +69,141 @@
   class Command : public UntypedCommand {
   public:
     Command(const std::string& aName, Func& aFunction, const std::string& aDescription)
-      : theName(aName), theFunction(aFunction), theDescription(aDescription) {}
+      : theName(aName), theFunction(aFunction), theDescription(aDescription)
+    {}
+
+    Command(const std::string& aName, const std::set<std::string> aAliases, Func& aFunction, const std::string& aDescription)
+      : theName(aName), theAliases(aAliases), theFunction(aFunction), theDescription(aDescription)
+    {}
+
     ~Command();
+
   public:
-    Command& operator() (unsigned aId,
-                         const std::string& aFlags,
-                         CommandArgType<Tuple>* aType,
-                         const std::string& aDescription = "",
-                         bool isRequired = false);
-    virtual std::string get_name() const { return theName; }
-    virtual std::string get_description() const { return theDescription; }
+
+    void
+    addArgument(
+      unsigned aId,
+      const std::string& aFlags,
+      CommandArgType<Tuple>* aType,
+      const std::string& aDescription = "",
+      bool isRequired = false);
+
+    static void
+    splitNames(
+      const std::string& names,
+      std::set<std::string>& set);
+
+    virtual std::string
+    getName() const
+    {
+      return theName;
+    }
+
+    virtual std::set<std::string> getAliases() const
+    {
+      return theAliases;
+    }
+
+    virtual std::string
+    getDescription() const
+    {
+      return theDescription;
+    }
+
+    virtual void
+    printHelp() const;
+
     virtual bool execute(const std::vector<std::string>& args)
     {
       CommandInstance<Func, Tuple, CommandIdx> instance(theFunction, theTuple);
-      if (instance.parseArguments(args, theArgs))
+      if (instance.parseArguments(args, theArgs)) {
         instance.execute();
-      else
-        return false;
-      return true;
+        return true;
+      }
+      return false;
     }
   private:
     std::string theName;
+    std::set<std::string> theAliases;
     Func& theFunction;
     Tuple theTuple;
     std::string theDescription;
-    std::map<std::string, CommandArg<Tuple>* > theArgs;
-  };
-  
-  class CommandLine {
-  public:
-    ~CommandLine();
-  public:
-    void execute();
-    CommandLine& operator<< (UntypedCommand* aCommand);
-  private:
-    std::map<std::string, UntypedCommand*> theCommands;
-  };
-  
-  template<typename Func, typename Tuple, int CommandIdx>
-  Command<Func, Tuple, CommandIdx>::~Command()
-  {
-    typedef std::map<std::string, CommandArg<Tuple>* > ArgType;
-    for (typename ArgType::iterator i = theArgs.begin(); i != theArgs.end(); ++i) {
-      delete i->second;
-    }
-  }
-    
- 
-  template<typename Func, typename Tuple, int CommandIdx>
-  Command<Func, Tuple, CommandIdx>& 
-  Command<Func, Tuple, CommandIdx>::operator() (unsigned aId,
-                                    const std::string& aFlags,
-                                    CommandArgType<Tuple>* aType,
-                                    const std::string& aDescription,
-                                    bool isRequired)
-  {
-    std::set<std::string> args;
-    args << aFlags;
-    for (std::set<std::string>::iterator i = args.begin(); i != args.end(); ++i) {
-      std::string toAdd = (i->size() == 1) ? "-" + *i : "--" + *i;
-      theArgs.insert(std::make_pair(toAdd,
-                                    new CommandArg<Tuple>(aId,
-                                                          aType,
-                                                          args,
-                                                          aDescription,
-                                                          isRequired)
-                                    )
-                     );
-    }
-    return *this;
-  }
-  
+    std::map<std::string, CommandArg<Tuple>*> theArgs;
+  };
+
+/*****************************************************************************/
+/*****************************************************************************/
+
+template<typename Func, typename Tuple, int CommandIdx>
+Command<Func, Tuple, CommandIdx>::~Command()
+{
+  typedef std::map<std::string, CommandArg<Tuple>*> ArgType;
+  for (typename ArgType::iterator i = theArgs.begin(); i != theArgs.end(); ++i) {
+    delete i->second;
+  }
+}
+
+template<typename Func, typename Tuple, int CommandIdx>
+void
+Command<Func, Tuple, CommandIdx>::printHelp() const
+{
+  std::cout << "Purpose: " << getDescription() << std::endl;
+
+  typename std::map<std::string, CommandArg<Tuple>*>::const_iterator lIter = theArgs.begin();
+  if (lIter == theArgs.end()) {
+    std::cout << "This command has no arguments." << std::endl;
+    std::cout << std::endl;
+    return;
+  }
+  
+  std::cout << "Arguments:" << std::endl << std::endl;
+  for (; lIter != theArgs.end(); ++lIter) {
+    std::cout << "  " << lIter->first << "\t" << lIter->second->getDescription() << std::endl;
+  }
+  std::cout << std::endl;
+}
+
+template<typename Func, typename Tuple, int CommandIdx>
+void
+Command<Func, Tuple, CommandIdx>::splitNames(const std::string& aNames, std::set<std::string>& aSet)
+{
+  std::string::size_type before = 0;
+  std::string::size_type pos = aNames.find(" ", 0);
+  while (pos != aNames.npos) {
+    std::string lName = aNames.substr(before, pos);
+    if (lName != "") {
+      aSet.insert(lName);
+    }
+    before = pos + 1;
+    pos = aNames.find(" ", before);
+  }
+  std::string lName = aNames.substr(before);
+  if (lName != "") {
+    aSet.insert(lName);
+  }
+}
+
+template<typename Func, typename Tuple, int CommandIdx>
+void
+Command<Func, Tuple, CommandIdx>::addArgument(
+  unsigned aId,
+  const std::string& aFlags,
+  CommandArgType<Tuple>* aType,
+  const std::string& aDescription,
+  bool isRequired)
+{
+  std::set<std::string> lNames;
+  splitNames(aFlags, lNames);
+
+  for (std::set<std::string>::iterator i = lNames.begin(); i != lNames.end(); ++i) {
+    std::string toAdd = (i->size() == 1) ? "-" + *i : "--" + *i;
+    CommandArg<Tuple>* lArg = new CommandArg<Tuple>(aId, aType, lNames, aDescription, isRequired);
+    theArgs.insert(std::make_pair(toAdd, lArg));
+  }
+}
+
+/*****************************************************************************/
+
   template<typename Tuple, typename T, int Idx>
   CommandArgType<Tuple>* createArgType(Tuple t)
   {
@@ -290,6 +226,16 @@
     return new Command<Func, Tuple, CommandIdx>(aName, aFunction, aDescription);
   }
   
+  template<int CommandIdx, typename Tuple, typename Func>
+  Command<Func, Tuple, CommandIdx>* createCommand(Tuple t,
+                                                  const std::string& aName,
+                                                  const std::set<std::string>& aAliases,
+                                                  Func& aFunction,
+                                                  const std::string& aDescription)
+  {
+    return new Command<Func, Tuple, CommandIdx>(aName, aAliases, aFunction, aDescription);
+  }
+  
   template<typename Func, typename Tuple, int CommandIdx>
   bool CommandInstance<Func, Tuple, CommandIdx>::
   parseArguments(const std::vector<std::string>& args,
@@ -301,29 +247,34 @@
     for (ArgType::size_type i = 1; i < size; ++i) {
       typename CArgType::const_iterator pos = aCommandArgs.find(args[i]);
       if (pos == aCommandArgs.end()) {
-        std::cerr << "Error: Unknown Argument " << args[i] << std::endl;
+        std::cerr << "Error: Unknown option " << args[i] << std::endl;
         parseError = true;
         return false;
       }
       const CommandArg<Tuple>& arg = *(pos->second);
-      if (!arg.isVoid() && args[++i][0] == '-') {
-        std::cerr << "Did not expect parameter for option " << args[i] << std::endl;
-        return false;
-      }
       std::auto_ptr<CommandArgInstance<Tuple> > instance;
       if (arg.isVoid()) {
         instance.reset(arg.parse("1"));
       } else {
+        ++i;
+        if (i >= size) {
+          std::cerr << "Error: Missing value for argument " << args[i - 1] << std::endl;
+          parseError = true;
+          allSet = false;
+          return false;
+        }
         instance.reset(arg.parse(args[i]));
       }
-      instance->insertValue(theTuple);
+      if (instance.get()) {
+        instance->insertValue(theTuple);
+      }
     }
     bool allSet = true;
     for (typename CArgType::const_iterator i = aCommandArgs.begin();
          i != aCommandArgs.end(); ++i)
     {
       if (i->second->isRequired() && !i->second->isSet(theTuple)) {
-        std::cerr << "Error: Argument " << i->second->get_name() << " not set" << std::endl;
+        std::cerr << "Error: Argument -" << i->second->getName() << " not set" << std::endl;
         allSet = false;
       }
     }
@@ -336,4 +287,7 @@
     theFunction.template handle<CommandIdx>(this->theTuple);
   }
 
-}} // end of namespace zorba::debugclient
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_COMMAND_H

=== added file 'bin/debugger/command_arg.h'
--- bin/debugger/command_arg.h	1970-01-01 00:00:00 +0000
+++ bin/debugger/command_arg.h	2012-09-27 18:04:43 +0000
@@ -0,0 +1,237 @@
+/*
+ * 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.
+ */
+#pragma once
+#ifndef ZORBA_DEBUGGER_COMMAND_ARG_H
+#define ZORBA_DEBUGGER_COMMAND_ARG_H
+
+#include <string>
+#include <iostream>
+#include <set>
+#include <sstream>
+
+#include "tuple.h"
+
+
+namespace zorba { namespace debugger {
+
+template<typename Tuple>
+class CommandArg;
+
+template<typename Tuple>
+class CommandArgInstance {
+  public:
+    virtual int get_index() const = 0;
+    virtual const CommandArg<Tuple>* get_arg() const = 0;
+    virtual void insertValue(Tuple& t) = 0;
+    virtual bool isSet(Tuple& t) const = 0;
+};
+
+template<typename T, int Idx, typename Tuple>
+class TypedCommandArgInstance : public CommandArgInstance<Tuple>
+{
+  public:
+    TypedCommandArgInstance(T aValue, const CommandArg<Tuple>* aArg)
+      : theValue(aValue), theArg(aArg)
+    {
+    }
+
+    virtual int
+    get_index() const
+    {
+      return Idx;
+    }
+
+    virtual const CommandArg<Tuple>*
+    get_arg() const
+    {
+      return theArg;
+    }
+
+    virtual void
+    insertValue(Tuple& t)
+    {
+      ZORBA_TR1_NS::get<Idx>(t).first = true;
+      ZORBA_TR1_NS::get<Idx>(t).second = theValue;
+    }
+
+    virtual bool isSet(Tuple& t) const
+    {
+      return ZORBA_TR1_NS::get<Idx>(t).first;
+    }
+
+  private:
+
+    T theValue;
+    const CommandArg<Tuple>* theArg;
+};
+  
+template<typename Tuple>
+class CommandArgType
+{
+  public:
+    virtual CommandArgInstance<Tuple>*
+    parse(
+      const std::string& str,
+      const CommandArg<Tuple>* arg) = 0;
+
+    virtual bool
+    isVoid() const = 0;
+  
+    virtual bool
+    isSet(Tuple& t) const = 0;
+
+    virtual ~CommandArgType() {}
+};
+  
+  template<typename T, int Idx, typename Tuple>
+  class TypedCommandArgType : public CommandArgType<Tuple> {
+  public:
+    typedef T Type;
+  public: // implementation
+    TypedCommandArgType(bool aIsVoid) : theIsVoid(aIsVoid) {}
+    TypedCommandArgType(const T& aValue,
+                        bool aIsVoid)
+    : theDefault(aValue), theIsVoid(aIsVoid) {}
+    virtual CommandArgInstance<Tuple>* parse(const std::string& str,
+                                             const CommandArg<Tuple>* arg)
+    {
+      T aValue;
+
+      // special treatment for strings
+      // this is a double hack:
+      // - we check the type name if this starts with: class std::basic_string
+      // - we use void* in readEntireString to workaround the template type T
+      //   which would otherwise complain during compilation if types and
+      //   operators do not match
+      // TOSO: probably someone can find a more elegant solution
+      std::string lTypeName(typeid(T).name());
+      if (lTypeName.find("class std::basic_string") == 0) {
+        readEntireString(str, &aValue);
+      } else {
+        std::stringstream stream(str);
+        std::stringstream out;
+        stream >> aValue;
+        if (stream.fail()) {
+          std::cerr << "Error: Could not parse value \"" << str << "\" as type "
+            << typeid(T).name()
+            << std::endl;
+          return 0;
+        }
+      }
+
+      return new TypedCommandArgInstance<T, Idx, Tuple>(aValue, arg);
+    }
+    virtual bool isVoid() const { return theIsVoid; }
+    virtual bool isSet(Tuple& t) const
+    {
+      return ZORBA_TR1_NS::get<Idx>(t).first;
+    }
+  private:
+    void readEntireString(std::string aIn, void* aValue)
+    {
+      *((std::string*)aValue) = aIn;
+    }
+
+    TypedCommandArgType<T, Idx, Tuple>() {}
+    T theDefault;
+    bool theIsVoid;
+  };
+
+  template<typename Tuple>
+  class CommandArg {
+  public:
+    CommandArg(unsigned aId,
+               CommandArgType<Tuple>* aType,
+               const std::set<std::string>& aNames,
+               const std::string& aDescription,
+               bool aIsRequired)
+    : theId(aId),
+    theType(aType),
+    theNames(aNames),
+    theDescription(aDescription),
+    theIsRequired(aIsRequired)
+    {
+    }
+
+    ~CommandArg()
+    { 
+      delete theType;
+    }
+
+    unsigned
+    get_id() const
+    {
+      return theId;
+    }
+
+    bool
+    canHandle(const std::string& arg) const
+    {
+      if (theNames.find(arg) != theNames.end()) {
+        return true;
+      }
+      return false;
+    }
+
+    CommandArgInstance<Tuple>*
+    parse(const std::string& str) const
+    {
+      return theType->parse(str, this);
+    }
+
+    bool
+    isVoid() const
+    {
+      return theType->isVoid();
+    }
+    
+    bool
+    isRequired() const
+    {
+      return theIsRequired;
+    }
+
+    std::string
+    getName() const
+    {
+      return *(theNames.begin());
+    }
+
+    std::string
+    getDescription() const
+    {
+      return theDescription;
+    }
+
+    bool
+    isSet(Tuple& t) const
+    {
+      return theType->isSet(t);
+    }
+
+  private:
+
+    unsigned theId;
+    CommandArgType<Tuple>* theType;
+    std::set<std::string> theNames;
+    std::string theDescription;
+    bool theIsRequired;
+  };
+
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_COMMAND_ARG_H

=== modified file 'bin/debugger/command_line_handler.cpp'
--- bin/debug_client/command_line_handler.cpp	2011-07-01 01:53:24 +0000
+++ bin/debugger/command_line_handler.cpp	2012-09-27 18:04:43 +0000
@@ -1,4 +1,4 @@
-/*
+  /*
  * Copyright 2006-2008 The FLWOR Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,225 +23,385 @@
 # define msleep Sleep
 #endif
 
-namespace zorba { namespace debugclient {
+#include "command_prompt.h"
+
+
+namespace zorba { namespace debugger {
   
-  using namespace ::std;
   using namespace ::ZORBA_TR1_NS;
   
-  CommandLineHandler::CommandLineHandler(unsigned short port,
-                                         LockFreeConsumer<std::size_t>& aConsumer,
-                                         LockFreeConsumer<bool>& aContinueQueue,
-                                         EventHandler& aHandler,
-                                         CommandLine& aCommandLine)
+CommandLineHandler::CommandLineHandler(
+  unsigned short port,
+  LockFreeConsumer<std::size_t>& aConsumer,
+  LockFreeConsumer<bool>& aContinueQueue,
+  EventHandler* aHandler,
+  CommandPrompt* aCommandPrompt)
   : theConsumer(aConsumer),
     theContinueQueue(aContinueQueue),
-    theClient(DebuggerClient::createDebuggerClient(&aHandler, port, "localhost")),
-    theCommandLine(aCommandLine),
-    theQuit(false), theContinue(false), theWaitFor(0)
+    theClient(DebuggerClient::createDebuggerClient(aHandler, port, "localhost")),
+    theCommandLine(aCommandPrompt),
+    theQuit(false), theTerminated(true), theContinue(false), theWaitFor(0)
   {
     addCommands();
   }
   
-  CommandLineHandler::~CommandLineHandler()
-  {
-  }
+CommandLineHandler::~CommandLineHandler()
+{
+}
   
-  void CommandLineHandler::execute()
-  {
-    theClient->accept();
-    std::set<std::size_t> lIdList;
-    do {
+void
+CommandLineHandler::execute()
+{
+  theClient->accept();
+  std::set<std::size_t> lIdList;
+  do {
+    getNextId(lIdList);
+    while (lIdList.find(theWaitFor) == lIdList.end()) {
       getNextId(lIdList);
-      while (!theQuit && lIdList.find(theWaitFor) == lIdList.end()) {
-        getNextId(lIdList);
-        msleep(20);
-      }
-      while (!theContinueQueue.consume(theQuit)) {
-        msleep(20);
-      }
-      theQuit = !theQuit;
-      if (!theQuit) {
-        theCommandLine.execute();
-        while (theContinue) {
-          theContinue = false;
-          theCommandLine.execute();
-        }
-      }
-    } while (!theQuit);
-  }
-  
-  void CommandLineHandler::getNextId(std::set<std::size_t>& aIdList)
-  {
-    std::size_t result;
-    if (theConsumer.consume(result)) {
-      aIdList.insert(result);
-    }
-  }
-  
-  template<>
-  void CommandLineHandler::handle<Status>(ZORBA_TR1_NS::tuple<> &t)
-  {
-    theWaitFor = theClient->status();
-  }
-  
-  template<>
-  void CommandLineHandler::handle<Quit>(ZORBA_TR1_NS::tuple<> &t)
-  {
+      msleep(20);
+    }
+    bool lCanQuit;
+    while (!theContinueQueue.consume(lCanQuit)) {
+      msleep(20);
+    }
+    if (lCanQuit) {
+      theTerminated = true;
+    }
+    theCommandLine->execute();
+    while (theContinue) {
+      theContinue = false;
+      theCommandLine->execute();
+    }
+  } while (!theQuit);
+}
+  
+void
+CommandLineHandler::getNextId(std::set<std::size_t>& aIdList)
+{
+  std::size_t result;
+  if (theConsumer.consume(result)) {
+    aIdList.insert(result);
+  }
+}
+
+template<>
+void
+CommandLineHandler::handle<Status>(ZORBA_TR1_NS::tuple<> &t)
+{
+  theWaitFor = theClient->status();
+}
+
+template<>
+void
+CommandLineHandler::handle<Variables>(ZORBA_TR1_NS::tuple<> &t)
+{
+  theWaitFor = theClient->variables();
+}
+
+template<>
+void
+CommandLineHandler::handle<Quit>(ZORBA_TR1_NS::tuple<> &t)
+{
+  if (!theTerminated) {
     bool answered = false;
     while (!answered) {
       std::cout << "Do you really want to stop debugging and exit? (y/n) ";
-      char answer;
-      std::cin >> answer;
-      std::cout << std::endl;
-      if (answer == 'y') {
+      std::string lAnswer;
+      std::getline(std::cin, lAnswer);
+      if (lAnswer == "y" || lAnswer == "yes") {
         answered = true;
-      } else if (answered == 'n') {
+      } else if (lAnswer == "n" || lAnswer == "no") {
         theContinue = true;
         return;
       }
     }
-    theWaitFor = theClient->stop();
-    theClient->quit();
-  }
-  
-  template<>
-  void CommandLineHandler::handle<Run>(ZORBA_TR1_NS::tuple<> &t)
-  {
-    theWaitFor = theClient->run();
-  }
-  
-  template<>
-  void CommandLineHandler::handle<BreakpointSet>(std::tr1::tuple<bstring, bstring, bint> &t)
-  {
-    DebuggerClient::BreakpointType lType = DebuggerClient::Line;
-    bool lEnabled = true;
-    if (get<0>(t).first) {
-      if (get<0>(t).second == "disabled") {
-        lEnabled = false;
-      }
-    }
-    theWaitFor = theClient->breakpoint_set(lType,
-                                           lEnabled,
-                                           get<1>(t).second,
-                                           get<2>(t).second);
-  }
-  
-  template<>
-  void CommandLineHandler::handle<BreakpointGet>(tuple<bint> &aTuple)
-  {
-    theWaitFor = theClient->breakpoint_get(get<0>(aTuple).second);
-  }
-  
-  template<>
-  void CommandLineHandler::handle<BreakpointDel>(tuple<bint> &aTuple)
-  {
-    theWaitFor = theClient->breakpoint_remove(get<0>(aTuple).second);
-  }
-  
-  template<>
-  void CommandLineHandler::handle<BreakpointList>(tuple<> &t)
-  {
-    theWaitFor = theClient->breakpoint_list();
-  }
-  
-  template<>
-  void CommandLineHandler::handle<StackDepth>(tuple<> &t)
-  {
-    theWaitFor = theClient->stack_depth();
-  }
-  
-  template<>
-  void CommandLineHandler::handle<StackGet>(tuple<bint> &aTuple)
-  {
-    if (get<0>(aTuple).first) {
-      theWaitFor = theClient->stack_get(get<0>(aTuple).second);
-    } else {
-      theWaitFor = theClient->stack_get();
-    }
-  }
-  
-  template<>
-  void CommandLineHandler::handle<ContextNames>(tuple<>& aTuple)
-  {
-    theWaitFor = theClient->context_names();
-  }
-  
-  template<>
-  void CommandLineHandler::handle<ContextGet>(tuple<bint> &aTuple)
-  {
-    if (get<0>(aTuple).first)
-      theWaitFor = theClient->context_get(get<0>(aTuple).second);
-    else
-      theWaitFor = theClient->context_get();
-  }
-  
-  template<>
-  void CommandLineHandler::handle<Eval>(tuple<bstring>& aTuple)
-  {
-    theWaitFor = theClient->eval(get<0>(aTuple).second);
-  }
-  
-  void CommandLineHandler::addCommands()
-  {
-    theCommandLine << createCommand<Status>(tuple<>(), "status", *this,
-                                            "Gets the status of the server");
-    theCommandLine << createCommand<Quit>(tuple<>(), "quit", *this,
-                                          "Stops debugging and quits the client");
-    theCommandLine << createCommand<Run>(tuple<>(), "run", *this, "Run the Query");
-    {
-      Command<CommandLineHandler, tuple<bstring, bstring, bint>, BreakpointSet>* lCommand =
-      createCommand<BreakpointSet>(tuple<bstring, bstring, bint>(), "break", *this, "Set a breakpoint");
-      (*lCommand)(0, "s", createArgType<tuple<bstring, bstring, bint>, std::string, 0>(tuple<bstring, bstring, bint>()),
-                  "breakpoint state (enabled or disabled - default: enabled)", false);
-      (*lCommand)(1, "f", createArgType<tuple<bstring, bstring, bint>, std::string, 1>(tuple<bstring, bstring, bint>()),
-                  "The name of the file where to stop", true);
-      (*lCommand)(2, "l", createArgType<tuple<bstring, bstring, bint>, int, 2>(tuple<bstring, bstring, bint>()),
-                  "The line number", true);
-      
-      theCommandLine << lCommand;
-    }
-    {
-      Command<CommandLineHandler, tuple<bint>, BreakpointGet>* lCommand
-      = createCommand<BreakpointGet>(tuple<bint>(), "binfo", *this, 
-                                   "Get information about a given breakpoint");
-      (*lCommand)(0, "i", createArgType<tuple<bint>, int, 0>(tuple<bint>()),
-                  "The id of the breakpoint", true);
-      
-      theCommandLine << lCommand;
-    }
-    {
-      Command<CommandLineHandler, tuple<bint>, BreakpointDel>* lCommand
-      = createCommand<BreakpointDel>(tuple<bint>(), "bdel", *this, "Delete a breakpoint with a given id");
-      (*lCommand)(0, "i", createArgType<tuple<bint>, int, 0>(tuple<bint>()), "The id of the breakpoint", true);
-      
-      theCommandLine << lCommand;
-    }
-    theCommandLine << createCommand<BreakpointList>(tuple<>(), "blist", *this, "List all set breakpoints");
-    theCommandLine << createCommand<StackDepth>(tuple<>(), "sdepth", *this, "Get the depth of the stack");
-    {
-      Command<CommandLineHandler, tuple<bint>, StackGet>* lCommand
-      = createCommand<StackGet>(tuple<bint>(), "sget", *this, "Get information about one or all stack frames");
-      (*lCommand)(0, "d", createArgType<tuple<bint>, int, 0>(tuple<bint>()), "The stack entry two show (show all if not provided)", false);
-      theCommandLine << lCommand;
-    }
-    theCommandLine << createCommand<ContextNames>(tuple<>(), "cnames", *this, "Get the names of the avilable contexts");
-    {
-      Command<CommandLineHandler, tuple<bint>, ContextGet>* lCommand
-      = createCommand<ContextGet>(tuple<bint>(), "cget", *this, "Get a context");
-      
-      (*lCommand)(0, "c", createArgType<tuple<bint>, int, 0>(tuple<bint>()), "The id of the context", false);
-      
-      theCommandLine << lCommand;
-    }
-    {
-      Command<CommandLineHandler, tuple<bstring>, Eval>* lCommand
-      = createCommand<Eval>(tuple<bstring>(), "eval", *this, "Evaluate a function");
-      
-      (*lCommand)(0, "c", createArgType<tuple<bstring>, std::string, 0>(tuple<bstring>()), "The command to evaluate", true);
-      
-      theCommandLine << lCommand;
-    }
-  }
-  
-}} // namespace zorba::debugclient
-
+  }
+  theWaitFor = theClient->stop(true);
+  theClient->quit();
+  theQuit = true;
+}
+
+template<>
+void
+CommandLineHandler::handle<Run>(ZORBA_TR1_NS::tuple<> &t)
+{
+  theTerminated = false;
+  theWaitFor = theClient->run();
+}
+
+template<>
+void
+CommandLineHandler::handle<Stop>(ZORBA_TR1_NS::tuple<> &t)
+{
+  theWaitFor = theClient->stop(false);
+}
+
+template<>
+void
+CommandLineHandler::handle<BreakpointSet>(std::tr1::tuple<bstring, bstring, bint> &aTuple)
+{
+  DebuggerClient::BreakpointType lType = DebuggerClient::Line;
+  bool lEnabled = true;
+  if (get<0>(aTuple).first) {
+    if (get<0>(aTuple).second == "disabled") {
+      lEnabled = false;
+    }
+  }
+  theWaitFor = theClient->breakpoint_set(lType,
+                                          lEnabled,
+                                          get<1>(aTuple).second,
+                                          get<2>(aTuple).second);
+}
+  
+template<>
+void
+CommandLineHandler::handle<BreakpointGet>(tuple<bint> &aTuple)
+{
+  theWaitFor = theClient->breakpoint_get(get<0>(aTuple).second);
+}
+  
+template<>
+void
+CommandLineHandler::handle<BreakpointRemove>(tuple<bint> &aTuple)
+{
+  theWaitFor = theClient->breakpoint_remove(get<0>(aTuple).second);
+}
+  
+template<>
+void
+CommandLineHandler::handle<BreakpointList>(tuple<> &aTuple)
+{
+  theWaitFor = theClient->breakpoint_list();
+}
+  
+template<>
+void
+CommandLineHandler::handle<StackDepth>(tuple<> &aTuple)
+{
+  theWaitFor = theClient->stack_depth();
+}
+  
+template<>
+void
+CommandLineHandler::handle<StackGet>(tuple<bint> &aTuple)
+{
+  if (get<0>(aTuple).first) {
+    theWaitFor = theClient->stack_get(get<0>(aTuple).second);
+  } else {
+    theWaitFor = theClient->stack_get();
+  }
+}
+  
+template<>
+void
+CommandLineHandler::handle<ContextNames>(tuple<>& aTuple)
+{
+  theWaitFor = theClient->context_names();
+}
+  
+template<>
+void CommandLineHandler::handle<ContextGet>(tuple<bint, bint> &aTuple)
+{
+  int lDepth = -1;
+  int lContext = -1;
+
+  if (get<0>(aTuple).first) {
+    lDepth = get<0>(aTuple).second;
+  }
+  if (get<1>(aTuple).first) {
+    lContext  = get<1>(aTuple).second;
+  }
+  theWaitFor = theClient->context_get(lDepth, lContext);
+}
+
+template<>
+void CommandLineHandler::handle<Source>(tuple<bint, bint, bstring> &aTuple)
+{
+  theWaitFor = theClient->source(
+    get<2>(aTuple).second,
+    get<0>(aTuple).second,
+    get<1>(aTuple).second);
+}
+  
+template<>
+void CommandLineHandler::handle<Eval>(tuple<bstring>& aTuple)
+{
+  theWaitFor = theClient->eval(get<0>(aTuple).second);
+}
+
+template<>
+void
+CommandLineHandler::handle<StepIn>(ZORBA_TR1_NS::tuple<> &t)
+{
+  theTerminated = false;
+  theWaitFor = theClient->step_into();
+}
+
+template<>
+void
+CommandLineHandler::handle<StepOut>(ZORBA_TR1_NS::tuple<> &t)
+{
+  theWaitFor = theClient->step_out();
+}
+
+template<>
+void
+CommandLineHandler::handle<StepOver>(ZORBA_TR1_NS::tuple<> &t)
+{
+  theTerminated = false;
+  theWaitFor = theClient->step_over();
+}
+
+void
+CommandLineHandler::addCommands()
+{
+  typedef tuple<> TUPLE;
+  typedef tuple<bint> TUPLE_INT;
+  typedef tuple<bstring> TUPLE_STR;
+  typedef tuple<bint, bint> TUPLE_INT_INT;
+  typedef tuple<bstring, bstring, bint> TUPLE_STR_STR_INT;
+  typedef tuple<bint, bint, bstring> TUPLE_INT_INT_STR;
+
+  // DBGP: status
+  *theCommandLine << createCommand<Status>(TUPLE(), "status", *this, "Gets the status of the server");
+
+  // ALIAS: variables (context_get -c -1)
+  {
+    std::set<std::string> lAliases;
+    lAliases.insert("vars");
+    *theCommandLine << createCommand<Variables>(TUPLE(), "variables", lAliases, *this, "Gets the variables visible in the current scope");
+  }
+
+  // META: quit
+  *theCommandLine << createCommand<Quit>(TUPLE(), "quit", *this, "Stops debugging and quits the client");
+
+  // DBGP: run
+  *theCommandLine << createCommand<Run>(TUPLE(), "run", *this, "Run the query");
+
+  // DBGP: stop
+  *theCommandLine << createCommand<Stop>(TUPLE(), "stop", *this, "Stop the query");
+
+  // DBGP: breakpoint_set
+  {
+    std::set<std::string> lAliases;
+    lAliases.insert("break");
+    Command<CommandLineHandler, TUPLE_STR_STR_INT, BreakpointSet>* lCommand =
+      createCommand<BreakpointSet>(TUPLE_STR_STR_INT(), "bset", lAliases, *this, "Set a breakpoint");
+
+    lCommand->addArgument(0, "s", createArgType<TUPLE_STR_STR_INT, std::string, 0>(TUPLE_STR_STR_INT()), "breakpoint state (optional, 'enabled' or 'disabled', default: enabled)", false);
+    lCommand->addArgument(1, "f", createArgType<TUPLE_STR_STR_INT, std::string, 1>(TUPLE_STR_STR_INT()), "name of the file where to stop", true);
+    lCommand->addArgument(2, "l", createArgType<TUPLE_STR_STR_INT, int, 2>(TUPLE_STR_STR_INT()), "line number", true);
+      
+    *theCommandLine << lCommand;
+  }
+
+  // DBGP: breakpoint_get
+  {
+    Command<CommandLineHandler, TUPLE_INT, BreakpointGet>* lCommand =
+      createCommand<BreakpointGet>(TUPLE_INT(), "bget", *this, "Get information about a given breakpoint");
+
+    lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "breakpoint ID", true);
+      
+    *theCommandLine << lCommand;
+  }
+
+  // DBGP: breakpoint_remove
+  {
+    std::set<std::string> lAliases;
+    lAliases.insert("clear");
+    lAliases.insert("delete");
+    Command<CommandLineHandler, TUPLE_INT, BreakpointRemove>* lCommand = 
+      createCommand<BreakpointRemove>(TUPLE_INT(), "bremove", lAliases, *this, "Delete a breakpoint");
+
+    lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "breakpoint ID", true);
+      
+    *theCommandLine << lCommand;
+  }
+
+  // DBGP: breakpoint_list
+  *theCommandLine << createCommand<BreakpointList>(TUPLE(), "blist", *this, "List all set breakpoints");
+
+  // DBGP: stack_depth
+  *theCommandLine << createCommand<StackDepth>(TUPLE(), "sdepth", *this, "Get the depth of the stack");
+
+  // DBGP: stack_get
+  {
+    Command<CommandLineHandler, TUPLE_INT, StackGet>* lCommand =
+      createCommand<StackGet>(TUPLE_INT(), "sget", *this, "Get information about one or all stack frames");
+
+    lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "stack frame to show: 0 for current stack frame, N for the main module (optional, all frames are shown if not provided)", false);
+
+    *theCommandLine << lCommand;
+  }
+
+  // DBGP: context_names
+  *theCommandLine << createCommand<ContextNames>(tuple<>(), "cnames", *this, "Get the names of the avilable contexts");
+  // the DBGP -d arguments for this command is omitted since we always have/return: 0 - Local, 1 - Global
+
+  // DBGP: context_get
+  {
+    Command<CommandLineHandler, TUPLE_INT_INT, ContextGet>* lCommand =
+      createCommand<ContextGet>(TUPLE_INT_INT(), "cget", *this, "Get a context (list variables in this context)");
+
+    lCommand->addArgument(0, "d", createArgType<TUPLE_INT_INT, int, 0>(TUPLE_INT_INT()), "stack depth (optional, default: 0)", false);
+    lCommand->addArgument(0, "c", createArgType<TUPLE_INT_INT, int, 1>(TUPLE_INT_INT()), "context ID: 0 for Local, 1 for Global (optional, default: 0)", false);
+
+    *theCommandLine << lCommand;
+  }
+
+  // DBGP: source
+  {
+    std::set<std::string> lAliases;
+    lAliases.insert("list");
+    Command<CommandLineHandler, TUPLE_INT_INT_STR, Source>* lCommand =
+      createCommand<Source>(TUPLE_INT_INT_STR(), "source", lAliases, *this, "List source code");
+
+    lCommand->addArgument(0, "b", createArgType<TUPLE_INT_INT_STR, int, 0>(TUPLE_INT_INT_STR()), "begin line (optional, default: first line)", false);
+    lCommand->addArgument(1, "e", createArgType<TUPLE_INT_INT_STR, int, 1>(TUPLE_INT_INT_STR()), "end line (optional, default: last line)", false);
+    lCommand->addArgument(2, "f", createArgType<TUPLE_INT_INT_STR, std::string, 2>(TUPLE_INT_INT_STR()), "file URI (optional, default: the file in the top-most stack frame during execution, main module otherwise)", false);
+
+    *theCommandLine << lCommand;
+  }
+
+  // DBGP: eval
+  {
+    std::set<std::string> lAliases;
+    lAliases.insert("print");
+    Command<CommandLineHandler, TUPLE_STR, Eval>* lCommand =
+      createCommand<Eval>(TUPLE_STR(), "eval", lAliases, *this, "Evaluate an expression");
+
+    // TODO: this argument should not be here at all. Eval has the form: eval -i transaction_id -- {DATA}
+    // Eval should be called with a command like: eval 1 + 3
+    // - no need for an argument name
+    // - everything following the fist contiguous set of whitespaces are sent as string
+    lCommand->addArgument(0, "c", createArgType<TUPLE_STR, std::string, 0>(TUPLE_STR()), "expression to evaluate", true);
+      
+    *theCommandLine << lCommand;
+  }
+
+  // DBGP: step_in
+  {
+    std::set<std::string> lAliases;
+    lAliases.insert("step");
+    lAliases.insert("s");
+    *theCommandLine << createCommand<StepIn>(TUPLE(), "in", lAliases, *this, "Step in");
+  }
+
+  // DBGP: step_out
+  {
+    std::set<std::string> lAliases;
+    lAliases.insert("finish");
+    *theCommandLine << createCommand<StepOut>(TUPLE(), "out", lAliases, *this, "Step out");
+  }
+
+  // DBGP: step_over
+  {
+    std::set<std::string> lAliases;
+    lAliases.insert("next");
+    lAliases.insert("n");
+    *theCommandLine << createCommand<StepOver>(TUPLE(), "over", lAliases, *this, "Step over");
+  }
+}
+  
+} // namespace zorba
+} // namespace debugger

=== modified file 'bin/debugger/command_line_handler.h'
--- bin/debug_client/command_line_handler.h	2011-07-01 01:53:24 +0000
+++ bin/debugger/command_line_handler.h	2012-09-27 18:04:43 +0000
@@ -14,46 +14,71 @@
  * limitations under the License.
  */
 #pragma once
+#ifndef ZORBA_DEBUGGER_COMMAND_LINE_HANDLER_H
+#define ZORBA_DEBUGGER_COMMAND_LINE_HANDLER_H
 
 #include <set>
 #include <cassert>
+
 #include <zorba/debugger_client.h>
-#include "debug_command.h"
+
+#include "command.h"
 #include "event_handler.h"
 
-namespace zorba { namespace debugclient {
-  
+
+namespace zorba { namespace debugger {
+
+  class CommandPrompt;
+
   enum Commands {
     Status,
+    Variables,
+    Quit,
     Run,
+    Stop,
     BreakpointSet,
     BreakpointGet,
-    BreakpointDel,
+    BreakpointRemove,
     BreakpointList,
     StackDepth,
     StackGet,
     ContextNames,
     ContextGet,
+    Source,
     Eval,
-    Quit
+    StepIn,
+    StepOut,
+    StepOver
   };
   
-  class CommandLineHandler {
+class CommandLineHandler
+{
   private:
+
     typedef std::pair<bool, std::string> bstring;
     typedef std::pair<bool, int> bint;
+
   public:
-    CommandLineHandler(unsigned short port,
-                       LockFreeConsumer<std::size_t>& aConsumer,
-                       LockFreeConsumer<bool>& aContinueQueue,
-                       EventHandler& aHandler,
-                       CommandLine& aCommandLine);
+
+    CommandLineHandler(
+      unsigned short port,
+      LockFreeConsumer<std::size_t>& aConsumer,
+      LockFreeConsumer<bool>& aContinueQueue,
+      EventHandler* aHandler,
+      CommandPrompt* aCommandPrompt);
+
     ~CommandLineHandler();
+
   public:
     void execute();
+  
   public: // Handlers
+
     template<int>
-    void handle(ZORBA_TR1_NS::tuple<>& aTuple) { assert(false); }
+    void handle(ZORBA_TR1_NS::tuple<>& aTuple)
+    {
+      assert(false);
+    }
     
     template<int>
     void handle(ZORBA_TR1_NS::tuple<bstring, bstring, bint>& t)
@@ -62,63 +87,96 @@
     }
     
     template<int>
+    void handle(ZORBA_TR1_NS::tuple<bint, bint, bstring>& t)
+    {
+      assert(false);
+    }
+    
+    template<int>
     void handle(ZORBA_TR1_NS::tuple<bint>& aTuple)
     {
       assert(false);
     }
     
     template<int>
+    void handle(ZORBA_TR1_NS::tuple<bint, bint>& aTuple)
+    {
+      assert(false);
+    }
+    
+    template<int>
     void handle(ZORBA_TR1_NS::tuple<bstring>& aTuple)
     {
       assert(false);
     }
+
   private:
-    LockFreeConsumer<std::size_t>& theConsumer;
-    LockFreeConsumer<bool>& theContinueQueue;
-    DebuggerClient* theClient;
-    CommandLine& theCommandLine;
-    bool theQuit;
-    bool theContinue;
-    std::size_t theWaitFor;
+    LockFreeConsumer<std::size_t>&  theConsumer;
+    LockFreeConsumer<bool>&         theContinueQueue;
+    DebuggerClient*                 theClient;
+    CommandPrompt*                  theCommandLine;
+    bool                            theQuit;
+    bool                            theTerminated;
+    bool                            theContinue;
+    std::size_t                     theWaitFor;
+
   private:
     void getNextId(std::set<std::size_t>& aIdList);
     void addCommands();
-  };
-  
-  template<>
-  void CommandLineHandler::handle<Status> (ZORBA_TR1_NS::tuple<>& t);
-  
-  template<>
-  void CommandLineHandler::handle<Quit> (ZORBA_TR1_NS::tuple<>& t);
-  
-  template<>
-  void CommandLineHandler::handle<Run> (ZORBA_TR1_NS::tuple<> &t);
-  
-  template<>
-  void CommandLineHandler::handle<StackDepth> (ZORBA_TR1_NS::tuple<>& t);
-  
-  template<>
-  void CommandLineHandler::handle<BreakpointList> (ZORBA_TR1_NS::tuple<>& aTuple);
-  
-  template<>
-  void CommandLineHandler::handle<BreakpointSet> (ZORBA_TR1_NS::tuple<bstring, bstring, bint> &t);
-  
-  template<>
-  void CommandLineHandler::handle<BreakpointGet> (ZORBA_TR1_NS::tuple<bint>& aTuple);
-  
-  template<>
-  void CommandLineHandler::handle<BreakpointDel>(ZORBA_TR1_NS::tuple<bint> &aTuple);
-  
-  template<>
-  void CommandLineHandler::handle<StackGet> (ZORBA_TR1_NS::tuple<bint>& aTuple);
-  
-  template<>
-  void CommandLineHandler::handle<ContextNames>(ZORBA_TR1_NS::tuple<> &aTuple);
-  
-  template<>
-  void CommandLineHandler::handle<ContextGet>(ZORBA_TR1_NS::tuple<bint> &aTuple);
-  
-  template<>
-  void CommandLineHandler::handle<Eval>(ZORBA_TR1_NS::tuple<bstring>& aTuple);
-  
-}} // close namespaces zorba::debugclient
+};
+
+template<>
+void CommandLineHandler::handle<Status> (ZORBA_TR1_NS::tuple<>& t);
+
+template<>
+void CommandLineHandler::handle<Quit> (ZORBA_TR1_NS::tuple<>& t);
+
+template<>
+void CommandLineHandler::handle<Run> (ZORBA_TR1_NS::tuple<> &t);
+
+template<>
+void CommandLineHandler::handle<Stop> (ZORBA_TR1_NS::tuple<> &t);
+
+template<>
+void CommandLineHandler::handle<StackDepth> (ZORBA_TR1_NS::tuple<>& t);
+
+template<>
+void CommandLineHandler::handle<BreakpointList> (ZORBA_TR1_NS::tuple<>& aTuple);
+  
+template<>
+void CommandLineHandler::handle<BreakpointSet> (ZORBA_TR1_NS::tuple<bstring, bstring, bint> &t);
+  
+template<>
+void CommandLineHandler::handle<BreakpointGet> (ZORBA_TR1_NS::tuple<bint>& aTuple);
+  
+template<>
+void CommandLineHandler::handle<BreakpointRemove>(ZORBA_TR1_NS::tuple<bint> &aTuple);
+  
+template<>
+void CommandLineHandler::handle<StackGet> (ZORBA_TR1_NS::tuple<bint>& aTuple);
+  
+template<>
+void CommandLineHandler::handle<ContextNames>(ZORBA_TR1_NS::tuple<> &aTuple);
+  
+template<>
+void CommandLineHandler::handle<ContextGet>(ZORBA_TR1_NS::tuple<bint, bint> &aTuple);
+  
+template<>
+void CommandLineHandler::handle<Source>(ZORBA_TR1_NS::tuple<bint, bint, bstring> &aTuple);
+  
+template<>
+void CommandLineHandler::handle<Eval>(ZORBA_TR1_NS::tuple<bstring>& aTuple);
+
+template<>
+void CommandLineHandler::handle<StepIn> (ZORBA_TR1_NS::tuple<> &t);
+
+template<>
+void CommandLineHandler::handle<StepOut> (ZORBA_TR1_NS::tuple<> &t);
+
+template<>
+void CommandLineHandler::handle<StepOver> (ZORBA_TR1_NS::tuple<> &t);
+
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_COMMAND_LINE_HANDLER_H

=== added file 'bin/debugger/command_prompt.cpp'
--- bin/debugger/command_prompt.cpp	1970-01-01 00:00:00 +0000
+++ bin/debugger/command_prompt.cpp	2012-09-27 18:04:43 +0000
@@ -0,0 +1,286 @@
+/*
+ * 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 "command_prompt.h"
+
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+
+#include "command.h"
+
+
+namespace zorba { namespace debugger {
+
+#ifdef ZORBA_HAVE_LIBEDIT_H
+const char*
+prompt(EditLine* aEl) {
+  return "(xqdb) ";
+}
+#endif
+
+CommandPrompt::CommandPrompt()
+{
+#ifdef ZORBA_HAVE_LIBEDIT_H
+  theEditLine = el_init("xqdb", stdin, stdout, stderr);
+  theHistory = history_init();
+  HistEvent lHistoryEvent;
+  history(theHistory, &lHistoryEvent, H_SETSIZE, 100);
+
+  el_set(theEditLine, EL_PROMPT, prompt);
+
+  el_set(theEditLine, EL_HIST, history, theHistory);
+  el_set(theEditLine, EL_EDITOR, "emacs");
+#endif
+}
+
+CommandPrompt::~CommandPrompt()
+{
+#ifdef ZORBA_HAVE_LIBEDIT_H
+  history_end(theHistory);
+  el_end(theEditLine);
+#endif
+
+  std::map<std::string, UntypedCommand*>::iterator lIter;
+  for (lIter = theCommands.begin(); lIter != theCommands.end(); ++lIter) {
+    delete lIter->second;
+  }
+}
+
+void
+CommandPrompt::printHelp(UntypedCommand* aCommand)
+{
+  // if no command is provided, print all the available commands
+  if (!aCommand) {
+    std::cout << "Available commands:" << std::endl;
+
+    // print the names of all commands
+    std::map<std::string, UntypedCommand*>::iterator lIter = theCommands.begin();
+    while (lIter != theCommands.end()) {
+      std::cout << "  " << (*lIter).first;
+      std::set<std::string> lAliases = (*lIter).second->getAliases();
+      std::set<std::string>::const_iterator lAliasIter = lAliases.begin();
+      while (lAliasIter != lAliases.end()) {
+        std::cout << ", " << *lAliasIter;
+        lAliasIter++;
+      }
+      std::cout << std::endl;
+      lIter++;
+    }
+
+    // some hints for detailed help
+    std::cout << std::endl;
+    std::cout << "Type help <command> to get more information about one command." << std::endl;
+    std::cout << std::endl;
+  } else {
+    // ok, so we have a command; then print the help
+    aCommand->printHelp();
+  }
+}
+
+void
+CommandPrompt::execute()
+{
+  for (;;) {
+#ifdef ZORBA_HAVE_LIBEDIT_H
+    const char* lBuf;
+    int lCharsRead = -1;
+    lBuf = el_gets(theEditLine, &lCharsRead);
+    std::string lCommandLine(lBuf, lCharsRead - 1);
+#else
+    bool lWithOutput = true;
+    if (lWithOutput) {
+      std::cout << "(xqdb) ";
+    }
+    lWithOutput = true;
+    std::string lCommandLine;
+    std::getline(std::cin, lCommandLine);
+    if (std::cin.fail()) {
+      lWithOutput = false;
+      std::cin.clear();
+      continue;
+    }
+#endif
+    
+    std::vector<std::string> lArgs;
+
+    // split the command into arguments
+    parseLine(lCommandLine, lArgs);
+    std::string::size_type lSize = lArgs.size();
+
+    // empty command? do nothing!
+    if (lSize == 0) {
+      lArgs = theLastArgs;
+      if (lArgs.size() == 0) {
+        continue;
+      }
+    }
+#ifdef ZORBA_HAVE_LIBEDIT_H
+    else {
+      HistEvent lHistoryEvent;
+      history(theHistory, &lHistoryEvent, H_ENTER, lCommandLine.c_str());
+    }
+#endif
+    theLastArgs = lArgs;
+
+    UntypedCommand* lCommand = NULL;
+
+    // help is not a command but a hook here
+    if (lArgs.at(0) == "h" || lArgs.at(0) == "help") {
+      std::string lCmd = "";
+
+      // if the user needs the help for a specific command
+      if (lSize > 1) {
+        // do nothing if we don't have a command starting with this prefix?
+        // findCommand will print the appropriate errors
+        if (!findCommand(lArgs[1], lCommand)) {
+          continue;
+        }
+      }
+      printHelp(lCommand);
+      continue;
+    }
+    if (findCommand(lArgs[0], lCommand) && lCommand->execute(lArgs)) {
+      return;
+    }
+    continue;
+  }
+}
+  
+CommandPrompt&
+CommandPrompt::operator<<(UntypedCommand *aCommand)
+{
+  theCommands.insert(std::make_pair(aCommand->getName(), aCommand));
+  return *this;
+}
+
+bool
+CommandPrompt::findCommand(const std::string& aPrefix, UntypedCommand*& aCommand)
+{
+  std::vector<UntypedCommand*> lFoundCommands;
+
+  std::map<std::string, UntypedCommand*>::iterator lIter = theCommands.begin();
+  while (lIter != theCommands.end()) {
+    // if a command name is equal with the prefix, this is the command we want
+    if ((*lIter).first == aPrefix) {
+      aCommand = (*lIter).second;
+      return true;
+    }
+
+    bool lIsCandidate = false;
+
+    // add this command to candidate commands if the prefix matches
+    if ((*lIter).first.find(aPrefix) == 0) {
+      lFoundCommands.push_back((*lIter).second);
+      lIsCandidate = true;
+    }
+
+    // now process the aliases
+    std::set<std::string> lAliases = (*lIter).second->getAliases();
+    std::set<std::string>::const_iterator lAliasIter = lAliases.begin();
+    while (lAliasIter != lAliases.end()) {
+      // if a command alias is equal with the prefix, this is the command we want
+      if (*lAliasIter == aPrefix) {
+        aCommand = (*lIter).second;
+        return true;
+      }
+
+      // add this command to candidate commands if the prefix matches one alias
+      // and if the command is not already added 
+      if (!lIsCandidate && (*lAliasIter).find(aPrefix) == 0) {
+        lFoundCommands.push_back((*lIter).second);
+        break;
+      }
+      lAliasIter++;
+    }
+
+    lIter++;
+  }
+
+  if (lFoundCommands.empty()) {
+    std::cout << "Command not found: " << aPrefix << std::endl;
+    return false;
+  }
+
+  if (lFoundCommands.size() > 1) {
+    std::cout << "Ambigous command: " << aPrefix << std::endl;
+    // show all possible commands that start with this prefix
+    for (std::string::size_type i = 0; i < lFoundCommands.size(); i++) {
+      UntypedCommand* lCommand = lFoundCommands.at(i);
+
+      // commands
+      if (lCommand->getName().find(aPrefix) == 0) {
+        std::cout << "  " << lCommand->getName() << std::endl;
+      }
+
+      // and aliases
+      std::set<std::string> lAliases = lCommand->getAliases();
+      std::set<std::string>::const_iterator lAliasIter = lAliases.begin();
+      while (lAliasIter != lAliases.end()) {
+        if ((*lAliasIter).find(aPrefix) == 0) {
+          std::cout << "  " << *lAliasIter << std::endl;
+        }
+        lAliasIter++;
+      }
+    }
+    return false;
+  }
+
+  aCommand = lFoundCommands[0];
+  return true;
+}
+
+void
+CommandPrompt::parseLine(const std::string& aLine, std::vector<std::string>& aVector)
+{
+  std::string::size_type lBefore = 0;
+  std::string::size_type lPos = aLine.find_first_of(" \t", 0);
+
+  while (lPos != aLine.npos) {
+    std::string lSub = aLine.substr(lBefore, lPos - lBefore);
+
+    // if two consecutive spaces, you get an empty string here
+    if (lSub != "") {
+      if (lSub[0] == '"') {
+        std::string::size_type lBeforeCopy = lBefore;
+        do {
+          lBeforeCopy = aLine.find("\"", lBeforeCopy + 1);
+        } while (lPos != aLine.npos && aLine.size() > lPos + 1 && aLine[lPos + 1] == '\\');
+        lPos = lBeforeCopy;
+        lSub = aLine.substr(lBefore + 1, lPos - lBefore - 1);
+      }
+      aVector.push_back(lSub);
+    }
+
+    lBefore = lPos + 1;
+    lPos = aLine.find_first_of(" \t", lBefore);
+  }
+  std::string lSub = aLine.substr(lBefore);
+
+  // catching the case when the command ends with a space
+  if (lSub == "") {
+    return;
+  }
+
+  if (lSub[0] == '"') {
+    lPos = aLine.find("\"", lBefore + 1);
+    lSub = aLine.substr(lBefore + 1, lPos - lBefore - 1);
+  }
+  aVector.push_back(lSub);
+}
+  
+} // namespace zorba
+} // namespace debugger

=== added file 'bin/debugger/command_prompt.h'
--- bin/debugger/command_prompt.h	1970-01-01 00:00:00 +0000
+++ bin/debugger/command_prompt.h	2012-09-27 18:04:43 +0000
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+#pragma once
+#ifndef ZORBA_DEBUGGER_COMMAND_PROMPT_H
+#define ZORBA_DEBUGGER_COMMAND_PROMPT_H
+
+#include <string>
+#include <map>
+#include <vector>
+
+#include "config.h"
+
+#ifdef ZORBA_HAVE_LIBEDIT_H
+# include <histedit.h>
+#endif
+
+
+namespace zorba { namespace debugger {
+
+class UntypedCommand;
+
+class CommandPrompt
+{
+  public:
+    CommandPrompt();
+    ~CommandPrompt();
+
+  public:
+
+    void execute();
+
+    CommandPrompt& operator<< (UntypedCommand* command);
+
+  private:
+
+    void
+    printHelp(UntypedCommand* command);
+
+    bool
+    findCommand(const std::string& prefix, UntypedCommand*& command);
+
+    void
+    parseLine(const std::string& line, std::vector<std::string>& vector);
+
+  private:
+    std::map<std::string, UntypedCommand*>  theCommands;
+    std::vector<std::string>                theLastArgs;
+
+#ifdef ZORBA_HAVE_LIBEDIT_H
+    EditLine*                               theEditLine;
+    History*                                theHistory;
+#endif
+};  
+
+  
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_COMMAND_PROMPT_H

=== added file 'bin/debugger/config.h.cmake'
--- bin/debugger/config.h.cmake	1970-01-01 00:00:00 +0000
+++ bin/debugger/config.h.cmake	2012-09-27 18:04:43 +0000
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+// This header is configured by Zorba's build process -- DO NOT EDIT!
+
+#ifndef ZORBA_DEBUGGER_CONFIG_H
+#define ZORBA_DEBUGGER_CONFIG_H
+
+#cmakedefine ZORBA_HAVE_LIBEDIT_H
+
+#endif /* ZORBA_DEBUGGER_CONFIG_H */

=== modified file 'bin/debugger/event_handler.cpp'
--- bin/debug_client/event_handler.cpp	2011-07-01 01:53:24 +0000
+++ bin/debugger/event_handler.cpp	2012-09-27 18:04:43 +0000
@@ -13,88 +13,93 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+#include "event_handler.h"
+
+#include <sstream>
+
 #include <zorba/zorba.h>
 #include <zorba/store_manager.h>
 #include <zorba/iterator.h>
-#include <sstream>
-#include "debug_client/event_handler.h"
 
-namespace zorba { namespace debugclient {
+namespace zorba { namespace debugger {
   
-  EventHandler::EventHandler(LockFreeProducer<std::size_t>& aQueue, LockFreeProducer<bool>& aContProducer)
+EventHandler::EventHandler(LockFreeProducer<std::size_t>& aQueue, LockFreeProducer<bool>& aContProducer)
   : theIdQueue(aQueue), theContinueProducer(aContProducer),
     theStore(StoreManager::getStore()),
     theZorbaInstance(Zorba::getInstance(theStore)),
     theStaticContext(theZorbaInstance->createStaticContext())
-    
-  {
-    try {
-      Zorba_CompilerHints_t lHints;
-      lHints.opt_level = ZORBA_OPT_LEVEL_O1;
-      std::auto_ptr<std::istream> stream(getCurrentDirectory());
-      zorba::String query;
-      char buffer[1024];
-      std::string::size_type s;
-      while ((s = stream->readsome(buffer, 1024))) {
-        query.append(std::string(buffer, s));
-      }
-      theStaticContext->loadProlog(query, lHints);
-    } catch (zorba::ZorbaException& e) {
-      std::cerr << "Exception: I was not able to load the query file:" << std::endl;
-      std::cerr << e.what() << std::endl;
-      throw;
-    }
-  }
-  
-  EventHandler::~EventHandler()
-  {
-    theStaticContext = 0;
-    theZorbaInstance->shutdown();
-    StoreManager::shutdownStore(theStore);
-  }
-  
-  void EventHandler::parseMessage(const std::string &aMessage)
-  {
-    try {
-      zorba::String queryString = "local:main(";
-      queryString += aMessage + ")";
-      XQuery_t query = theZorbaInstance->compileQuery(queryString, theStaticContext);
-      Iterator_t lIter = query->iterator();
-      Item item;
-      lIter->open();
-      bool doContinue = false;
-      lIter->next(item);
-      {
-        const std::string& continueString = item.getStringValue().str();
-        if (continueString == "true") {
-          doContinue = true;
-        } else if (continueString == "false") {
-          doContinue = false;
-        } else {
-          std::stringstream stream(continueString);
-          stream >> doContinue;
-        }
-      }
-      lIter->next(item);
-      std::size_t lId;
-      {
-        std::stringstream stream(item.getStringValue().c_str());
-        stream >> lId;
-      }
-      lIter->next(item);
-      std::cout << item.getStringValue() << std::endl;
-      theContinueProducer.produce(doContinue);
-      theIdQueue.produce(lId);
-    } catch (ZorbaException& e) {
-      std::cerr << "FATAL: could not execute query: " << std::endl;
-      std::cerr << e << std::endl;
-      std::cerr << "This is a bug, please report to zorba-users@xxxxxxxxxxxxxxxxxxxxx" << std::endl;
-      theContinueProducer.produce(false);
-    }
-  }
-  
-  void EventHandler::error(unsigned int errcode, const std::string &msg)
-  {
-    std::cerr << "Error " << errcode << ": " << msg << std::endl;
-  }
-}}
+{
+}
+
+EventHandler::~EventHandler()
+{
+  theStaticContext = 0;
+  theZorbaInstance->shutdown();
+  StoreManager::shutdownStore(theStore);
+}
+
+void
+EventHandler::init()
+{
+  try {
+    Zorba_CompilerHints_t lHints;
+    lHints.opt_level = ZORBA_OPT_LEVEL_O1;
+    zorba::String lProlog("import module namespace dmh = 'http://www.zorba-xquery.com/modules/debugger/dbgp-message-handler';");
+    theStaticContext->loadProlog(lProlog, lHints);
+  } catch (zorba::ZorbaException& e) {
+    std::cerr << "Exception: I was not able to load the query file:" << std::endl;
+    std::cerr << e.what() << std::endl;
+    throw;
+  }
+}
+
+void
+EventHandler::parseMessage(const std::string &aMessage)
+{
+  try {
+#ifndef NDEBUG
+    // uncomment this to see the raw messages received by the event handler
+    //std::cout << "Processing response: " << aMessage << std::endl;
+#endif
+    // the query to process the response
+    std::stringstream lQueryStream;
+    lQueryStream << "dmh:process(" << aMessage << ")";
+    XQuery_t lQuery = theZorbaInstance->compileQuery(lQueryStream.str(), theStaticContext);
+
+    // get the query result sequrence:
+    //   1. a message
+    Iterator_t lIter = lQuery->iterator();
+    Item lItem;
+    lIter->open();
+    lIter->next(lItem);
+    std::size_t lId;
+    std::stringstream lStream(lItem.getStringValue().c_str());
+    lStream >> lId;
+
+    //   2. an "idle" flag (to disable quit confirmation)
+    bool lCanQuit = false;
+    if (lIter->next(lItem)) {
+      String lMessage = lItem.getStringValue();
+      lCanQuit = lMessage == "idle";
+      std::cout << std::endl << lItem.getStringValue() << std::endl;
+    }
+    theContinueProducer.produce(lCanQuit);
+
+    // go and solve the event with this id
+    theIdQueue.produce(lId);
+  } catch (ZorbaException& e) {
+    std::cerr << "FATAL: could not execute query: " << std::endl;
+    std::cerr << e << std::endl;
+    std::cerr << "This is a bug, please report it at http://bugs.launchpad.net/zorba"; << std::endl;
+  }
+}
+  
+void
+EventHandler::error(unsigned int errcode, const std::string &msg)
+{
+  std::cerr << "Error " << errcode << ": " << msg << std::endl;
+}
+
+} // namespace zorba
+} // namespace debugger

=== modified file 'bin/debugger/event_handler.h'
--- bin/debug_client/event_handler.h	2011-07-01 01:53:24 +0000
+++ bin/debugger/event_handler.h	2012-09-27 18:04:43 +0000
@@ -14,33 +14,46 @@
  * limitations under the License.
  */
 #pragma once
+#ifndef ZORBA_DEBUGGER_EVENT_HANDLER_H
+#define ZORBA_DEBUGGER_EVENT_HANDLER_H
+
 #include <string>
 #include <iostream>
+
 #include <zorba/debugger_event_handler.h>
 #include <zorba/static_context.h>
+
 #include "lock_free_queue.h"
 
-namespace zorba {
-  class Zorba;
-}
-
-namespace zorba { namespace debugclient {
-  
-  class EventHandler : public zorba::DebuggerEventHandler
-  {
+
+namespace zorba { namespace debugger {
+
+class EventHandler : public zorba::DebuggerEventHandler
+{
   public:
-    EventHandler(LockFreeProducer<std::size_t>& aQueue, LockFreeProducer<bool>& aContQueue);
+    EventHandler(
+      LockFreeProducer<std::size_t>& aQueue,
+      LockFreeProducer<bool>& aContQueue);
+
     ~EventHandler();
+
   public:
     virtual void parseMessage(const std::string& aMessage);
+
     virtual void error(unsigned int errcode, const std::string& msg);
+
+    virtual void init();
+
   private:
-    static std::istream* getCurrentDirectory();
     LockFreeProducer<std::size_t>& theIdQueue;
     LockFreeProducer<bool>& theContinueProducer;
     void* theStore;
     Zorba* theZorbaInstance;
     StaticContext_t theStaticContext;
-  };
+
+};
   
-}} // end of namespace zorba::debugclient
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_EVENT_HANDLER_H

=== modified file 'bin/debugger/lock_free_queue.h'
--- bin/debug_client/lock_free_queue.h	2011-07-01 01:53:24 +0000
+++ bin/debugger/lock_free_queue.h	2012-09-27 18:04:43 +0000
@@ -14,10 +14,14 @@
  * limitations under the License.
  */
 #pragma once
+#ifndef ZORBA_DEBUGGER_LOCK_FREE_QUEUE_H
+#define ZORBA_DEBUGGER_LOCK_FREE_QUEUE_H
+
 #include <iostream>
 #include <list>
 
-namespace zorba { namespace debugclient {
+
+namespace zorba { namespace debugger {
 
 template<typename T>
 class LockFreeProducer
@@ -80,4 +84,8 @@
   }
   return false;
 }
-}} // namespace zorba::debugclient
+
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_LOCK_FREE_QUEUE_H

=== modified file 'bin/debugger/main.cpp'
--- bin/debug_client/main.cpp	2011-07-01 01:53:24 +0000
+++ bin/debugger/main.cpp	2012-09-27 18:04:43 +0000
@@ -13,12 +13,288 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+#ifdef WIN32
+# include <windows.h>
+# include <string.h>
+# include <strsafe.h>
+#else
+#include <unistd.h>
+#endif
+
+#include <vector>
+
 #include <zorba/config.h>
-#include "debug_command.h"
-#include "command_line_handler.h"
+
+#include "xqdb_client.h"
+#include "process_listener.h"
+
 
 using namespace zorba;
-using namespace zorba::debugclient;
+using namespace zorba::debugger;
+
+
+std::auto_ptr<XqdbClient> theClient;
+
+// this will make sure the xqdb process will not quit when Ctrl-C is pressed
+#ifdef WIN32
+BOOL WINAPI
+ctrlC_Handler(DWORD aCtrlType)
+{
+  if (CTRL_C_EVENT == aCtrlType) {
+    return true;
+  }
+  return false;
+}
+#else
+void
+ctrlC_Handler(int lParam)
+{
+  // an empty sugnal handler on Linux should do the job
+}
+#endif
+
+
+// this handler function is passed the the zorba process listener and will
+// the client if the zorba process terminates
+void
+onExitProcess(ExitCode aExitCode) {
+  std::cout << std::endl << "Terminating debugger client." << std::endl;
+
+#ifndef WIN32
+  XqdbClient* lClient = theClient.release();
+  if (lClient) {
+    delete lClient;
+  }
+#endif
+
+  exit(aExitCode);
+}
+
+
+int
+startZorba(std::string& aExec, std::vector<std::string>& aArgs, std::auto_ptr<ProcessListener>& aProcessListener) 
+{
+#ifdef WIN32
+  // **************************
+  // start a process on Windows
+
+  DWORD iReturnVal = 0;
+
+  std::wstring lExec;
+  std::wstring lArgs;
+
+  lExec.assign(aExec.begin(), aExec.end());
+
+  // the executable must be the first in the list of arguments
+  lArgs.append(L"\"");
+  lArgs.append(lExec);
+  lArgs.append(L"\"");
+
+  for (std::vector<std::string>::size_type j = 0; j < aArgs.size(); j++) {
+    std::string lArg(aArgs.at(j));
+    std::wstring lArgW;
+    lArgW.assign(lArg.begin(), lArg.end());
+    lArgs.append(L" ");
+    lArgs.append(lArgW);
+  }
+
+  // CreateProcessW can modify Parameters thus we allocate needed memory
+  wchar_t * pwszParam = new wchar_t[lArgs.size() + 1];
+  if (pwszParam == 0) {
+    return 1;
+  }
+  const wchar_t* pchrTemp = lArgs.c_str();
+  wcscpy_s(pwszParam, lArgs.size() + 1, pchrTemp); 
+
+  // CreateProcess API initialization
+  STARTUPINFOW siStartupInfo;
+  PROCESS_INFORMATION piProcessInfo;
+  memset(&siStartupInfo, 0, sizeof(siStartupInfo));
+  memset(&piProcessInfo, 0, sizeof(piProcessInfo));
+  siStartupInfo.cb = sizeof(siStartupInfo);
+
+  BOOL lResult = CreateProcessW(
+    const_cast<LPCWSTR>(lExec.c_str()),
+    pwszParam, 0, 0, false,
+    CREATE_DEFAULT_ERROR_MODE, 0, 0,
+    &siStartupInfo, &piProcessInfo);
+
+  if (lResult) {
+    // Watch the process
+    aProcessListener.reset(new ProcessListener(piProcessInfo.dwProcessId, &onExitProcess));
+  }
+  else {
+    // CreateProcess failed
+    iReturnVal = GetLastError();
+    LPVOID lpMsgBuf;
+    LPVOID lpDisplayBuf;
+
+    FormatMessage(
+      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+      NULL,
+      iReturnVal,
+      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+      (LPTSTR) &lpMsgBuf,
+      0, NULL);
+
+    // Display the error message and exit the process
+
+    lpDisplayBuf = (LPVOID)LocalAlloc(
+      LMEM_ZEROINIT,
+      (lstrlen((LPCTSTR)lpMsgBuf) + 40) * sizeof(TCHAR));
+
+    StringCchPrintf(
+      (LPTSTR)lpDisplayBuf,
+      LocalSize(lpDisplayBuf) / sizeof(TCHAR),
+      TEXT("Error (%d) when starting zorba: %s"),
+      iReturnVal,
+      lpMsgBuf);
+
+    std::wstring lErrorW((wchar_t*)lpDisplayBuf);
+    std::string lError;
+    lError.assign(lErrorW.begin(), lErrorW.end());
+    std::cout << lError << std::endl;
+
+    LocalFree(lpMsgBuf);
+    LocalFree(lpDisplayBuf);
+  }
+
+  // Free memory
+  delete[]pwszParam;
+  pwszParam = 0;
+
+  // Release handles
+  CloseHandle(piProcessInfo.hProcess);
+  CloseHandle(piProcessInfo.hThread);
+
+  return iReturnVal; 
+
+#else
+  // ************************
+  // start a process on Linux
+
+  pid_t pID = fork();
+  if (pID == 0) {
+    // Code only executed by child process
+    std::stringstream lCommand;
+    lCommand << aExec;
+    for (std::vector<std::string>::size_type j = 0; j < aArgs.size(); j++) {
+      lCommand << " " << aArgs.at(j);
+    }
+
+    int lRes = system(lCommand.str().c_str());
+    exit(lRes);
+  }
+  else {
+    // Code only executed by parent process
+    if (pID < 0) {
+      std::cerr << "Failed to fork Zorba" << std::endl;
+      return pID;
+    }
+    
+    // Watch the process
+    aProcessListener.reset(new ProcessListener(pID, &onExitProcess));
+
+    return 0;
+  }
+#endif
+}
+
+void printUsage(std::string& aProgram)
+{
+  std::cerr << "Usage:" << std::endl
+    << "    " << aProgram << " <zorba_arguments>" << std::endl
+    << "        this will start a debugger command line and a zorba process with the given arguments" << std::endl;
+}
+
+bool
+processArguments(
+  int argc,
+  char* argv[],
+  std::string& aProgram,
+  bool& aStandalone,
+  std::string& aZorba,
+  unsigned int& aPort,
+  std::vector<std::string>& aZorbaArgs)
+{
+  aPort = 28028;
+
+  // find the path to Zorba and this executable name
+  aProgram = argv[0];
+
+#ifdef WIN32
+  char lSep = '\\';
+#else
+  char lSep = '/';
+#endif
+  std::string::size_type lPos = aProgram.find_last_of(lSep);
+
+  std::stringstream lZs;
+
+  if (lPos == aProgram.npos) {
+    lZs << "." << lSep;
+  } else {
+    lZs << aProgram.substr(0, lPos + 1);
+    aProgram = aProgram.substr(lPos + 1);
+  }
+  lZs << "zorba";
+#ifdef WIN32
+  lZs << ".exe";
+#endif
+  aZorba = lZs.str();
+
+
+  bool lHasFileArg = false;
+  bool lHasQueryArg = false;
+  bool lHasQueryVal = false;
+
+  // find if the user asked for help or specified a specific port
+  for (int i = 1; i < argc; i++) {
+    std::string lArg = argv[i];
+    if (lArg == "-h" || lArg == "--help") {
+      return false;
+    }
+    else if (lArg == "-p" || lArg == "--debug-port") {
+      // if there is one more argument
+      if (i < argc - 1) {
+        // get the port value
+        int lPort;
+        std::stringstream lStream(argv[i + 1]);
+        lStream >> lPort;
+        if (!lStream.fail()) {
+          aPort = lPort;
+        }
+      }
+    }
+    else if (lArg == "-f") {
+      lHasFileArg = true;
+    }
+    else if (lArg == "-q") {
+      lHasQueryArg = true;
+      if (++i < argc) {
+        lHasQueryVal = true;
+      }
+    }
+  }
+
+  if (!lHasFileArg || !lHasQueryArg || !lHasQueryVal) {
+    std::cout << "Not enough arguments to start Zorba." << std::endl;
+    std::cout << "Running the standalone XQuery debugger client on port: " << aPort << std::endl;
+    return true;
+  }
+
+  // zorba will need the -d flag
+  aZorbaArgs.push_back("-d");
+
+  // gather all arguments (excepting the program name)
+  for (int i = 1; i < argc; i++) {
+    aZorbaArgs.push_back(argv[i]);
+  }
+
+  aStandalone = false;
+  return true;
+}
 
 #ifndef _WIN32_WCE
 int
@@ -28,24 +304,72 @@
 _tmain(int argc, _TCHAR* argv[])
 #endif
 {
-  int port = 28028;
-  if (argv[1]) {
-    std::stringstream stream(argv[1]);
-    stream >> port;
-    if (stream.fail() || argv[2]) {
-      std::cerr << "Unknown argument. USAGE: " << argv[0] << " [PORT]" << std::endl;
-      return 2;
+#ifdef WIN32
+  SetConsoleCtrlHandler(ctrlC_Handler, TRUE);
+#else
+  signal(SIGINT, ctrlC_Handler);
+#endif
+
+  // **************************************************************************
+  // processing arguments
+
+  std::string lProgram, lZorbaExec;
+  unsigned int lPort = 28028;
+  std::vector<std::string> lZorbaArgs;
+
+  bool lStandalone = true;
+  if (!processArguments(argc, argv, lProgram, lStandalone, lZorbaExec, lPort, lZorbaArgs)) {
+    printUsage(lProgram);
+    return 1;
+  }
+
+#ifndef NDEBUG
+  // **************************************************************************
+  // debug reporting
+
+  if (!lStandalone) {
+    std::cout << "Communication port: " << lPort << std::endl;
+    std::cout << "Zorba executable:   " << lZorbaExec << std::endl;
+    std::cout << "Zorba arguments:    ";
+    for (std::vector<std::string>::size_type j = 0; j < lZorbaArgs.size(); j++) {
+      std::cout << lZorbaArgs.at(j) << " ";
     }
+    std::cout << std::endl;
   }
+#endif
+
   try {
-    LockFreeQueue<std::size_t> lQueue;
-    LockFreeQueue<bool> lContEvent;
-    EventHandler lHandler(lQueue, lContEvent);
-    CommandLine cli;
-    CommandLineHandler handler(port, lQueue, lContEvent, lHandler, cli);
-    handler.execute();
+    // **************************************************************************
+    // start a zorba
+
+    // This is a process listener used to watch the Zorba process termination.
+    std::auto_ptr<ProcessListener> lProcessListener;
+
+    if (!lStandalone) {
+      int lResult = startZorba(lZorbaExec, lZorbaArgs, lProcessListener);
+      if (lResult) {
+        return lResult;
+      }
+    } else {
+      std::cout << "Listening for an incomming Zorba connection on port " << lPort << "..." << std::endl;
+    }
+
+    // **************************************************************************
+    // start the debugger command line
+
+    theClient.reset(new XqdbClient(lPort));
+    theClient->start();
+
   } catch (...) {
-    return 4;
-  }
+    return -1;
+  }
+
+#ifndef WIN32
+  XqdbClient* lClient = theClient.release();
+  if (lClient) {
+    delete lClient;
+  }
+#endif
+
   return 0;
 }

=== added file 'bin/debugger/process_listener.cpp'
--- bin/debugger/process_listener.cpp	1970-01-01 00:00:00 +0000
+++ bin/debugger/process_listener.cpp	2012-09-27 18:04:43 +0000
@@ -0,0 +1,109 @@
+/*
+ * 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 "process_listener.h"
+
+#include <iostream>
+
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
+#ifdef ZORBA_HAVE_PTHREAD_H
+# include <cassert>
+#endif
+
+
+namespace zorba { namespace debugger {
+  
+ProcessListener::ProcessListener(ProcessId aProcessID, ExitCallbackType aCallback)
+  : theProcessID(aProcessID), theCallback(aCallback)
+{
+#ifdef WIN32
+  theThread = CreateThread(NULL, 0, &run, (void*) this, 0, &theThreadId);
+#else
+  if (pthread_create(&theThread, NULL, &run, (void*) this)) {
+    assert(false);
+  }
+#endif
+}
+
+ProcessListener::~ProcessListener()
+{
+}
+
+ProcessId
+ProcessListener::getProcessID()
+{
+  return theProcessID;
+}
+
+ExitCallbackType
+ProcessListener::getCallback()
+{
+  return theCallback;
+}
+
+
+ZORBA_THREAD_RETURN
+ProcessListener::run(void* params)
+{
+  ProcessListener* lThis = static_cast<ProcessListener*>(params);
+  ExitCode lExitCode = -1;
+  ProcessId lPid = lThis->getProcessID();
+
+#ifdef WIN32
+  HANDLE lProcessHandle = OpenProcess(SYNCHRONIZE, false, lPid);
+  if (lProcessHandle != NULL) {
+    // wait for the process to exit
+    DWORD lResult = WaitForSingleObject(lProcessHandle, INFINITE);
+ 
+    // find out the process exit code if possible
+    if (!GetExitCodeProcess(lProcessHandle, &lExitCode)) {
+      lExitCode = -1;
+    }
+    DWORD dw = GetLastError();
+ 
+    // wait a little for zorba to dump the garbage
+    Sleep(1000);
+  }
+#else
+  int lChildExitStatus;
+
+  // wait for the process to exit
+  waitpid(lPid, &lChildExitStatus, 0);
+
+  // find out the process exit code if possible
+  if (WIFEXITED(lChildExitStatus)) {
+    lExitCode = WEXITSTATUS(lChildExitStatus);
+  }
+
+  // wait a little for zorba to dump the garbage
+  sleep(1);
+#endif
+
+  // and call the callback when this happened
+  ExitCallbackType lCallback = lThis->getCallback();
+  lCallback(lExitCode);
+
+  for (int i = 0; i < 10; i++) {
+    std::cout << i << std::endl;
+  }
+  return NULL;
+}
+
+} // namespace zorba
+} // namespace debugger

=== added file 'bin/debugger/process_listener.h'
--- bin/debugger/process_listener.h	1970-01-01 00:00:00 +0000
+++ bin/debugger/process_listener.h	2012-09-27 18:04:43 +0000
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+#pragma once
+#ifndef ZORBA_DEBUGGER_PROCESS_LISTENER_H
+#define ZORBA_DEBUGGER_PROCESS_LISTENER_H
+
+#include <zorba/config.h>
+
+#ifdef ZORBA_HAVE_PTHREAD_H
+# include <pthread.h>
+# include <sys/wait.h>
+  typedef pthread_t ThreadId;
+  typedef pid_t ProcessId;
+  typedef int ExitCode;
+# define ZORBA_THREAD_RETURN void *
+#else
+# include <windows.h>
+  typedef DWORD ThreadId;
+  typedef DWORD ProcessId;
+  typedef DWORD ExitCode;
+# define ZORBA_THREAD_RETURN DWORD WINAPI
+#endif
+
+typedef void (*ExitCallbackType)(ExitCode);
+
+
+namespace zorba { namespace debugger {
+
+class ProcessListener
+{
+  public:
+    ProcessListener(ProcessId processID, ExitCallbackType callback);
+
+    ~ProcessListener();
+
+    ProcessId
+    getProcessID();
+
+    ExitCallbackType
+    getCallback();
+
+  private:
+
+    static ZORBA_THREAD_RETURN run(void* params);
+
+  private:
+
+#ifdef ZORBA_HAVE_PTHREAD_H
+    pthread_t         theThread;
+#else
+    ThreadId          theThreadId;
+    HANDLE            theThread;
+#endif
+
+    ProcessId         theProcessID;
+    ExitCallbackType  theCallback;
+};
+  
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_PROCESS_LISTENER_H

=== modified file 'bin/debugger/tuple.h'
--- bin/debug_client/tuple.h	2011-07-04 08:05:46 +0000
+++ bin/debugger/tuple.h	2012-09-27 18:04:43 +0000
@@ -14,9 +14,15 @@
  * limitations under the License.
  */
 #pragma once
+#ifndef ZORBA_DEBUGGER_TUPLE_H
+#define ZORBA_DEBUGGER_TUPLE_H
+
 #include <zorba/config.h>
+
 #if ZORBA_TR1_IN_TR1_SUBDIRECTORY
 # include <tr1/tuple>
 #else
 # include <tuple>
 #endif
+
+#endif // ZORBA_DEBUGGER_TUPLE_H

=== added file 'bin/debugger/xqdb_client.cpp'
--- bin/debugger/xqdb_client.cpp	1970-01-01 00:00:00 +0000
+++ bin/debugger/xqdb_client.cpp	2012-09-27 18:04:43 +0000
@@ -0,0 +1,63 @@
+/*
+ * 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 "xqdb_client.h"
+
+#include <iostream>
+
+#ifdef ZORBA_HAVE_PTHREAD_H
+# include <cassert>
+#endif
+
+
+namespace zorba { namespace debugger {
+
+XqdbClient::XqdbClient(unsigned int aPort)
+{
+  theIdQueue = new LockFreeQueue<std::size_t>();
+  theQuitQueue = new LockFreeQueue<bool>();
+  theEventHandler = new EventHandler(*theIdQueue, *theQuitQueue);
+  theEventHandler->init();
+
+  theCommandPrompt = new CommandPrompt();
+  theCommandLineHandler = new CommandLineHandler(aPort, *theIdQueue, *theQuitQueue, theEventHandler, theCommandPrompt);
+}
+
+XqdbClient::~XqdbClient()
+{
+  if (theCommandLineHandler) {
+    delete theCommandLineHandler;
+  }
+  if (theCommandPrompt) {
+    delete theCommandPrompt;
+  }
+  if (theEventHandler) {
+    delete theEventHandler;
+  }
+
+  delete theIdQueue;
+  delete theQuitQueue;
+}
+
+void
+XqdbClient::start()
+{
+  theCommandLineHandler->execute();
+}
+
+
+} // namespace zorba
+} // namespace debugger

=== added file 'bin/debugger/xqdb_client.h'
--- bin/debugger/xqdb_client.h	1970-01-01 00:00:00 +0000
+++ bin/debugger/xqdb_client.h	2012-09-27 18:04:43 +0000
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+#pragma once
+#ifndef ZORBA_DEBUGGER_XQDB_CLIENT_H
+#define ZORBA_DEBUGGER_XQDB_CLIENT_H
+
+#include "command_prompt.h"
+#include "command_line_handler.h"
+
+
+namespace zorba { namespace debugger {
+
+class XqdbClient {
+
+  public:
+
+    XqdbClient(unsigned int aPort);
+
+    ~XqdbClient();
+
+    void
+    start();
+
+  private:
+
+    LockFreeQueue<std::size_t>* theIdQueue;
+    LockFreeQueue<bool>*        theQuitQueue;
+
+    EventHandler*       theEventHandler;
+    CommandPrompt*      theCommandPrompt;
+    CommandLineHandler* theCommandLineHandler;
+};
+
+  
+} // namespace zorba
+} // namespace debugger
+
+#endif // ZORBA_DEBUGGER_XQDB_CLIENT_H

=== modified file 'bin/error_printer.cpp'
--- bin/error_printer.cpp	2011-06-14 14:21:49 +0000
+++ bin/error_printer.cpp	2012-09-27 18:04:43 +0000
@@ -64,8 +64,12 @@
           if (aIndent) aOut << std::endl << "        ";
           aOut << "<location ";
           aOut << "fileName=\"" << lFileName << "\" ";
-          aOut << "line=\"" << it->getLine() << "\" ";  
-          aOut << "column=\"" << it->getColumn() << "\" ";  
+          aOut << "lineStart=\"" << it->getLine() << "\" "
+            << "columnStart=\"" << it->getColumn() << "\" ";
+          if (it->getLineEnd())
+            aOut << "lineEnd=\"" << it->getLineEnd() << "\" ";
+          if (it->getColumnEnd())
+            aOut << "lineEnd=\"" << it->getColumnEnd() << "\" ";
           aOut << "/>";
           if (aIndent) aOut << std::endl << "      ";
           aOut << "</call>"; 
@@ -105,8 +109,13 @@
         if (aIndent) aOut << std::endl << "    ";
         //location
         aOut << "<location module='" << aException.source_uri();
-        aOut << "' line='" << aException.source_line();
-        aOut << "' column='" << aException.source_column() << "'/>";
+        aOut << "' lineStart='" << aException.source_line();
+        aOut << "' columnStart='" << aException.source_column() << "'";
+        if (aException.source_line_end())
+          aOut << " lineEnd='" << aException.source_line_end() << "'";
+        if (aException.source_column_end())
+          aOut << " columnEnd='" << aException.source_column_end() << "'";
+        aOut << "/>";
         if (aIndent) aOut << std::endl << "    ";
         //description
         aOut << "<description>" << aException.what() << "</description>";

=== renamed file 'bin/module_path.cpp' => 'bin/path_util.cpp'
--- bin/module_path.cpp	2011-05-25 16:40:26 +0000
+++ bin/path_util.cpp	2012-09-27 18:04:43 +0000
@@ -14,85 +14,117 @@
  * limitations under the License.
  */
 
-#include "module_path.h"
+#include "path_util.h"
 
 #include <stdlib.h>
-#include "zorba/zorba_string.h"
+//#include "zorba/zorba_string.h"
 #include "zorba/util/path.h"
 
 #include "util.h"
 #include "zorbacmdproperties.h"
+#include <zorba/static_context.h>
 
 namespace zorba {
 
-std::string
-ModulePath::getEnvironmentModulePath()
+namespace PathUtil {
+
+static std::string
+getPathFromEnvironment(std::string const& aEnvVar)
 {
-  std::string lEnvName("ZORBA_MODULE_PATH");
 #ifdef WIN32
   char* lBuffer;
   size_t lLen=0;
-  errno_t lErr = getenv_s(&lLen, NULL, 0, lEnvName.c_str());
+  errno_t lErr = getenv_s(&lLen, NULL, 0, aEnvVar.c_str());
   if (lErr || !lLen) return "";
   lBuffer = (char*)malloc(lLen * sizeof(char));
   if (!lBuffer) return "";
-  getenv_s(&lLen, lBuffer, lLen, lEnvName.c_str());
+  getenv_s(&lLen, lBuffer, lLen, aEnvVar.c_str());
   std::string lRes(lBuffer);
   free(lBuffer);
   return lRes;
 #else
-  const char* lEnvValue = getenv(lEnvName.c_str());
-  return lEnvValue!=0?lEnvValue:"";
+  const char* lEnvValue = getenv(aEnvVar.c_str());
+  return lEnvValue != 0 ? lEnvValue : "";
 #endif
 }
 
-void
-ModulePath::convertVector(
-  const std::vector<std::string>& aSource,
-  std::vector<String>&            aDest)
-{
-  for (std::vector<std::string>::const_iterator lIter = aSource.begin();
-       lIter != aSource.end(); ++lIter) {
-    aDest.push_back(*lIter);
-  } 
-}
 
 void
-ModulePath::tokenizeModulePath(
-  const std::string&        aModulePath,
-  std::vector<std::string>& aResult)
+tokenizePath(
+  const std::string&    aPathStr,
+  std::vector<String>&  aResult)
 {
+  std::vector<std::string> lPath;
 #ifdef WIN32
-  Util::tokenize(aModulePath, ";", aResult);
+  Util::tokenize(aPathStr, ";", lPath);
 #else
-  Util::tokenize(aModulePath, ":", aResult);
+  Util::tokenize(aPathStr, ":", lPath);
 #endif
-}
+  for (std::vector<std::string>::iterator lIter = lPath.begin();
+       lIter != lPath.end(); ++lIter) {
+    aResult.push_back(*lIter);
+  }
+}
+
+
+String
+concatenatePaths( const std::vector<String>& aPathList)
+{
+  String delimiter(filesystem_path::get_path_separator());
+
+  String lResult;
+  for (std::vector<String>::const_iterator lIter = aPathList.begin();
+       lIter != aPathList.end(); ++lIter)
+  {
+    lResult += delimiter + *lIter;
+  }
+
+  return lResult;
+}
+
 
 void
-ModulePath::getModulePaths(
+setPathsOnContext(
   const ZorbaCMDProperties& aProperties,
-  std::vector<String>&      aModulePaths)
+  StaticContext_t& aStaticCtx)
 {
-  std::vector<std::string> lModulePaths; // result vector
-  std::string lModulePath; // temporary variable for collections paths
-
-  // 1. add the module paths from the command line properties
-  aProperties.getModulePaths(lModulePath);
-
-  tokenizeModulePath(lModulePath, lModulePaths);
-
-  // 2. add the module paths from the environment
-  lModulePath = ModulePath::getEnvironmentModulePath();
-
-  tokenizeModulePath(lModulePath, lModulePaths);
-
-  // 3. add the current working directory as module path
+  std::vector<String> lPath;
+  std::string lPathStr, lEnvStr;
+
+  // Compute the current working directory to append to all paths.
   filesystem_path lCWD;
-  lModulePaths.push_back(lCWD.get_path());
-
-  // convert std::string to zorba::String
-  convertVector(lModulePaths, aModulePaths);
+
+  // setModulePaths() *overwrites* the URI path and lib path, so there's no
+  // sense in calling both. So if either --module-path or ZORBA_MODULE_PATH
+  // exists, just use those.
+  aProperties.getModulePath(lPathStr);
+  lEnvStr = getPathFromEnvironment("ZORBA_MODULE_PATH");
+  if (lPathStr.length() > 0 || lEnvStr.length() > 0) {
+    tokenizePath(lPathStr, lPath);
+    tokenizePath(lEnvStr, lPath);
+    lPath.push_back(lCWD.get_path());
+    aStaticCtx->setModulePaths(lPath);
+  }
+  else {
+    // Compute and set URI path
+    aProperties.getURIPath(lPathStr);
+    tokenizePath(lPathStr, lPath);
+    lEnvStr = getPathFromEnvironment("ZORBA_URI_PATH");
+    tokenizePath(lEnvStr, lPath);
+    lPath.push_back(lCWD.get_path());
+    aStaticCtx->setURIPath(lPath);
+    lPath.clear();
+
+    // Compute and set lib path
+    aProperties.getLibPath(lPathStr);
+    tokenizePath(lPathStr, lPath);
+    lPath.push_back(lCWD.get_path());
+    lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");
+    tokenizePath(lEnvStr, lPath);
+    aStaticCtx->setLibPath(lPath);
+  }
 }
 
+} /* namespace ModulePath */
+
 } /* namespace zorba */

=== renamed file 'bin/module_path.h' => 'bin/path_util.h'
--- bin/module_path.h	2010-02-12 08:57:04 +0000
+++ bin/path_util.h	2012-09-27 18:04:43 +0000
@@ -18,6 +18,7 @@
 
 #include <vector>
 #include <string>
+#include <zorba/api_shared_types.h>
 
 class ZorbaCMDProperties;
 
@@ -25,30 +26,20 @@
 
   class String;
 
-  class ModulePath {
-  protected:
-    static std::string
-    getEnvironmentModulePath();
-
-    static void
-    convertVector(const std::vector<std::string>& aSource,
-                  std::vector<String>& aDest); 
-
-    static void
-    tokenizeModulePath(const std::string& aModulePath,
-                       std::vector<std::string>& aResult);
-
-    static void
-    getInstalledModulePath(const std::string& aModulePath,
-                       std::vector<std::string>& aResult);
-
-  public:
-    static void
-    getModulePaths(const ZorbaCMDProperties& aProperties,
-                   std::vector<String>& aModulePaths);
-
-
-  };
+  namespace PathUtil {
+
+    void
+    setPathsOnContext(const ZorbaCMDProperties& aProperties,
+                      zorba::StaticContext_t& aStaticCtx);
+
+    void
+    tokenizePath(const std::string& aPathStr, std::vector<String>&  aResult);
+
+
+    String
+    concatenatePaths( const std::vector<String>& aPathList);
+
+  }
 } /* namespace zorba */
 
 #endif

=== modified file 'bin/test/mymod.xq'
--- bin/test/mymod.xq	2009-10-30 16:24:51 +0000
+++ bin/test/mymod.xq	2012-09-27 18:04:43 +0000
@@ -1,4 +1,20 @@
-module namespace foo = "http://www.28msec.com/foo";;
+(:
+ : 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.
+:)
+
+module namespace foo = "http://www.zorba-xquery.com/foo";;
 
 declare function foo:test() {
   if (fn:true())

=== modified file 'bin/test/mymod2.xq'
--- bin/test/mymod2.xq	2010-01-21 13:59:26 +0000
+++ bin/test/mymod2.xq	2012-09-27 18:04:43 +0000
@@ -1,1 +1,17 @@
+(:
+ : 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.
+:)
+
 module namespace i = "i";

=== modified file 'bin/test/option.xq'
--- bin/test/option.xq	2010-12-04 01:58:25 +0000
+++ bin/test/option.xq	2012-09-27 18:04:43 +0000
@@ -1,3 +1,19 @@
+(:
+ : 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.
+:)
+
 import module namespace i = "http://www.zorba-xquery.com/modules/introspection/sctx";;
 
 i:option(fn:QName("http://www.zorba-xquery.com";, "option"))

=== modified file 'bin/test/sequential_expr_err.xq'
--- bin/test/sequential_expr_err.xq	2011-04-13 19:33:42 +0000
+++ bin/test/sequential_expr_err.xq	2012-09-27 18:04:43 +0000
@@ -1,3 +1,19 @@
+(:
+ : 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.
+:)
+
 declare %sequential function local:foo()
 {
   1

=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp	2011-07-01 16:07:54 +0000
+++ bin/zorbacmd.cpp	2012-09-27 18:04:43 +0000
@@ -38,12 +38,22 @@
 #include <zorba/iterator.h>
 #include <zorba/xquery_functions.h>
 #include <zorba/uri_resolvers.h>
+#include <zorba/serialization_callback.h>
+#include <zorba/audit.h>
+#include <zorba/audit_scoped.h>
 
 #include <zorba/store_manager.h>
 
+//#define DO_AUDIT
+
+#ifdef DO_AUDIT
+#include <zorba/audit.h>
+#include <zorba/audit_scoped.h>
+#endif
+
 #include "error_printer.h"
 #include "util.h"
-#include "module_path.h"
+#include "path_util.h"
 
 // For setting the base URI from the current directory
 #include <zorba/util/path.h>
@@ -59,6 +69,8 @@
 #  include "system/properties.h"
 #endif
 
+//#define DO_AUDIT
+
 using namespace zorba;
 namespace zorbatm = zorba::time;
 
@@ -69,14 +81,36 @@
 #define PATH_SEP (zorba::filesystem_path::get_directory_separator ())
 
 #ifndef ZORBA_NO_FULL_TEXT
-OneToOneURIMapper theStopWordsMapper(Resource::STOP_WORDS);
-OneToOneURIMapper theThesaurusMapper(Resource::THESAURUS, URIMapper::COMPONENT);
+OneToOneURIMapper theStopWordsMapper(EntityData::STOP_WORDS);
+OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS);
 #endif
 
-bool
-populateStaticContext(
-    zorba::StaticContext_t& aStaticContext,
-    const ZorbaCMDProperties& aProperties)
+
+/*******************************************************************************
+
+********************************************************************************/
+class URIMapperSerializationCallback : public SerializationCallback
+{
+private:
+  std::vector<URIMapper*>   theURIMappers;
+
+public:
+  void addURIMapper(URIMapper* mapper) { theURIMappers.push_back(mapper); }
+
+  URIMapper* getURIMapper(size_t i) const { return theURIMappers[i]; }
+};
+
+
+URIMapperSerializationCallback theSerializationCallback;
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool populateStaticContext(
+    Zorba* zorba,
+    zorba::StaticContext_t& sctx,
+    const ZorbaCMDProperties& props)
 {
   try
   {
@@ -85,103 +119,162 @@
     // 2. environment ZORBA_MODULE_PATH
     // 3. current working directory
     {
-      std::vector<String> lModulePaths;
-      ModulePath::getModulePaths(aProperties, lModulePaths);
-
-      aStaticContext->setModulePaths(lModulePaths);
-    }
-
-    if (aProperties.boundarySpace().size() != 0 )
-      aStaticContext->setBoundarySpacePolicy(
-                         (aProperties.boundarySpace().compare("preserve") == 0
-                          ? preserve_space
-                          : strip_space));
-
-    if (aProperties.constructionMode().size() != 0)
-      aStaticContext->setConstructionMode( aProperties.boundarySpace().compare("preserve") == 0
-                                           ? preserve_cons
-                                           : strip_cons );
-
-    if (aProperties.orderingMode().size() != 0 )
-    {
-      aStaticContext->setOrderingMode( aProperties.boundarySpace().compare("ordered") == 0
-                                       ? ordered
-                                       : unordered );
-    }
-
-    if (aProperties.baseUri().size() != 0 )
-      aStaticContext->setBaseURI( aProperties.baseUri() );
+      std::vector<String> lModulePath;
+      PathUtil::setPathsOnContext(props, sctx);
+    }
+
+    if (props.boundarySpace().size() != 0 )
+    {
+      sctx->setBoundarySpacePolicy(props.boundarySpace().compare("preserve") == 0 ?
+                                   preserve_space : 
+                                   strip_space);
+    }
+
+    if (props.constructionMode().size() != 0)
+    {
+      sctx->setConstructionMode(props.boundarySpace().compare("preserve") == 0 ? 
+                                preserve_cons :
+                                strip_cons);
+    }
+
+    if (props.orderingMode().size() != 0 )
+    {
+      sctx->setOrderingMode(props.boundarySpace().compare("ordered") == 0 ?
+                            ordered :
+                            unordered);
+    }
+
+    if (props.baseUri().size() != 0 )
+      sctx->setBaseURI( props.baseUri() );
   }
-  catch (zorba::ZorbaException const& ze) {
+  catch (const zorba::ZorbaException& ze) 
+  {
     std::cerr << ze << std::endl;
     return false;
   }
 
-  if (aProperties.defaultCollation().size() != 0 )
-  {
-    try {
-      aStaticContext->addCollation( aProperties.defaultCollation() );
-    } catch (zorba::ZorbaException const&) {
-      std::cerr << "the given collation {" << aProperties.defaultCollation() << "} is not a valid collation." << std::endl;
-      return false;
-    }
-    aStaticContext->setDefaultCollation( aProperties.defaultCollation() );
-  }
-
-  {
-    ZorbaCMDProperties::Options_t::const_iterator lIter = aProperties.optionsBegin();
-    ZorbaCMDProperties::Options_t::const_iterator end = aProperties.optionsEnd();
-    for (; lIter != end; ++lIter)
-    {
-      try {
-        zorba::Zorba* lZorba = zorba::Zorba::getInstance(0);
-        Item lQName = lZorba->getItemFactory()->createQName(lIter->clark_qname);
-        aStaticContext->declareOption(lQName, lIter->value);
-      } catch (zorba::ZorbaException const& /* e */) {
-        std::cerr << "unable to set static context option with qname "
-                  << lIter->clark_qname << std::endl;
-        return false;
-      }
-    }
-  }
+  if (props.defaultCollation().size() != 0 )
+  {
+    try 
+    {
+      sctx->addCollation( props.defaultCollation() );
+    }
+    catch (zorba::ZorbaException const&)
+    {
+      std::cerr << "the given collation {" << props.defaultCollation()
+                << "} is not a valid collation." << std::endl;
+      return false;
+    }
+
+    sctx->setDefaultCollation( props.defaultCollation() );
+  }
+
+  ZorbaCMDProperties::Options_t::const_iterator lIter = props.optionsBegin();
+  ZorbaCMDProperties::Options_t::const_iterator end = props.optionsEnd();
+  for (; lIter != end; ++lIter)
+  {
+    try 
+    {
+      Item lQName = zorba->getItemFactory()->createQName(lIter->clark_qname);
+      sctx->declareOption(lQName, lIter->value);
+    }
+    catch (zorba::ZorbaException const& /* e */) 
+    {
+      std::cerr << "unable to set static context option with qname "
+                << lIter->clark_qname << std::endl;
+      return false;
+    }
+  }
+
+#ifdef DO_AUDIT
+  zorba::audit::Provider* lAuditProvider = zorba->getAuditProvider();
+  zorba::audit::Configuration* config = lAuditProvider->createConfiguration();
+  std::vector<zorba::String> property_names;
+  zorba::audit::Configuration::getPropertyNames(property_names);
+
+  bool lIsStatic;
+
+  lIsStatic = zorba::audit::Configuration::
+  enableProperty(config, property_names, "xquery/compilation/parse-duration");
+  assert(lIsStatic);
+
+  lIsStatic = zorba::audit::Configuration::
+  enableProperty(config, property_names, "xquery/compilation/translation-duration");
+  assert(lIsStatic);
+
+  lIsStatic = zorba::audit::Configuration::
+  enableProperty(config, property_names, "xquery/compilation/optimization-duration");
+  assert(lIsStatic);
+
+  lIsStatic = zorba::audit::Configuration::
+  enableProperty(config, property_names, "xquery/compilation/codegeneration-duration");
+  assert(lIsStatic);
+
+  zorba::audit::Event* event = lAuditProvider->createEvent(config);
+
+  sctx->setAuditEvent(event);
+#endif // DO_AUDIT
+
 #ifndef ZORBA_NO_FULL_TEXT
   {
-    ZorbaCMDProperties::FullText_t::const_iterator lIter = aProperties.stopWordsBegin();
-    ZorbaCMDProperties::FullText_t::const_iterator end = aProperties.stopWordsEnd();
-    for (; lIter != end; ++lIter) {
+    ZorbaCMDProperties::FullText_t::const_iterator lIter = props.stopWordsBegin();
+    ZorbaCMDProperties::FullText_t::const_iterator end = props.stopWordsEnd();
+    for (; lIter != end; ++lIter) 
+    {
       theStopWordsMapper.addMapping(lIter->uri, lIter->value);
     }
-    aStaticContext->registerURIMapper(&theStopWordsMapper);
+
+    if (props.serializePlan() || props.loadPlan()) 
+    {
+      theSerializationCallback.addURIMapper(&theStopWordsMapper);
+    }
+    else
+    {
+      sctx->registerURIMapper(&theStopWordsMapper);
+    }
   }
+
   {
-    ZorbaCMDProperties::FullText_t::const_iterator lIter = aProperties.thesaurusBegin();
-    ZorbaCMDProperties::FullText_t::const_iterator end = aProperties.thesaurusEnd();
-    for (; lIter != end; ++lIter) {
+    ZorbaCMDProperties::FullText_t::const_iterator lIter = props.thesaurusBegin();
+    ZorbaCMDProperties::FullText_t::const_iterator end = props.thesaurusEnd();
+    for (; lIter != end; ++lIter) 
+    {
       theThesaurusMapper.addMapping(lIter->uri, lIter->value);
     }
-    aStaticContext->registerURIMapper(&theThesaurusMapper);
+
+    if (props.serializePlan() || props.loadPlan())
+    {
+      theSerializationCallback.addURIMapper(&theStopWordsMapper);
+    }
+    else
+    {
+      sctx->registerURIMapper(&theThesaurusMapper);
+    }
   }
 #endif
   return true;
 }
 
 
-bool
-populateDynamicContext(
-  Zorba* zorba,
-  zorba::DynamicContext* aDynamicContext,
-  const ZorbaCMDProperties& aProperties)
+/*******************************************************************************
+
+********************************************************************************/
+bool populateDynamicContext(
+    Zorba* zorba,
+    zorba::DynamicContext* aDynamicContext,
+    const ZorbaCMDProperties& props)
 {
-  XmlDataManager* lXmlMgr = zorba->getXmlDataManager();
-  if ( aProperties.contextItem().size() != 0 ) {
-    std::ifstream lInStream(aProperties.contextItem().c_str());
+  if ( props.contextItem().size() != 0 ) 
+  {
+    XmlDataManager* lXmlMgr = zorba->getXmlDataManager();
+    std::ifstream lInStream(props.contextItem().c_str());
     Item lDoc = lXmlMgr->parseXML(lInStream);
     aDynamicContext->setContextItem(lDoc);
   }
 
   ZorbaCMDProperties::ExternalVars_t::const_iterator lIter;
-  ZorbaCMDProperties::ExternalVars_t::const_iterator end = aProperties.externalVarsEnd();
-  for (lIter = aProperties.externalVarsBegin();
+  ZorbaCMDProperties::ExternalVars_t::const_iterator end = props.externalVarsEnd();
+  for (lIter = props.externalVarsBegin();
        lIter != end;
        ++lIter)
   {
@@ -189,6 +282,7 @@
     {
       if ((*lIter).inline_file)
       {
+        XmlDataManager* lXmlMgr = zorba->getXmlDataManager();
         std::ifstream lInStream((*lIter).var_value.c_str());
         Item lDoc = lXmlMgr->parseXML(lInStream);
         aDynamicContext->setVariable((*lIter).var_name, lDoc);
@@ -212,34 +306,36 @@
 }
 
 
-bool
-createSerializerOptions(
+/*******************************************************************************
+
+********************************************************************************/
+bool createSerializerOptions(
     Zorba_SerializerOptions_t& lSerOptions,
-    const ZorbaCMDProperties& aProperties)
+    const ZorbaCMDProperties& props)
 {
-  if ( aProperties.indent() )
+  if ( props.indent() )
     lSerOptions.indent = ZORBA_INDENT_YES;
 
-  if ( aProperties.omitXmlDeclaration() )
+  if ( props.omitXmlDeclaration() )
     lSerOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
 
-  if ( aProperties.byteOrderMark() )
+  if ( props.byteOrderMark() )
     lSerOptions.byte_order_mark = ZORBA_BYTE_ORDER_MARK_YES;
 
-  if ( aProperties.serializeHtml() )
+  if ( props.serializeHtml() )
     lSerOptions.ser_method = ZORBA_SERIALIZATION_METHOD_HTML;
-  else if ( aProperties.serializeText() )
+  else if ( props.serializeText() )
     lSerOptions.ser_method = ZORBA_SERIALIZATION_METHOD_TEXT;
 
   return true;
 }
 
 
-/// Fullfills the command-line "as-file" (-f) switch,
-/// or if not requested, infers -f for file:// queries.
-/// Returns an URI or the empty string.
-std::string
-parseFileURI (bool asPath, const std::string &str)
+/*******************************************************************************
+  Fullfills the command-line "as-file" (-f) switch, or if not requested, infers
+  -f for file:// queries. Returns an URI or the empty string.
+********************************************************************************/
+std::string parseFileURI(bool asPath, const std::string &str)
 {
   if (asPath)
     return str;
@@ -312,6 +408,8 @@
     COMP_TIMER,
     EXEC_TIMER,
     UNLOAD_TIMER,
+    PLAN_SAVE_TIMER,
+    PLAN_LOAD_TIMER,
     TOTAL_TIMER
   } TimerKind;
 
@@ -323,6 +421,8 @@
   DECLARE_TIMER(Exec);
   DECLARE_TIMER(Load);
   DECLARE_TIMER(Unload);
+  DECLARE_TIMER(PlanSave);
+  DECLARE_TIMER(PlanLoad);
   DECLARE_TIMER(Total);
 
   TimingInfo(unsigned long num)
@@ -340,6 +440,13 @@
     elapsedLoadCputime(0),
     elapsedUnloadWalltime(0),
     elapsedUnloadCputime(0),
+
+    elapsedPlanSaveWalltime(0),
+    elapsedPlanSaveCputime(0),
+
+    elapsedPlanLoadWalltime(0),
+    elapsedPlanLoadCputime(0),
+
     elapsedTotalWalltime(0),
     elapsedTotalCputime(0)
   {
@@ -348,7 +455,7 @@
   void startTimer(TimerKind kind, unsigned long iteration);
   void stopTimer(TimerKind kind, unsigned long iteration);
 
-  std::ostream& print(std::ostream& os);
+  std::ostream& print(std::ostream& os, bool);
 };
 
 
@@ -383,6 +490,14 @@
   case UNLOAD_TIMER:
     START_TIMER(Unload);
     break;
+
+  case PLAN_SAVE_TIMER:
+    START_TIMER(PlanSave);
+    break;
+
+  case PLAN_LOAD_TIMER:
+    START_TIMER(PlanLoad);
+    break;
   }
 }
 
@@ -425,12 +540,22 @@
     STOP_TIMER(Unload);
     break;
   }
+  case PLAN_SAVE_TIMER:
+  {
+    STOP_TIMER(PlanSave);
+    break;
+  }
+  case PLAN_LOAD_TIMER:
+  {
+    STOP_TIMER(PlanLoad);
+    break;
+  }
   }
 }
 
 
 std::ostream&
-TimingInfo::print(std::ostream& os)
+TimingInfo::print(std::ostream& os, bool serializePlan)
 {
   os.precision(3);
   os.setf(std::ios::fixed);
@@ -442,12 +567,16 @@
   double eWalltime = elapsedExecWalltime / timeDiv;
   double lWalltime = elapsedLoadWalltime / timeDiv;
   double uWalltime = elapsedUnloadWalltime / timeDiv;
+  double psWalltime = elapsedPlanSaveWalltime / timeDiv;
+  double plWalltime = elapsedPlanLoadWalltime / timeDiv;
   double tWalltime = elapsedTotalWalltime / timeDiv;
 
   double cCputime = elapsedCompCputime / timeDiv;
   double eCputime = elapsedExecCputime / timeDiv;
   double lCputime = elapsedLoadCputime / timeDiv;
   double uCputime = elapsedUnloadCputime / timeDiv;
+  double psCputime = elapsedPlanSaveCputime / timeDiv;
+  double plCputime = elapsedPlanLoadCputime / timeDiv;
   double tCputime = elapsedTotalCputime / timeDiv;
 
   os << "Engine Startup Time     : " << elapsedInitWalltime
@@ -458,6 +587,17 @@
      << " (user: " << cCputime << ")"
      << " milliseconds" << std::endl;
 
+  if (serializePlan)
+  {
+    os << "Average Plan Saving Time: " << psWalltime
+       << " (user: " << psCputime << ")"
+       << " milliseconds" << std::endl;
+    
+    os << "Average Plan Loading Time: " << plWalltime
+       << " (user: " << plCputime << ")"
+       << " milliseconds" << std::endl;
+  }
+
   os << "Average Execution Time  : " << eWalltime - lWalltime
      << " (user: " << eCputime - lCputime  << ")"
      << " milliseconds" << std::endl;
@@ -505,16 +645,59 @@
   unsigned long lNumExecutions = properties.multiple();
   bool lIndent = properties.indent();
   bool doTiming = properties.timing();
-
+  bool serializePlan = properties.serializePlan();
+  bool savePlan = properties.savePlan();
+  bool loadPlan = properties.loadPlan();
+  std::ostringstream lOut;
   Zorba_CompilerHints lHints;
 
+  std::auto_ptr<std::fstream> planFile;
+  std::fstream* planFilep = NULL;
+
+  if (serializePlan)
+  {
+    if (savePlan || loadPlan)
+    {
+      std::cerr << "The --serialize-plan option cannot be used together with the --compile-plan or --execute-plan options" << std::endl;
+      exit(1);
+    }
+
+    std::string planFilePath = qfilepath;
+    planFilePath += ".plan";
+    planFile.reset(new std::fstream(planFilePath.c_str(), 
+                                    std::fstream::in | 
+                                    std::fstream::out |
+                                    std::fstream::trunc |
+                                    std::fstream::binary));
+    planFilep = planFile.get();
+    assert(planFilep->good());
+  }
+
+  if (savePlan && loadPlan)
+  {
+    std::cerr << "The --compile-plan and --execute-plan options cannot be used together" << std::endl;
+    exit(1);
+  }
+
   // default is O1 in the Zorba_CompilerHints constructor
-  if (properties.optimizationLevel() == "O0") {
+  if (properties.optimizationLevel() == "O0") 
+  {
     lHints.opt_level = ZORBA_OPT_LEVEL_O0;
-  } else if (properties.optimizationLevel() == "O2") {
+  }
+  else if (properties.optimizationLevel() == "O2") 
+  {
     lHints.opt_level = ZORBA_OPT_LEVEL_O2;
   }
 
+  lHints.for_serialization_only = true;
+
+#if ZORBACMD_LOAD_SYSTEM_PROPERTIES
+  if (Properties::instance()->serializeOnlyQuery() == 0)
+  {
+    lHints.for_serialization_only = false;
+  }
+#endif
+
   // default is false
   if (properties.libModule())
   {
@@ -529,7 +712,14 @@
 
   for (unsigned long i = 0; i < lNumExecutions; ++i)
   {
-    // Perform compilation and create dynamic context only once, unless timing is needed
+    // start the total timer
+    if (doTiming)
+      timing.startTimer(TimingInfo::TOTAL_TIMER, i);
+    
+    //
+    // Compile the query
+    // Compilation is done only once, unless timing is needed
+    //
     if (doTiming || i == 0)
     {
       // go back to the beginning of the stream
@@ -537,33 +727,51 @@
       qfile.seekg(0);
       assert (qfile.tellg() >= 0);
 
-      if (doTiming)
-      {
-        // start the total timer
-        timing.startTimer(TimingInfo::TOTAL_TIMER, i);
-      }
-
-      //
-      // Compile the query
-      //
       try
       {
+        // start the compilation timer
         if (doTiming)
-        {
-          // start the compilation timer
           timing.startTimer(TimingInfo::COMP_TIMER, i);
-        }
 
+        // Create and compile the query
         query = zorbaInstance->createQuery();
         query->registerDiagnosticHandler(&diagnosticHandler);
         query->setFileName(qfilepath);
 
-        query->compile(qfile, staticContext, lHints);
-
-        if (doTiming)
-        {
-          // stop the compilation timer
-          timing.stopTimer(TimingInfo::COMP_TIMER, i);
+        if (loadPlan) 
+        {
+          query->loadExecutionPlan(qfile, &theSerializationCallback);
+
+          // stop the compilation timer
+          if (doTiming)
+            timing.stopTimer(TimingInfo::COMP_TIMER, i);
+        }
+        else
+        {
+          query->compile(qfile, staticContext, lHints);
+
+          // stop the compilation timer
+          if (doTiming)
+            timing.stopTimer(TimingInfo::COMP_TIMER, i);
+
+          // Serialize the execution plan, if requested
+          if (serializePlan) 
+          {
+            planFilep->clear();
+            planFilep->seekp(0);
+
+            // start the plan-save timer
+            if (doTiming)
+              timing.startTimer(TimingInfo::PLAN_SAVE_TIMER, i);
+
+            query->saveExecutionPlan(*planFilep, ZORBA_USE_BINARY_ARCHIVE);
+
+            // stop the plan-save timer
+            if (doTiming)
+              timing.stopTimer(TimingInfo::PLAN_SAVE_TIMER, i);
+
+            planFilep->flush();
+          }
         }
       }
       catch (zorba::XQueryException const& qe)
@@ -576,66 +784,85 @@
         std::cerr << ze << std::endl;
         return 12;
       }
-
-      // if (diagnosticHandler.
-
-      //
-      // Create and populate the dynamic context
-      //
-      zorba::DynamicContext* lDynamicContext = query->getDynamicContext();
-      try
-      {
-        if ( ! populateDynamicContext(zorbaInstance, lDynamicContext, properties) )
-        {
-          properties.printHelp(std::cout);
-          return 21;
-        }
-      }
-      catch (zorba::XQueryException const& qe)
-      {
-        ErrorPrinter::print(qe, std::cerr, properties.printErrorsAsXml(), lIndent);
-        return 22;
-      }
-      catch (zorba::ZorbaException const& ze)
-      {
-        std::cerr << ze << std::endl;
-        return 23;
-      }
     } // if (doTiming || i == 0)
 
-    // libModule assumes compileOnly even if compileOnly is false
+    //
+    // Run the query, unless compileOnly has been requested.
+    //
     if ( ! properties.compileOnly() && ! properties.libModule() )
     {
-      //
-      // Run the query
-      //
       try
       {
+        // load the execution plan, if requested
+        if (serializePlan) 
+        {
+          planFilep->seekg(0);
+          assert(planFilep->good());
+          
+          // start the plan-load timer
+          if (doTiming)
+            timing.startTimer(TimingInfo::PLAN_LOAD_TIMER, i);
+
+          query = zorbaInstance->createQuery();
+          query->loadExecutionPlan(*planFilep, &theSerializationCallback);
+
+          // stop the plan-load timer
+          if (doTiming)
+            timing.stopTimer(TimingInfo::PLAN_LOAD_TIMER, i);
+        }
+
+        // start the execution timer
         if (doTiming)
-        {
-          // start the execution timer
           timing.startTimer(TimingInfo::EXEC_TIMER, i);
-        }
-
+
+        // Populate the dynamic context
+        zorba::DynamicContext* lDynamicContext = query->getDynamicContext();
+        try
+        {
+          if ( ! populateDynamicContext(zorbaInstance, lDynamicContext, properties) )
+          {
+            properties.printHelp(std::cout);
+            return 21;
+          }
+        }
+        catch (zorba::XQueryException const& qe)
+        {
+          ErrorPrinter::print(qe, std::cerr, properties.printErrorsAsXml(), lIndent);
+          return 22;
+        }
+        catch (zorba::ZorbaException const& ze)
+        {
+          std::cerr << ze << std::endl;
+          return 23;
+        }
+
+        // run the query
         if (properties.noSerializer())
         {
           query->executeSAX();
         }
+        else if (savePlan)
+        {
+          query->saveExecutionPlan(outputStream,
+                                   ZORBA_USE_BINARY_ARCHIVE,
+                                   SAVE_UNUSED_FUNCTIONS);
+        }
         else
         {
           query->execute(outputStream, &lSerOptions);
-          if (properties.trailingNl()) {
-            outputStream << std::endl;
-          }
         }
 
+        if (properties.trailingNl()) 
+          outputStream << std::endl;
+ 
+        query->close();
+
+         // stop the execution timer
         if (doTiming)
-        {
-          // stop the execution timer
           timing.stopTimer(TimingInfo::EXEC_TIMER, i);
-        }
 
-        if (i > 0 || lNumExecutions == 1) {
+        if (i > 0 || lNumExecutions == 1) 
+        {
           timing.elapsedLoadWalltime += query->getDocLoadingTime();
           timing.elapsedLoadCputime += query->getDocLoadingUserTime();
         }
@@ -652,28 +879,37 @@
       }
     }
 
-    // only delete the docs from the store if timing is needed
+    //
+    // Delete all loaded docs from the store, if timing has been requested
+    //
     if (doTiming)
     {
-      //
-      // Delete all loaded docs from the store
-      //
       XmlDataManager* store = zorbaInstance->getXmlDataManager();
 
       timing.startTimer(TimingInfo::UNLOAD_TIMER, i);
+
       DocumentManager* lMgr = store->getDocumentManager();
       ItemSequence_t lSeq = lMgr->availableDocuments();
       Iterator_t lIter = lSeq->getIterator();
       lIter->open();
       Item lURI;
-      while (lIter->next(lURI)) {
+      while (lIter->next(lURI)) 
+      {
         lMgr->remove(lURI.getStringValue());
       }
+
       timing.stopTimer(TimingInfo::UNLOAD_TIMER, i);
+    }
 
+    // stop the total timer
+    if (doTiming)
       timing.stopTimer(TimingInfo::TOTAL_TIMER, i);
-    }
-  }
+
+#ifdef DO_AUDIT
+    audit::Event* event = staticContext->getAuditEvent(); 
+    std::cerr << *event << std::endl;
+#endif
+  } // for each execution
 
   return 0;
 }
@@ -698,27 +934,28 @@
 #endif
 
   // parse the command line and/or the properties file
-  ZorbaCMDProperties lProperties;
-  if (!lProperties.loadProperties(argc, argv))
+  ZorbaCMDProperties properties;
+  if (!properties.loadProperties(argc, argv))
   {
     return 1;
   }
 
-  TimingInfo timing(lProperties.multiple());
+  TimingInfo engineTiming(properties.multiple());
 
-  bool doTiming = lProperties.timing();
+  bool doTiming = properties.timing();
   bool debug = false;
 #ifdef ZORBA_WITH_DEBUGGER
-  debug = (lProperties.debug());
+  debug = (properties.debug());
 #endif
 
   // libModule assumes compileOnly even if compileOnly is false
-  bool compileOnly = (lProperties.compileOnly() || lProperties.libModule() );
+  bool compileOnly = (properties.compileOnly() || properties.libModule() );
 
   // write to file or standard out
-  std::auto_ptr<std::ostream> lFileStream(lProperties.outputFile().size() > 0 ?
-                                           new std::ofstream(lProperties.outputFile().c_str())
-                                          : 0 );
+  std::auto_ptr<std::ostream> 
+  lFileStream(properties.outputFile().size() > 0 ?
+              new std::ofstream(properties.outputFile().c_str()) : 0);
+
   std::ostream* lOutputStream = lFileStream.get();
   if ( lOutputStream == 0 )
   {
@@ -726,43 +963,72 @@
   }
   else if ( !lOutputStream->good() )
   {
-    std::cerr << "could not write to output file {" << lProperties.outputFile()
+    std::cerr << "could not write to output file {" << properties.outputFile()
               << "}" << std::endl;
     return 2;
   }
 
-  if(lProperties.queriesOrFilesBegin() == lProperties.queriesOrFilesEnd())
+  if (properties.queriesOrFilesBegin() == properties.queriesOrFilesEnd())
   {
     std::cerr << "no queries submitted." << std::endl;
-    lProperties.printHelp(std::cout);
+    properties.printHelp(std::cout);
     return 3;
   }
 
+  // Add command line --classpath option in front of config/env CLASSPATH
+  Properties* globaproperties = Properties::instance();
+  std::string cmdJvmClassPath;
+  properties.getJVMClassPath(cmdJvmClassPath);
+  std::string configJvmClassPath;
+  globaproperties->getJVMClassPath(configJvmClassPath);
+  globaproperties->setJVMClassPath(cmdJvmClassPath +
+      filesystem_path::get_path_separator() + configJvmClassPath);
 
   // Start the engine
 
-  timing.startTimer(TimingInfo::INIT_TIMER, 2);
+  engineTiming.startTimer(TimingInfo::INIT_TIMER, 2);
 
   void* store = zorba::StoreManager::getStore();
 
   zorba::Zorba* lZorbaInstance = zorba::Zorba::getInstance(store);
 
+#ifdef DO_AUDIT
+  zorba::audit::Provider* lAuditProvider = lZorbaInstance->getAuditProvider();
+
+  zorba::audit::Configuration* config = lAuditProvider->createConfiguration();
+
+  std::vector<zorba::String> property_names;
+  zorba::audit::Configuration::getPropertyNames(property_names);
+
+  zorba::audit::Configuration::
+  enableProperty(config, property_names, "xquery/compilation/parse-duration");
+
+  zorba::audit::Configuration::
+  enableProperty(config, property_names, "xquery/compilation/translation-duration");
+
+  zorba::audit::Configuration::
+  enableProperty(config, property_names, "xquery/compilation/optimization-duration");
+
+  zorba::audit::Configuration::
+  enableProperty(config, property_names, "xquery/compilation/codegeneration-duration");
+#endif
+
   {
-  timing.stopTimer(TimingInfo::INIT_TIMER, 2);
+  engineTiming.stopTimer(TimingInfo::INIT_TIMER, 2);
 
   // For each query ...
 
   int queryNo;
   ZorbaCMDProperties::QueriesOrFiles_t::const_iterator lIter;
-  for (queryNo = 1, lIter = lProperties.queriesOrFilesBegin();
-       lIter != lProperties.queriesOrFilesEnd();
+  for (queryNo = 1, lIter = properties.queriesOrFilesBegin();
+       lIter != properties.queriesOrFilesEnd();
        ++queryNo, ++lIter)
   {
     //
     // Read the query (either from a file or given as parameter)
     //
     std::string fURI = *lIter;
-    std::string fname = parseFileURI (lProperties.asFiles (), fURI);
+    std::string fname = parseFileURI (properties.asFiles (), fURI);
     zorba::filesystem_path path (fname);
     bool asFile = ! fname.empty ();
     std::auto_ptr<std::istream> qfile;
@@ -770,30 +1036,31 @@
     if (asFile)
     {
       path.resolve_relative ();
-      qfile.reset (new std::ifstream (path.c_str ()));
+      qfile.reset(new std::ifstream (path.c_str ()));
     }
     else
     {
-      qfile.reset (new std::istringstream(fURI));
+      qfile.reset(new std::istringstream(fURI));
     }
 
-    if ( asFile && (!qfile->good() || qfile->eof()) )
+    if (asFile && (!qfile->good() || qfile->eof()))
     {
       std::cerr << "file {" << fname << "} not found or not readable." << std::endl;
-      lProperties.printHelp(std::cout);
+      properties.printHelp(std::cout);
       return 3;
     }
     else if (fURI.empty ())
     {
       std::cerr << "empty query." << std::endl;
-      lProperties.printHelp(std::cout);
+      properties.printHelp(std::cout);
       return 3;
     }
 
     //
     // Print the query if requested
     //
-    if (lProperties.printQuery()) {
+    if (properties.printQuery()) 
+    {
       *lOutputStream << "\nQuery number " << queryNo << " :\n";
       std::copy (std::istreambuf_iterator<char> (*qfile),
                  std::istreambuf_iterator<char> (),
@@ -807,13 +1074,19 @@
     // Create the static context and populate it with info taken from the properties
     //
     zorba::StaticContext_t lStaticContext = lZorbaInstance->createStaticContext();
-    if (! populateStaticContext(lStaticContext, lProperties) )
+
+    if (! populateStaticContext(lZorbaInstance, lStaticContext, properties) )
     {
-      lProperties.printHelp(std::cout);
+      properties.printHelp(std::cout);
       return 3;
     }
 
-    if (!asFile && lProperties.baseUri().size() == 0 )
+#ifdef DO_AUDIT
+    zorba::audit::Event* event = lAuditProvider->createEvent(config);
+    lStaticContext->setAuditEvent(event);
+#endif // DO_AUDIT
+
+    if (!asFile && properties.baseUri().size() == 0 )
     {
       // No user set base URI. Set the cwd to be used as base-uri in order
       // to make the doc function doc("mydoc.xml") work
@@ -836,16 +1109,20 @@
     }
 
     // Parse the query
-    if (lProperties.parseOnly()) {
-      try {
+    if (properties.parseOnly()) 
+    {
+      try 
+      {
         zorba::XQuery_t lQuery = lZorbaInstance->createQuery();
-        if (asFile) {
+        if (asFile)
+        {
           lQuery->setFileName(path.get_path());
         }
 
         lQuery->parse (*qfile);
       }
-      catch (zorba::ZorbaException const& ze) {
+      catch (zorba::ZorbaException const& ze) 
+      {
         std::cerr << ze << std::endl;
         return 6;
       }
@@ -853,52 +1130,71 @@
 
     // Compile and run it if necessary.
     // Print timing information if requested.
-    else if (!debug) {
-      if (compileOnly) {
-        try {
+    else if (!debug) 
+    {
+      if (compileOnly) 
+      {
+        try 
+        {
           zorba::XQuery_t aQuery = lZorbaInstance->createQuery();
-          if (asFile) {
+          if (asFile) 
+          {
             aQuery->setFileName(path.get_path());
           }
+
           aQuery->parse(*qfile);
+
           qfile->clear();
           qfile->seekg(0); // go back to the beginning
-        } catch (zorba::XQueryException const& qe) {
-          ErrorPrinter::print(qe, std::cerr, lProperties.printErrorsAsXml(), lProperties.indent());
+        }
+        catch (zorba::XQueryException const& qe)
+        {
+          ErrorPrinter::print(qe,
+                              std::cerr,
+                              properties.printErrorsAsXml(),
+                              properties.indent());
           return 6;
         }
       }
 
+      TimingInfo queryTiming(properties.multiple());
+
       int status = compileAndExecute(lZorbaInstance,
-                                     lProperties,
+                                     properties,
                                      lStaticContext,
                                      path.get_path(),
                                      *qfile,
                                      *lOutputStream,
-                                     timing);
-      if (status != 0) {
+                                     queryTiming);
+      if (status != 0) 
+      {
         // reset the file handler (in case output option was provided)
         // in order to delete the created output file
         lFileStream.reset();
-        removeOutputFileIfNeeded(lProperties);
+        removeOutputFileIfNeeded(properties);
         return status;
       }
 
-      if (doTiming) {
-        timing.print(std::cout);
+      if (doTiming) 
+      {
+        bool serializePlan = properties.serializePlan();
+        queryTiming.print(std::cout, serializePlan);
       }
     }
 
 #ifdef ZORBA_WITH_DEBUGGER
     // Debug the query. Do not allow "compileOnly" flags and inline queries
-    else if (debug) {
-      if (compileOnly) {
+    else if (debug) 
+    {
+      if (compileOnly) 
+      {
         std::cerr << "cannot debug a query if the compileOnly option is specified"
                   << std::endl;
         return 7;
       }
 
-      if (!asFile) {
+      if (!asFile) 
+      {
         std::cerr << "Cannot debug inline queries." << std::endl;
         return 8;
       }
@@ -908,7 +1204,8 @@
 
       zorba::XQuery_t lQuery;
 
-      try {
+      try 
+      {
         lQuery = lZorbaInstance->createQuery();
         lQuery->setFileName(lFileName);
         lQuery->setDebugMode(true);
@@ -918,30 +1215,33 @@
 
         lQuery->compile(*lXQ.get(), lHints);
         zorba::DynamicContext* lDynamicContext = lQuery->getDynamicContext();
-        if (!populateDynamicContext(lZorbaInstance, lDynamicContext, lProperties)) {
+        if (!populateDynamicContext(lZorbaInstance, lDynamicContext, properties)) {
           return 9;
         }
 
-        std::string lHost = lProperties.debugHost();
+        std::string lHost = properties.debugHost();
         if (lHost == "") {
           lHost = "127.0.0.1";
         }
 
-        if (lProperties.debug()) {
-          Zorba_SerializerOptions lSerOptions =
-              Zorba_SerializerOptions::SerializerOptionsFromStringParams(
-              lProperties.getSerializerParameters());
-          createSerializerOptions(lSerOptions, lProperties);
+        Zorba_SerializerOptions lSerOptions =
+            Zorba_SerializerOptions::SerializerOptionsFromStringParams(
+            properties.getSerializerParameters());
+        createSerializerOptions(lSerOptions, properties);
 
-          if (!lProperties.hasNoLogo() && !lProperties.debug()) {
-            std::cout << "Zorba XQuery Debugger Server\n" << copyright_str << std::endl;
-          }
-          lQuery->debug(*lOutputStream, lSerOptions, lHost, lProperties.getDebugPort());
+        if (!properties.hasNoLogo()) 
+        {
+          std::cout << "Zorba XQuery Debugger Server\n" << copyright_str << std::endl;
         }
+
+        lQuery->debug(*lOutputStream, lSerOptions, lHost, properties.getDebugPort());
       }
       catch (zorba::XQueryException const& qe)
       {
-        ErrorPrinter::print(qe, std::cerr, lProperties.printErrorsAsXml(), lProperties.indent());
+        ErrorPrinter::print(qe,
+                            std::cerr,
+                            properties.printErrorsAsXml(),
+                            properties.indent());
         return 5;
       }
       catch (zorba::ZorbaException const& ze)
@@ -952,25 +1252,33 @@
     } // else if (debug)
 #endif
 
+#ifdef DO_AUDIT
+    lAuditProvider->submitEvent(event);
+#endif
+
   } // for each query
 
   }
 
   if (doTiming)
   {
-    timing.startTimer(TimingInfo::DEINIT_TIMER, 2);
+    engineTiming.startTimer(TimingInfo::DEINIT_TIMER, 2);
   }
 
+#ifdef DO_AUDIT
+  lAuditProvider->destroyConfiguration(config);
+#endif
+
   lZorbaInstance->shutdown();
   zorba::StoreManager::shutdownStore(store);
 
   if (doTiming)
   {
-    timing.stopTimer(TimingInfo::DEINIT_TIMER, 2);
+    engineTiming.stopTimer(TimingInfo::DEINIT_TIMER, 2);
 
     std::cout << std::endl << "Engine Shutdown Time     : "
-              << timing.elapsedDeinitWalltime
-              << " (user: " << timing.elapsedDeinitCputime << ")"
+              << engineTiming.elapsedDeinitWalltime
+              << " (user: " << engineTiming.elapsedDeinitCputime << ")"
               << " milliseconds" << std::endl;
   }
   return 0;

=== modified file 'bin/zorbacmdproperties.cpp'
--- bin/zorbacmdproperties.cpp	2011-06-29 15:42:47 +0000
+++ bin/zorbacmdproperties.cpp	2012-09-27 18:04:43 +0000
@@ -116,6 +116,9 @@
     std::string lURI   = lIter->substr(0, lEQual);
     std::string lValue = lIter->substr(lEQual + 2);
 
+    if ( lURI == "default" )
+      lURI = "##default";
+
     FullTextMapping lMapping;
     lMapping.uri   = lURI;
     lMapping.value = lValue;
@@ -163,11 +166,25 @@
 }
 
 
-void ZorbaCMDProperties::getModulePaths(std::string& aPaths) const
-{
-  aPaths = theModulePath;
-}
-
+void ZorbaCMDProperties::getModulePath(std::string& aPath) const
+{
+  aPath = theModulePath;
+}
+
+void ZorbaCMDProperties::getURIPath(std::string& aPath) const
+{
+  aPath = theUriPath;
+}
+
+void ZorbaCMDProperties::getLibPath(std::string& aPath) const
+{
+  aPath = theLibPath;
+}
+
+void ZorbaCMDProperties::getJVMClassPath(std::string& aPath) const
+{
+  aPath = theClasspath;
+}
 
 std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const
 {

=== modified file 'bin/zorbacmdproperties.h'
--- bin/zorbacmdproperties.h	2011-06-29 17:25:50 +0000
+++ bin/zorbacmdproperties.h	2012-09-27 18:04:43 +0000
@@ -84,8 +84,17 @@
   getSerializerParameters() const;
 
   void
-  getModulePaths(std::string&) const;
+  getModulePath(std::string&) const;
   
+  void
+  getURIPath(std::string&) const;
+
+  void
+  getLibPath(std::string&) const;
+
+  void
+  getJVMClassPath(std::string&) const;
+
   bool isDebug(){ return theDebug; }
 
   bool hasNoLogo(){ return theNoLogo; }

=== modified file 'bin/zorbacmdproperties.txt'
--- bin/zorbacmdproperties.txt	2011-07-04 08:31:01 +0000
+++ bin/zorbacmdproperties.txt	2012-09-27 18:04:43 +0000
@@ -28,8 +28,13 @@
 ("debug-port,p", po::value<unsigned int>()->default_value (28028), "The port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028")
 ("no-logo", "Print no logo when starting.")
 ("timeout", po::value<long>()->default_value(-1), "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.")
-("module-path", po::value<std::string>(), "Module paths added to the built-in resolver, i.e. where module imports are looking for modules.")
+("uri-path", po::value<std::string>(), "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.")
+("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")
+("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")
+("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
 ("option", po::value<std::vector<std::string> >(), "Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value";).
 ("trailing-nl", "Output a trailing newline after the result of the query.")
 ("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")
 ("thesaurus", po::value<std::vector<std::string> >(), "Mapping specifying a thesaurus URI to another.")
+("compile-plan,c", "Output the query plan as binary.")
+("execute-plan", "Take a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.")

=== modified file 'bin/zorbacmdproperties_base.h'
--- bin/zorbacmdproperties_base.h	2011-07-04 08:31:01 +0000
+++ bin/zorbacmdproperties_base.h	2012-09-27 18:04:43 +0000
@@ -15,13 +15,6 @@
  */
 /* vim:set et sw=2 ts=2: */
 
-// ******************************************
-// *                                        *
-// * THIS IS A GENERATED FILE. DO NOT EDIT! *
-// * SEE .txt FILE WITH SAME NAME           *
-// *                                        *
-// ******************************************
-
 #include <string>
 #include <sstream>
 #include <zorba/config.h>
@@ -30,13 +23,29 @@
 
 #ifndef ZORBACMD_ZORBACMDPROPERTIESBASE
 #define ZORBACMD_ZORBACMDPROPERTIESBASE
-namespace zorbacmd { 
-class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase {
+namespace zorbacmd
+{
+
+class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase
+{
 protected:
-  const char **get_all_options () const {
-    static const char *result [] = { "--timing", "--output-file", "--serialization-parameter", "--serialize-html", "--serialize-text", "--indent", "--print-query", "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration", "--base-uri", "--boundary-space", "--default-collation", "--construction-mode", "--ordering-mode", "--multiple", "--query", "--as-files", "--external-variable", "--context-item", "--optimization-level", "--lib-module", "--parse-only", "--compile-only", "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo", "--timeout", "--module-path", "--option", "--trailing-nl", "--stop-words", "--thesaurus", NULL };
+  const char** get_all_options () const
+  {
+    static const char* result [] = {
+      "--timing", "--output-file", "--serialization-parameter",
+      "--serialize-html", "--serialize-text", "--indent", "--print-query",
+      "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration",
+      "--base-uri", "--boundary-space", "--default-collation",
+      "--construction-mode", "--ordering-mode", "--multiple", "--query",
+      "--as-files", "--external-variable", "--context-item",
+      "--optimization-level", "--lib-module", "--parse-only", "--compile-only",
+      "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo",
+      "--timeout", "--uri-path", "--lib-path", "--module-path", "--classpath",
+      "--option", "--trailing-nl", "--stop-words", "--thesaurus",
+      "--compile-plan", "--execute-plan --serialize-plan", NULL };
     return result;
   }
+
   bool theTiming;
   std::string theOutputFile;
   std::vector<std::string> theSerializationParameter;
@@ -67,13 +76,20 @@
   unsigned int theDebugPort;
   bool theNoLogo;
   long theTimeout;
+  std::string theUriPath;
+  std::string theLibPath;
   std::string theModulePath;
+  std::string theClasspath;
   std::vector<std::string> theOption;
   bool theTrailingNl;
   std::vector<std::string> theStopWords;
   std::vector<std::string> theThesaurus;
+  bool theSerializePlan;
+  bool theSavePlan;
+  bool theLoadPlan;
 
-  void initialize () {
+  void initialize () 
+  {
     theTiming = false;
     theSerializeHtml = false;
     theSerializeText = false;
@@ -95,7 +111,11 @@
     theNoLogo = false;
     theTimeout = -1;
     theTrailingNl = false;
+    theSerializePlan = false;
+    theSavePlan = false;
+    theLoadPlan = false;
   }
+
 public:
   const bool &timing () const { return theTiming; }
   const std::string &outputFile () const { return theOutputFile; }
@@ -127,170 +147,296 @@
   const unsigned int &debugPort () const { return theDebugPort; }
   const bool &noLogo () const { return theNoLogo; }
   const long &timeout () const { return theTimeout; }
+  const std::string &uriPath () const { return theUriPath; }
+  const std::string &libPath () const { return theLibPath; }
   const std::string &modulePath () const { return theModulePath; }
+  const std::string &classpath () const { return theClasspath; }
   const std::vector<std::string> &option () const { return theOption; }
   const bool &trailingNl () const { return theTrailingNl; }
   const std::vector<std::string> &stopWords () const { return theStopWords; }
   const std::vector<std::string> &thesaurus () const { return theThesaurus; }
+  const bool& serializePlan () const { return theSerializePlan; }
+  const bool& loadPlan () const { return theLoadPlan; }
+  const bool& savePlan () const { return theSavePlan; }
 
-  std::string load_argv (int argc, const char **argv) {
+  std::string load_argv (int argc, const char **argv) 
+  {
     if (argv == NULL) return "";
 
     std::string result;
-    for (++argv; *argv != NULL; ++argv) {
+    for (++argv; *argv != NULL; ++argv) 
+    {
       if (strcmp (*argv, "--help") == 0 || strcmp (*argv, "-h") == 0)
         return "!HELP";
+
       else if (strcmp (*argv, "--version") == 0)
         return "!VER";
-      else if (strcmp (*argv, "--timing") == 0 || strncmp (*argv, "-t", 2) == 0) {
+
+      else if (strcmp (*argv, "--timing") == 0 || strncmp (*argv, "-t", 2) == 0) 
+      {
         theTiming = true;
       }
-      else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --output-file option"; break; }        init_val (*argv, theOutputFile, d);
-      }
-      else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; }        init_val (*argv, theSerializationParameter, d);
-      }
-      else if (strcmp (*argv, "--serialize-html") == 0) {
+      else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --output-file option"; break; }
+        init_val (*argv, theOutputFile, d);
+      }
+      else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; }
+
+        init_val (*argv, theSerializationParameter, d);
+      }
+      else if (strcmp (*argv, "--serialize-html") == 0) 
+      {
         theSerializeHtml = true;
       }
-      else if (strcmp (*argv, "--serialize-text") == 0) {
+      else if (strcmp (*argv, "--serialize-text") == 0) 
+      {
         theSerializeText = true;
       }
-      else if (strcmp (*argv, "--indent") == 0 || strncmp (*argv, "-i", 2) == 0) {
+      else if (strcmp (*argv, "--indent") == 0 || strncmp (*argv, "-i", 2) == 0) 
+      {
         theIndent = true;
       }
-      else if (strcmp (*argv, "--print-query") == 0) {
+      else if (strcmp (*argv, "--print-query") == 0) 
+      {
         thePrintQuery = true;
       }
-      else if (strcmp (*argv, "--print-errors-as-xml") == 0 || strncmp (*argv, "-x", 2) == 0) {
+      else if (strcmp (*argv, "--print-errors-as-xml") == 0 || strncmp (*argv, "-x", 2) == 0)
+      {
         thePrintErrorsAsXml = true;
       }
-      else if (strcmp (*argv, "--byte-order-mark") == 0) {
+      else if (strcmp (*argv, "--byte-order-mark") == 0) 
+      {
         theByteOrderMark = true;
       }
-      else if (strcmp (*argv, "--omit-xml-declaration") == 0 || strncmp (*argv, "-r", 2) == 0) {
+      else if (strcmp (*argv, "--omit-xml-declaration") == 0 || strncmp (*argv, "-r", 2) == 0) 
+      {
         theOmitXmlDeclaration = true;
       }
-      else if (strcmp (*argv, "--base-uri") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --base-uri option"; break; }        init_val (*argv, theBaseUri, d);
-      }
-      else if (strcmp (*argv, "--boundary-space") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --boundary-space option"; break; }        init_val (*argv, theBoundarySpace, d);
-      }
-      else if (strcmp (*argv, "--default-collation") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --default-collation option"; break; }        init_val (*argv, theDefaultCollation, d);
-      }
-      else if (strcmp (*argv, "--construction-mode") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --construction-mode option"; break; }        init_val (*argv, theConstructionMode, d);
+      else if (strcmp (*argv, "--base-uri") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --base-uri option"; break; }
+        init_val (*argv, theBaseUri, d);
+      }
+      else if (strcmp (*argv, "--boundary-space") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --boundary-space option"; break; }
+        init_val (*argv, theBoundarySpace, d);
+      }
+      else if (strcmp (*argv, "--default-collation") == 0)
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --default-collation option"; break; }
+        init_val (*argv, theDefaultCollation, d);
+      }
+      else if (strcmp (*argv, "--construction-mode") == 0)
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --construction-mode option"; break; }
+
+        init_val (*argv, theConstructionMode, d);
       }
       else if (strcmp (*argv, "--ordering-mode") == 0) {
         int d = 2;
         if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; }        init_val (*argv, theOrderingMode, d);
-      }
-      else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --multiple option"; break; }        init_val (*argv, theMultiple, d);
-      }
-      else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --query option"; break; }        init_val (*argv, theQueriesOrFiles, d);
-      }
-      else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0) {
+        if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; }
+
+        init_val (*argv, theOrderingMode, d);
+      }
+      else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL)
+        {
+          result = "No value given for --multiple option"; break;
+        }
+        init_val(*argv, theMultiple, d);
+      }
+      else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL)
+        {
+          result = "No value given for --query option"; break;
+        }
+        init_val (*argv, theQueriesOrFiles, d);
+      }
+      else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0) 
+      {
         theAsFiles = true;
       }
-      else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --external-variable option"; break; }        init_val (*argv, theExternalVariable, d);
-      }
-      else if (strcmp (*argv, "--context-item") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --context-item option"; break; }        init_val (*argv, theContextItem, d);
-      }
-      else if (strcmp (*argv, "--optimization-level") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --optimization-level option"; break; }        init_val (*argv, theOptimizationLevel, d);
-      }
-      else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0) {
+      else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) 
+        {
+          result = "No value given for --external-variable option"; break;
+        }
+        init_val(*argv, theExternalVariable, d);
+      }
+      else if (strcmp (*argv, "--context-item") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) 
+        {
+          result = "No value given for --context-item option"; break;
+        }
+        init_val (*argv, theContextItem, d);
+      }
+      else if (strcmp (*argv, "--optimization-level") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL)
+        {
+          result = "No value given for --optimization-level option"; break;
+        }
+        init_val(*argv, theOptimizationLevel, d);
+      }
+      else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0) 
+      {
         theLibModule = true;
       }
-      else if (strcmp (*argv, "--parse-only") == 0) {
+      else if (strcmp (*argv, "--parse-only") == 0) 
+      {
         theParseOnly = true;
       }
-      else if (strcmp (*argv, "--compile-only") == 0) {
+      else if (strcmp (*argv, "--compile-only") == 0) 
+      {
         theCompileOnly = true;
       }
-      else if (strcmp (*argv, "--no-serializer") == 0) {
+      else if (strcmp (*argv, "--no-serializer") == 0) 
+      {
         theNoSerializer = true;
       }
-      else if (strcmp (*argv, "--debug") == 0 || strncmp (*argv, "-d", 2) == 0) {
+      else if (strcmp (*argv, "--debug") == 0 || strncmp (*argv, "-d", 2) == 0) 
+      {
         theDebug = true;
       }
-      else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --debug-host option"; break; }        init_val (*argv, theDebugHost, d);
-      }
-      else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --debug-port option"; break; }        init_val (*argv, theDebugPort, d);
-      }
-      else if (strcmp (*argv, "--no-logo") == 0) {
+      else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) 
+        {
+          result = "No value given for --debug-host option"; break;
+        }
+        init_val (*argv, theDebugHost, d);
+      }
+      else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) 
+        {
+          result = "No value given for --debug-port option"; break;
+        }
+        init_val (*argv, theDebugPort, d);
+      }
+      else if (strcmp (*argv, "--no-logo") == 0) 
+      {
         theNoLogo = true;
       }
-      else if (strcmp (*argv, "--timeout") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --timeout option"; break; }        init_val (*argv, theTimeout, d);
-      }
-      else if (strcmp (*argv, "--module-path") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --module-path option"; break; }        init_val (*argv, theModulePath, d);
-      }
-      else if (strcmp (*argv, "--option") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --option option"; break; }        init_val (*argv, theOption, d);
-      }
-      else if (strcmp (*argv, "--trailing-nl") == 0) {
+      else if (strcmp (*argv, "--timeout") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --timeout option"; break; }
+        init_val (*argv, theTimeout, d);
+      }
+      else if (strcmp (*argv, "--uri-path") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --uri-path option"; break; }
+        init_val (*argv, theUriPath, d);
+      }
+      else if (strcmp (*argv, "--lib-path") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --lib-path option"; break; }
+        init_val (*argv, theLibPath, d);
+      }
+      else if (strcmp (*argv, "--module-path") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --module-path option"; break; }
+        init_val (*argv, theModulePath, d);
+      }
+      else if (strcmp (*argv, "--classpath") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --classpath option"; break; }
+
+        init_val (*argv, theClasspath, d);
+      }
+      else if (strcmp (*argv, "--option") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --option option"; break; }
+        init_val (*argv, theOption, d);
+      }
+      else if (strcmp (*argv, "--trailing-nl") == 0) 
+      {
         theTrailingNl = true;
       }
-      else if (strcmp (*argv, "--stop-words") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --stop-words option"; break; }        init_val (*argv, theStopWords, d);
-      }
-      else if (strcmp (*argv, "--thesaurus") == 0) {
-        int d = 2;
-        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
-        if (*argv == NULL) { result = "No value given for --thesaurus option"; break; }        init_val (*argv, theThesaurus, d);
-      }
-      else if (strcmp (*argv, "--") == 0) {
+      else if (strcmp (*argv, "--stop-words") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --stop-words option"; break; }
+        init_val (*argv, theStopWords, d);
+      }
+      else if (strcmp (*argv, "--thesaurus") == 0) 
+      {
+        int d = 2;
+        if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
+        if (*argv == NULL) { result = "No value given for --thesaurus option"; break; }
+        init_val (*argv, theThesaurus, d);
+      }
+      else if (strcmp (*argv, "--serialize-plan") == 0 || strncmp (*argv, "-s", 2) == 0)
+      {
+        theSerializePlan = true;
+      }
+      else if (strcmp (*argv, "--compile-plan") == 0)
+      {
+        theSavePlan = true;
+      }
+      else if (strcmp (*argv, "--execute-plan") == 0)
+      {
+        theLoadPlan = true;
+      }
+      else if (strcmp (*argv, "--") == 0)
+      {
         copy_args (++argv);
         break;
-      } else if ((*argv) [0] == '-') {
+      }
+      else if ((*argv) [0] == '-')
+      {
         result = "unknown command line option "; result += *argv; break; 
-      } else {
+      }
+      else
+      {
         copy_args (argv);
         break;
       }
@@ -299,47 +445,55 @@
     return result;
   }
 
-  const char *get_help_msg () const {
+  const char *get_help_msg () const 
+  {
     return
-"--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"
-"--output-file, -o\nWrite the result to the given file.\n\n"
-"--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
-"--serialize-html\nSerialize the result as HTML.\n\n"
-"--serialize-text\nSerialize the result as Text.\n\n"
-"--indent, -i\nIndent output.\n\n"
-"--print-query\nPrint the queries.\n\n"
-"--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
-"--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
-"--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
-"--base-uri\nSet the base URI property of the static context.\n\n"
-"--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
-"--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
-"--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
-"--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
-"--multiple, -m\nExecute the given queries multiple times.\n\n"
-"--query, -q\nQuery test or file URI (file://...)\n\n"
-"--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries.\n\n"
-"--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
-"--context-item\nSet the context item to the XML document in a given file.\n\n"
-"--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
-"--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
-"--parse-only\nStop after parsing the query.\n\n"
-"--compile-only\nOnly compile (don't execute)\n\n"
-"--no-serializer\nDo not serialize (discard) result.\n\n"
-"--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
-"--debug-host, -p\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
-"--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
-"--no-logo\nPrint no logo when starting.\n\n"
-"--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
-"--module-path\nModule paths added to the built-in resolver, i.e. where module imports are looking for modules.\n\n"
-"--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value\n\n";
-"--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
-"--stop-words\nMapping specifying a stop-words URI to another.\n\n"
-"--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
-;
+        "--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"
+        "--output-file, -o\nWrite the result to the given file.\n\n"
+        "--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
+        "--serialize-html\nSerialize the result as HTML.\n\n"
+        "--serialize-text\nSerialize the result as Text.\n\n"
+        "--indent, -i\nIndent output.\n\n"
+        "--print-query\nPrint the queries.\n\n"
+        "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
+        "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
+        "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
+        "--base-uri\nSet the base URI property of the static context.\n\n"
+        "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
+        "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
+        "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
+        "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
+        "--multiple, -m\nExecute the given queries multiple times.\n\n"
+        "--query, -q\nQuery test or file URI (file://...)\n\n"
+        "--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries.\n\n"
+        "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
+        "--context-item\nSet the context item to the XML document in a given file.\n\n"
+        "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
+        "--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
+        "--parse-only\nStop after parsing the query.\n\n"
+        "--compile-only\nOnly compile (don't execute)\n\n"
+        "--no-serializer\nDo not serialize (discard) result.\n\n"
+        "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
+        "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
+        "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
+        "--no-logo\nPrint no logo when starting.\n\n"
+        "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
+        "--uri-path\nURI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n"
+        "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
+        "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
+        "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
+        "--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value\n\n";
+        "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
+        "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
+        "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
+        "--serialize-plan, -s\nSerialize and then load the query execution plan.\n\n"
+        "--compile-plan,\nDo not execute the query; just compile it and save the execution plan in the file specified with the -o option.\n\n"
+        "--execute-plan\nDo not compile the query; instead load the execution plan from the file specified by the -f -q options, and execute the loaded plan.\n\n"
+        ;
   }
 
-  static const ZorbaCMDPropertiesBase *instance () {
+  static const ZorbaCMDPropertiesBase *instance () 
+  {
     static ZorbaCMDPropertiesBase result;
     return &result;
   }

=== modified file 'cmake_modules/CMakeLists.txt'
--- cmake_modules/CMakeLists.txt	2011-06-16 19:30:58 +0000
+++ cmake_modules/CMakeLists.txt	2012-09-27 18:04:43 +0000
@@ -12,10 +12,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-INSTALL(FILES ZorbaModule.cmake
-  DESTINATION share/zorba-${ZORBA_VERSION}/cmake)
+INSTALL(FILES ZorbaModule.cmake DESTINATION "${ZORBA_CMAKE_DIR}")
 
 # Install Windows/ProxyFindModule.cmake for use of Module
-INSTALL(FILES
-  "${CMAKE_CURRENT_SOURCE_DIR}/Windows/ProxyFindModule.cmake" 
-  DESTINATION share/zorba-${ZORBA_VERSION}/cmake/Windows)
\ No newline at end of file
+IF(WIN32)
+  INSTALL(FILES
+    "${CMAKE_CURRENT_SOURCE_DIR}/Windows/ProxyFindModule.cmake" 
+    DESTINATION "${ZORBA_CMAKE_DIR}/Windows")
+ENDIF(WIN32)
+
+#creates file used for configuration of CPACK for external modules.
+FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake)
\ No newline at end of file

=== modified file 'cmake_modules/CMakeUseDoxygen.cmake'
--- cmake_modules/CMakeUseDoxygen.cmake	2011-03-01 22:14:39 +0000
+++ cmake_modules/CMakeUseDoxygen.cmake	2012-09-27 18:04:43 +0000
@@ -1,3 +1,19 @@
+# Copyright 2006-2011 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.
+#
+#
+#
 # -helper macro to add a "doc" target with CMake build system. 
 # and configure doxy.config.in to doxy.config
 #
@@ -22,7 +38,7 @@
   IF (DOXYGEN_FOUND)
     # the FindDoxygen module doesn't set DOXYGEN_DOT_FOUND like it is
     # supposed to, so here we have a workaround.
-    IF ( DOXYGEN_DOT_EXECUTABLE )
+    IF (DOXYGEN_DOT_EXECUTABLE)
 
       FIND_PROGRAM(DOXYGEN_DOT_EXECUTABLE_PATH
         NAMES dot
@@ -38,111 +54,117 @@
           DOC "Graphviz Dot tool for using Doxygen"
       )
 
-      IF(DOXYGEN_DOT_EXECUTABLE)
-        SET(DOXYGEN_DOT_FOUND "YES")
-        # The Doxyfile wants the path to Dot, not the entire path and executable
-        GET_FILENAME_COMPONENT(DOXYGEN_DOT_PATH "${DOXYGEN_DOT_EXECUTABLE}" PATH CACHE)
-      ENDIF()
+      SET(DOXYGEN_DOT_FOUND "YES")
+      # The Doxyfile wants the path to Dot, not the entire path and executable
+      GET_FILENAME_COMPONENT(DOXYGEN_DOT_PATH "${DOXYGEN_DOT_EXECUTABLE}" PATH CACHE)
 
-    ENDIF ( DOXYGEN_DOT_EXECUTABLE )
+    ENDIF (DOXYGEN_DOT_EXECUTABLE)
 
     # click+jump in Emacs and Visual Studio (for doxy.config) (jw)
-    IF    (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
+    IF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
       SET(DOXY_WARN_FORMAT "\"$file($line) : $text \"")
-    ELSE  (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
+    ELSE (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
       SET(DOXY_WARN_FORMAT "\"$file:$line: $text \"")
     ENDIF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
 
     # we need latex for doxygen because of the formulas
-    FIND_PACKAGE(LATEX)
-    IF    (NOT LATEX_COMPILER)
+    FIND_PACKAGE (LATEX)
+    IF (NOT LATEX_COMPILER)
       MESSAGE(STATUS "latex command LATEX_COMPILER not found but usually required. You will probably get warnings and user inetraction on doxy run.")
     ENDIF (NOT LATEX_COMPILER)
-    IF    (NOT MAKEINDEX_COMPILER)
-      MESSAGE(STATUS "makeindex command MAKEINDEX_COMPILER not found but usually required.")
+    IF (NOT MAKEINDEX_COMPILER)
+      MESSAGE (STATUS "makeindex command MAKEINDEX_COMPILER not found but usually required.")
     ENDIF (NOT MAKEINDEX_COMPILER)
-    IF    (NOT DVIPS_CONVERTER)
-      MESSAGE(STATUS "dvips command DVIPS_CONVERTER not found but usually required.")
+    IF (NOT DVIPS_CONVERTER)
+      MESSAGE (STATUS "dvips command DVIPS_CONVERTER not found but usually required.")
     ENDIF (NOT DVIPS_CONVERTER)
 
-    IF   (EXISTS "${DOXYGEN_SOURCE}/doxy.config.in")
-      MESSAGE(STATUS "configured ${DOXYGEN_SOURCE}/doxy.config.in --> ${DOXYGEN_BINARY}/doxy.config")
-      CONFIGURE_FILE(${DOXYGEN_SOURCE}/doxy.config.in 
+    IF (EXISTS "${DOXYGEN_SOURCE}/doxy.config.in")
+      MESSAGE (STATUS "configured ${DOXYGEN_SOURCE}/doxy.config.in --> ${DOXYGEN_BINARY}/doxy.config")
+      CONFIGURE_FILE (
+        ${DOXYGEN_SOURCE}/doxy.config.in 
         ${DOXYGEN_BINARY}/doxy.config
-        @ONLY )
+        @ONLY
+      )
       # use (configured) doxy.config from (out of place) BUILD tree:
-      SET(DOXY_CONFIG "${DOXYGEN_BINARY}/doxy.config")
+      SET (DOXY_CONFIG "${DOXYGEN_BINARY}/doxy.config")
     ELSE (EXISTS "${DOXYGEN_SOURCE}/doxy.config.in")
       # use static hand-edited doxy.config from SOURCE tree:
-      SET(DOXY_CONFIG "${DOXYGEN_SOURCE}/doxy.config")
-      IF   (EXISTS "${DOXYGEN_SOURCE}/doxy.config")
-        MESSAGE(STATUS "WARNING: using existing ${DOXYGEN_SOURCE}/doxy.config instead of configuring from doxy.config.in file.")
+      SET (DOXY_CONFIG "${DOXYGEN_SOURCE}/doxy.config")
+      IF (EXISTS "${DOXYGEN_SOURCE}/doxy.config")
+        MESSAGE (STATUS "WARNING: using existing ${DOXYGEN_SOURCE}/doxy.config instead of configuring from doxy.config.in file.")
       ELSE (EXISTS "${DOXYGEN_SOURCE}/doxy.config")
-        IF   (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
+        IF (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
           # using template doxy.config.in
-          MESSAGE(STATUS "configured ${CMAKE_CMAKE_MODULE_PATH}/doxy.config.in --> ${DOXYGEN_BINARY}/doxy.config")
-          CONFIGURE_FILE(${CMAKE_MODULE_PATH}/doxy.config.in 
+          MESSAGE (STATUS "configured ${CMAKE_CMAKE_MODULE_PATH}/doxy.config.in --> ${DOXYGEN_BINARY}/doxy.config")
+          CONFIGURE_FILE (
+            ${CMAKE_MODULE_PATH}/doxy.config.in 
             ${DOXYGEN_BINARY}/doxy.config
-            @ONLY )
-          SET(DOXY_CONFIG "${DOXYGEN_BINARY}/doxy.config")
+            @ONLY
+          )
+          SET (DOXY_CONFIG "${DOXYGEN_BINARY}/doxy.config")
         ELSE (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
           # failed completely...
-          MESSAGE(SEND_ERROR "Please create ${DOXYGEN_SOURCE}/doxy.config.in (or doxy.config as fallback)")
-        ENDIF(EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
-
-      ENDIF(EXISTS "${DOXYGEN_SOURCE}/doxy.config")
-    ENDIF(EXISTS "${DOXYGEN_SOURCE}/doxy.config.in")
-
-    SET(DOXY_CONFIG_NATIVE)
-    FILE(TO_NATIVE_PATH ${DOXY_CONFIG} DOXY_CONFIG_NATIVE)
-    ADD_CUSTOM_TARGET("${DOXYGEN_TARGET_NAME}" "${DOXYGEN_EXECUTABLE}" "${DOXY_CONFIG_NATIVE}")
+          MESSAGE (SEND_ERROR "Please create ${DOXYGEN_SOURCE}/doxy.config.in (or doxy.config as fallback)")
+        ENDIF (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
+
+      ENDIF (EXISTS "${DOXYGEN_SOURCE}/doxy.config")
+    ENDIF (EXISTS "${DOXYGEN_SOURCE}/doxy.config.in")
+
+    SET (DOXY_CONFIG_NATIVE)
+    FILE (TO_NATIVE_PATH ${DOXY_CONFIG} DOXY_CONFIG_NATIVE)
+    ADD_CUSTOM_TARGET (${DOXYGEN_TARGET_NAME} "${DOXYGEN_EXECUTABLE}" "${DOXY_CONFIG_NATIVE}")
+    SET_TARGET_PROPERTIES(${DOXYGEN_TARGET_NAME} PROPERTIES
+      FOLDER "Docs"
+    )
 
     # create a windows help .chm file using hhc.exe
     # HTMLHelp DLL must be in path!
     # fallback: use hhw.exe interactively
-    IF    (WIN32)
-      FIND_PACKAGE(HTMLHelp)
-      IF   (HTML_HELP_COMPILER)      
+    IF (WIN32)
+      FIND_PACKAGE (HTMLHelp)
+      IF (HTML_HELP_COMPILER)      
         SET (TMP "${DOXYGEN_BINARY}\\Doc\\html\\index.hhp")
-        STRING(REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} )
-        # MESSAGE(SEND_ERROR "DBG  HHP_FILE=${HHP_FILE}")
-        ADD_CUSTOM_TARGET(winhelp_${DOXYGEN_TARGET_NAME} ${HTML_HELP_COMPILER} ${HHP_FILE})
+        STRING (REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} )
+        ADD_CUSTOM_TARGET (winhelp_${DOXYGEN_TARGET_NAME} ${HTML_HELP_COMPILER} ${HHP_FILE})
         ADD_DEPENDENCIES (winhelp_${DOXYGEN_TARGET_NAME} ${DOXYGEN_TARGET_NAME})
+        SET_TARGET_PROPERTIES(winhelp_${DOXYGEN_TARGET_NAME} PROPERTIES
+          FOLDER "Docs"
+        )
 
         IF (NOT TARGET_DOC_SKIP_INSTALL)
         # install windows help?
         # determine useful name for output file 
         # should be project and version unique to allow installing 
         # multiple projects into one global directory      
-        IF   (EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
-          IF   (PROJECT_NAME)
-            SET(OUT "${PROJECT_NAME}")
+        IF (EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
+          IF (PROJECT_NAME)
+            SET (OUT "${PROJECT_NAME}")
           ELSE (PROJECT_NAME)
-            SET(OUT "Documentation") # default
-          ENDIF(PROJECT_NAME)
-          IF   (${PROJECT_NAME}_VERSION_MAJOR)
-            SET(OUT "${OUT}-${${PROJECT_NAME}_VERSION_MAJOR}")
-            IF   (${PROJECT_NAME}_VERSION_MINOR)
-              SET(OUT  "${OUT}.${${PROJECT_NAME}_VERSION_MINOR}")
-              IF   (${PROJECT_NAME}_VERSION_PATCH)
+            SET (OUT "Documentation") # default
+          ENDIF (PROJECT_NAME)
+          IF (${PROJECT_NAME}_VERSION_MAJOR)
+            SET (OUT "${OUT}-${${PROJECT_NAME}_VERSION_MAJOR}")
+            IF (${PROJECT_NAME}_VERSION_MINOR)
+              SET (OUT  "${OUT}.${${PROJECT_NAME}_VERSION_MINOR}")
+              IF (${PROJECT_NAME}_VERSION_PATCH)
                 SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_PATCH}")      
-              ENDIF(${PROJECT_NAME}_VERSION_PATCH)
-            ENDIF(${PROJECT_NAME}_VERSION_MINOR)
-          ENDIF(${PROJECT_NAME}_VERSION_MAJOR)
+              ENDIF (${PROJECT_NAME}_VERSION_PATCH)
+            ENDIF (${PROJECT_NAME}_VERSION_MINOR)
+          ENDIF (${PROJECT_NAME}_VERSION_MAJOR)
           # keep suffix
-          SET(OUT  "${OUT}.chm")
+          SET (OUT  "${OUT}.chm")
 
-          #MESSAGE("DBG ${PROJECT_BINARY_DIR}/Doc/html/index.chm \n${OUT}")
           # create target used by install and package commands 
-          INSTALL(FILES "${PROJECT_BINARY_DIR}/Doc/html/index.chm"
+          INSTALL (
+            FILES "${PROJECT_BINARY_DIR}/Doc/html/index.chm"
             DESTINATION "doc"
             RENAME "${OUT}"
           )
-        ENDIF(EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
-        ENDIF(NOT TARGET_DOC_SKIP_INSTALL)
+        ENDIF (EXISTS "${PROJECT_BINARY_DIR}/Doc/html/index.chm")
+        ENDIF (NOT TARGET_DOC_SKIP_INSTALL)
 
-      ENDIF(HTML_HELP_COMPILER)
-      # MESSAGE(SEND_ERROR "HTML_HELP_COMPILER=${HTML_HELP_COMPILER}")
+      ENDIF (HTML_HELP_COMPILER)
     ENDIF (WIN32) 
-  ENDIF(DOXYGEN_FOUND)
+  ENDIF (DOXYGEN_FOUND)
 ENDMACRO (ZORBA_DOXYGEN)

=== modified file 'cmake_modules/CMakeUseFlex.cmake'
--- cmake_modules/CMakeUseFlex.cmake	2010-01-28 10:56:47 +0000
+++ cmake_modules/CMakeUseFlex.cmake	2012-09-27 18:04:43 +0000
@@ -39,15 +39,22 @@
     # Extract major and minor versions
     STRING (REGEX REPLACE "[^0-9]*([0-9]+)..*" "\\1" FLEX_MAJOR_VERSION_TMP ${FLEX_VERSION})
     STRING (REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+).*" "\\1" FLEX_MINOR_VERSION_TMP ${FLEX_VERSION})
-	STRING (REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+[a-z]*).*" "\\1" FLEX_REVISION_VERSION_TMP ${FLEX_VERSION})	
+    STRING (REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+[a-z]*).*" "\\1" FLEX_REVISION_VERSION_TMP ${FLEX_VERSION})
     MESSAGE(STATUS "Found flex -- ${FLEX_EXECUTABLE}, version: " ${FLEX_MAJOR_VERSION_TMP} "." ${FLEX_MINOR_VERSION_TMP} "." ${FLEX_REVISION_VERSION_TMP})
     SET (FLEX_MAJOR_VERSION ${FLEX_MAJOR_VERSION_TMP} CACHE STRING "The flex major version" FORCE)
     SET (FLEX_MINOR_VERSION ${FLEX_MINOR_VERSION_TMP} CACHE STRING "The flex minor version" FORCE)
-	SET (FLEX_REVISION_VERSION ${FLEX_REVISION_VERSION_TMP} CACHE STRING "The flex revision version" FORCE)
+    SET (FLEX_REVISION_VERSION ${FLEX_REVISION_VERSION_TMP} CACHE STRING "The flex revision version" FORCE)
+
+    # Find the FlexLexer.h header. Try our best to find the one associated
+    # with the flex binary we're actually using.
+    GET_FILENAME_COMPONENT(_flex_path "${FLEX_EXECUTABLE}" PATH)
+    GET_FILENAME_COMPONENT(_flex_hint "${_flex_path}/../include" ABSOLUTE)
+    FIND_PATH(FLEX_INCLUDE_DIR FlexLexer.h HINTS "${_flex_hint}")
+
   ELSE (FLEX_EXECUTABLE)
     SET (FLEX_MAJOR_VERSION "0")
     SET (FLEX_MINOR_VERSION "0")
-	  SET (FLEX_REVISION_VERSION "0")
+    SET (FLEX_REVISION_VERSION "0")
   ENDIF(FLEX_EXECUTABLE)
   SET (FLEX_VERSION_FULL ${FLEX_MAJOR_VERSION}.${FLEX_MINOR_VERSION}.${FLEX_REVISION_VERSION} CACHE STRING "The Flex version" FORCE)
 ENDIF(NOT FLEX_EXECUTABLE)
@@ -63,15 +70,26 @@
     ELSE(FLEX_PREFIX_OUTPUTS)
       SET(PREFIX "yy")
     ENDIF(FLEX_PREFIX_OUTPUTS)
+    # If we regenerate the scanner, be sure to copy the corresponding
+    # FlexLexer.h as well. Put it in the top-level src/ directory since
+    # that path is on the include-directories list; also, that way
+    # multiple flex'd files will all share the include file.
+    SET(FLEXLEXERH "${CMAKE_CURRENT_BINARY_DIR}/FlexLexer.h")
+    ADD_CUSTOM_COMMAND(
+      OUTPUT "${FLEXLEXERH}"
+      COMMAND "${CMAKE_COMMAND}"
+      ARGS -E copy_if_different
+         "${FLEX_INCLUDE_DIR}/FlexLexer.h"
+         "${FLEXLEXERH}")
     SET(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/${PATH}/${PREFIX}.cpp")
     ADD_CUSTOM_COMMAND(
       OUTPUT "${OUTFILE}"
       COMMAND "${FLEX_EXECUTABLE}"
-      ARGS -t 
-	  "--debug"
-      "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
-      > ${OUTFILE}
-      DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
+      ARGS -t --debug "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
+      # flex's --outfile doesn't seem to work right, so redirect stdout
+          > "${OUTFILE}"
+      DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
+         "${FLEXLEXERH}")
     SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" PROPERTIES GENERATED TRUE)
   ENDMACRO(FLEX_FILE)
 ENDIF(FLEX_EXECUTABLE)

=== modified file 'cmake_modules/FindICU.cmake'
--- cmake_modules/FindICU.cmake	2011-03-06 16:49:30 +0000
+++ cmake_modules/FindICU.cmake	2012-09-27 18:04:43 +0000
@@ -28,6 +28,8 @@
 #                       (note: in addition to ICU_LIBRARIES)
 #  ICU_DATA_LIBRARIES - Libraries to link against for ICU data
 #
+#  ICU_VERSION        - ICU's version number.
+#
 
 # Look for the header file.
 find_path(
@@ -51,6 +53,49 @@
   MESSAGE(STATUS "Could not find ICU library")
 endif (ICU_LIBRARY)
 
+# Discover the version.
+IF (NOT ICU_INCLUDE STREQUAL "")
+  # ICU 3.x has the relevant #defines in uversion.h; 4.x uses uvernum.h.
+  FIND_PATH(ICUVERHPPPATH NAMES unicode/uvernum.h unicode/uversion.h
+    PATHS ${ICU_INCLUDE} NO_DEFAULT_PATH)
+
+  IF ( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
+    SET(ICU_VERSION "0")
+    MESSAGE(STATUS "Found ICU but unable to determine version - assuming version 0")
+  ELSE( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
+    SET (ICUVERHPP)
+    # One of these files has to exist, or else ICUVERHPPPATH wouldn't be set.
+    # If uvernum.h exists, it has the data we want; otherwise, that data is
+    # in uversion.h.
+    FOREACH (header uvernum.h uversion.h)
+      SET (headerfile "${ICUVERHPPPATH}/unicode/${header}")
+      IF (EXISTS "${headerfile}")
+	FILE(READ "${headerfile}" ICUVERHPP)
+	BREAK()
+      ENDIF (EXISTS "${headerfile}")
+    ENDFOREACH (header)
+
+    STRING(REGEX MATCH "\n *#define U_ICU_VERSION_MAJOR_NUM +[0-9]+" ICUVERMAJ 
+      ${ICUVERHPP}) 
+    STRING(REGEX MATCH "\n *#define U_ICU_VERSION_MINOR_NUM +[0-9]+" ICUVERMIN 
+      ${ICUVERHPP})
+    STRING(REGEX
+      MATCH "\n *#define U_ICU_VERSION_PATCHLEVEL_NUM +[0-9]+" ICUVERPATCH 
+      ${ICUVERHPP})
+  
+    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_MAJOR_NUM +" "" 
+      ICUVERMAJ ${ICUVERMAJ})
+    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_MINOR_NUM +" "" 
+      ICUVERMIN ${ICUVERMIN})
+    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_PATCHLEVEL_NUM +" "" 
+      ICUVERPATCH ${ICUVERPATCH})
+  
+    SET(ICU_VERSION ${ICUVERMAJ}.${ICUVERMIN}.${ICUVERPATCH})
+    MESSAGE(STATUS "ICU Version: ${ICU_VERSION}")
+  
+  ENDIF ( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
+ENDIF (NOT ICU_INCLUDE STREQUAL "")
+
 
 # Copy the results to the output variables.
 if(ICU_INCLUDE AND ICU_LIBRARY)
@@ -107,4 +152,5 @@
   set(ICU_I18N_LIBRARIES)
   set(ICU_DATA_LIBRARIES)
   set(ICU_INCLUDE_DIRS)
+  set(ICU_VERSION 0)
 endif(ICU_INCLUDE AND ICU_LIBRARY)

=== modified file 'cmake_modules/FindJNI.cmake'
--- cmake_modules/FindJNI.cmake	2010-12-10 21:14:42 +0000
+++ cmake_modules/FindJNI.cmake	2012-09-27 18:04:43 +0000
@@ -101,6 +101,12 @@
   ${_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
@@ -113,7 +119,6 @@
   /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}
@@ -137,6 +142,9 @@
   "[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
@@ -233,6 +241,7 @@
   ${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
@@ -259,14 +268,19 @@
   JAVA_INCLUDE_PATH2
 )
 
-SET(JNI_LIBRARIES
-  ${JAVA_AWT_LIBRARY}
-  ${JAVA_JVM_LIBRARY}
-)
-
-SET(JNI_INCLUDE_DIRS
-  ${JAVA_INCLUDE_PATH}
-  ${JAVA_INCLUDE_PATH2}
-  ${JAVA_AWT_INCLUDE_PATH}
-)
-
+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 file 'cmake_modules/FindLibedit.cmake'
--- cmake_modules/FindLibedit.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/FindLibedit.cmake	2012-09-27 18:04:43 +0000
@@ -0,0 +1,46 @@
+# Copyright 2011 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 libedit library
+#
+# Once done this will define
+#
+#  LIBEDIT_FOUND        - True if libedit library is found
+#  LIBEDIT_INCLUDE_DIRS - Directory to include to get libedit headers
+#  LIBEDIT_LIBRARIES    - Libraries to link against for the libedit library
+#
+
+FIND_PATH (
+  LIBEDIT_INCLUDE
+  editline/readline.h
+  PATHS ${LIBEDIT_INCLUDE_DIR} /usr/include /usr/local/include
+)
+MESSAGE(STATUS ${LIBEDIT_INCLUDE})
+
+FIND_LIBRARY (
+  LIBEDIT_LIBRARY
+  NAMES edit
+  PATHS ${LIBEDIT_LIBRARY_DIR} /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
+) 
+MESSAGE(STATUS ${LIBEDIT_LIBRARY})
+
+SET (LIBEDIT_INCLUDE_DIRS ${LIBEDIT_INCLUDE})
+SET (LIBEDIT_LIBRARIES ${LIBEDIT_LIBRARY})
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS (
+  Libedit
+  DEFAULT_MSG
+  LIBEDIT_INCLUDE LIBEDIT_LIBRARY
+)
+

=== modified file 'cmake_modules/FindPHP5.cmake'
--- cmake_modules/FindPHP5.cmake	2011-06-23 15:42:53 +0000
+++ cmake_modules/FindPHP5.cmake	2012-09-27 18:04:43 +0000
@@ -97,6 +97,14 @@
     _zend_rsrc_list_get_rsrc_type
     _zend_wrong_param_count
     _zval_used_for_init
+    _zval_is_true
+    _zend_lookup_class
+    __object_init
+    __zend_hash_add_or_update
+    _php_strtolower
+    _executor_globals
+    _call_user_function
+    _php_sprintf
     )
     SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
       "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS},-U,${symbol}")
@@ -144,7 +152,11 @@
 SET(PHP5_INCLUDES ${PHP5_INCLUDE_DIR})
 #SET(PHP5_EXTENSION_DIR "" CACHE PATH "Path to the ext subdir in binary PHP5")
 ENDIF (NOT WIN32 OR CYGWIN)
-
+ 
+IF(NOT PHP5_INCLUDE_DIR )
+  SET (PHP5_INCLUDE_DIR ${CMAKE_PREFIX_PATH})
+ENDIF(NOT PHP5_INCLUDE_DIR )
+ 
 set(PHP5_MAIN_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/main)
 set(PHP5_TSRM_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/TSRM)
 set(PHP5_ZEND_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/Zend)

=== added file 'cmake_modules/FindPythonLibs.cmake'
--- cmake_modules/FindPythonLibs.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/FindPythonLibs.cmake	2012-09-27 18:04:43 +0000
@@ -0,0 +1,195 @@
+# - Find python libraries
+# This module finds if Python 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:
+#
+#  PYTHONLIBS_FOUND           - have the Python libs been found
+#  PYTHON_LIBRARIES           - path to the python library
+#  PYTHON_INCLUDE_PATH        - path to where Python.h is found (deprecated)
+#  PYTHON_INCLUDE_DIRS        - path to where Python.h is found
+#  PYTHON_DEBUG_LIBRARIES     - path to the debug library
+#  Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for
+
+#=============================================================================
+# 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.)
+
+INCLUDE(CMakeFindFrameworks)
+# Search for the python framework on Apple.
+CMAKE_FIND_FRAMEWORKS(Python)
+
+# Set up the versions we know about, in the order we will search. Always add
+# the user supplied additional versions to the front.
+set(_Python_VERSIONS
+  ${Python_ADDITIONAL_VERSIONS}
+  2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5)
+
+FOREACH(_CURRENT_VERSION ${_Python_VERSIONS})
+  STRING(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})
+  IF(WIN32)
+    FIND_LIBRARY(PYTHON_DEBUG_LIBRARY
+      NAMES python${_CURRENT_VERSION_NO_DOTS}_d python
+      PATHS
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs )
+  ENDIF(WIN32)
+
+  FIND_LIBRARY(PYTHON_LIBRARY
+    NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
+    PATHS
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
+    # Avoid finding the .dll in the PATH.  We want the .lib.
+    NO_SYSTEM_ENVIRONMENT_PATH
+  )
+  # Look for the static library in the Python config directory
+  FIND_LIBRARY(PYTHON_LIBRARY
+    NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
+    # Avoid finding the .dll in the PATH.  We want the .lib.
+    NO_SYSTEM_ENVIRONMENT_PATH
+    # This is where the static library is usually located
+    PATH_SUFFIXES python${_CURRENT_VERSION}/config libs
+  )
+
+  # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if
+  # PYTHON_INCLUDE_DIR is not set.
+  IF(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR)
+    SET(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH
+      "Path to where Python.h is found" FORCE)
+  ENDIF(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR)
+
+  SET(PYTHON_FRAMEWORK_INCLUDES)
+  IF(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR)
+    FOREACH(dir ${Python_FRAMEWORKS})
+      SET(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES}
+        ${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION})
+    ENDFOREACH(dir)
+  ENDIF(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR)
+
+  FIND_PATH(PYTHON_INCLUDE_DIR
+    NAMES Python.h
+    PATHS
+      ${PYTHON_FRAMEWORK_INCLUDES}
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
+    PATH_SUFFIXES
+      python${_CURRENT_VERSION}
+  )
+
+  # For backward compatibility, set PYTHON_INCLUDE_PATH, but make it internal.
+  SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL
+    "Path to where Python.h is found (deprecated)")
+
+ENDFOREACH(_CURRENT_VERSION)
+
+MARK_AS_ADVANCED(
+  PYTHON_DEBUG_LIBRARY
+  PYTHON_LIBRARY
+  PYTHON_INCLUDE_DIR
+)
+
+# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the
+# cache entries because they are meant to specify the location of a single
+# library. We now set the variables listed by the documentation for this
+# module.
+SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
+SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
+SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
+
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
+
+
+# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
+# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
+# in your sources to initialize the static python modules
+FUNCTION(PYTHON_ADD_MODULE _NAME )
+  GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS
+    GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
+  OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
+  OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED
+    "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
+
+  # Mark these options as advanced
+  MARK_AS_ADVANCED(PYTHON_ENABLE_MODULE_${_NAME}
+    PYTHON_MODULE_${_NAME}_BUILD_SHARED)
+
+  IF(PYTHON_ENABLE_MODULE_${_NAME})
+    IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
+      SET(PY_MODULE_TYPE MODULE)
+    ELSE(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
+      SET(PY_MODULE_TYPE STATIC)
+      SET_PROPERTY(GLOBAL  APPEND  PROPERTY  PY_STATIC_MODULES_LIST ${_NAME})
+    ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
+
+    SET_PROPERTY(GLOBAL  APPEND  PROPERTY  PY_MODULES_LIST ${_NAME})
+    ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN})
+#    TARGET_LINK_LIBRARIES(${_NAME} ${PYTHON_LIBRARIES})
+
+    IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
+      SET_TARGET_PROPERTIES(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
+      IF(WIN32 AND NOT CYGWIN)
+        SET_TARGET_PROPERTIES(${_NAME} PROPERTIES SUFFIX ".pyd")
+      ENDIF(WIN32 AND NOT CYGWIN)
+    ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
+
+  ENDIF(PYTHON_ENABLE_MODULE_${_NAME})
+ENDFUNCTION(PYTHON_ADD_MODULE)
+
+FUNCTION(PYTHON_WRITE_MODULES_HEADER _filename)
+
+  GET_PROPERTY(PY_STATIC_MODULES_LIST  GLOBAL  PROPERTY PY_STATIC_MODULES_LIST)
+
+  GET_FILENAME_COMPONENT(_name "${_filename}" NAME)
+  STRING(REPLACE "." "_" _name "${_name}")
+  STRING(TOUPPER ${_name} _nameUpper)
+  SET(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename})
+
+  SET(_filenameTmp "${_filename}.in")
+  FILE(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n")
+  FILE(APPEND ${_filenameTmp}
+"#ifndef ${_nameUpper}
+#define ${_nameUpper}
+
+#include <Python.h>
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif /* __cplusplus */
+
+")
+
+  FOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
+    FILE(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n")
+  ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
+
+  FILE(APPEND ${_filenameTmp}
+"#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+")
+
+
+  FOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
+    FILE(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n  static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n")
+  ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
+
+  FILE(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n")
+  FOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
+    FILE(APPEND ${_filenameTmp} "  ${_name}_${_currentModule}();\n")
+  ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
+  FILE(APPEND ${_filenameTmp} "}\n\n")
+  FILE(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n  ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n")
+
+# with CONFIGURE_FILE() cmake complains that you may not use a file created using FILE(WRITE) as input file for CONFIGURE_FILE()
+  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET)
+
+ENDFUNCTION(PYTHON_WRITE_MODULES_HEADER)

=== modified file 'cmake_modules/GenZorbaRuntime.cmake'
--- cmake_modules/GenZorbaRuntime.cmake	2011-06-24 17:59:32 +0000
+++ cmake_modules/GenZorbaRuntime.cmake	2012-09-27 18:04:43 +0000
@@ -21,7 +21,7 @@
 #  extvars: List of external variables to bind (-e args to zorba)
 #  files: List of files to bind to $files in query
 #  gen_file: Full path to generated file (in binary dir)
-#  ZORBA_EXE: Full path of ZORBA_EXE_SCRIPT
+#  ZORBA_EXE: Full path of ZORBA_EXE
 #  binary_dir: Full path of CMAKE_BINARY_DIR
 #  source_dir: Full path of CMAKE_SOURCE_DIR
 

=== modified file 'cmake_modules/VCProject.vcproj.in'
--- cmake_modules/VCProject.vcproj.in	2010-04-01 09:28:23 +0000
+++ cmake_modules/VCProject.vcproj.in	2012-09-27 18:04:43 +0000
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="Windows-1252"?>
+<!--
+:: 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.
+::
+-->
   <VisualStudioUserFile>
     <Configurations>
         <Configuration

=== added file 'cmake_modules/Windows/FindCSharp.cmake'
--- cmake_modules/Windows/FindCSharp.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/Windows/FindCSharp.cmake	2012-09-27 18:04:43 +0000
@@ -0,0 +1,90 @@
+# 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.
+
+FILE(TO_CMAKE_PATH "$ENV{WINDIR}" windir)
+SET(framework_version "$ENV{FrameworkVersion}")
+
+SET(csc_search_paths
+  "${windir}/Microsoft.NET/Framework/v2.0.50727"
+  "${windir}/Microsoft.NET/Framework/v3.5"
+  "${windir}/Microsoft.NET/Framework/v3.0"
+  )
+
+IF(CMAKE_GENERATOR MATCHES "Visual Studio 9 2008")
+  SET(csc_search_paths
+    "${windir}/Microsoft.NET/Framework/v3.5"
+    "${windir}/Microsoft.NET/Framework/v3.0"
+    "${windir}/Microsoft.NET/Framework/v2.0.50727"
+    )
+ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 9 2008")
+
+IF(CMAKE_GENERATOR MATCHES "Visual Studio 10")
+  SET(csc_search_paths
+    "${windir}/Microsoft.NET/Framework/v4.0.30128"
+    "${windir}/Microsoft.NET/Framework/v3.5"
+    "${windir}/Microsoft.NET/Framework/v3.0"
+    "${windir}/Microsoft.NET/Framework/v2.0.50727"
+    )
+ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 10")
+
+FIND_PROGRAM(csc_EXECUTABLE "csc"
+  ${csc_search_paths}
+  "${windir}/Microsoft.NET/Framework/${framework_version}"
+  "${windir}/Microsoft.NET/Framework/v1.1.4322"
+  "${windir}/Microsoft.NET/Framework/v1.0.3705"
+  NO_DEFAULT_PATH
+  )
+
+IF(NOT csc_EXECUTABLE)
+  FIND_PROGRAM(csc_EXECUTABLE NAMES "csc" "gmcs")
+ENDIF(NOT csc_EXECUTABLE)
+
+FIND_PROGRAM(mono_EXECUTABLE "mono")
+
+GET_FILENAME_COMPONENT(csc_DIR "${csc_EXECUTABLE}" PATH)
+
+SET(CSC_ACCEPTS_PLATFORM_FLAG 0)
+SET(CSC_COMPILES_PARTIAL_CLASSES 0)
+
+IF(csc_EXECUTABLE)
+  EXECUTE_PROCESS(COMMAND "${csc_EXECUTABLE}" "/?" OUTPUT_VARIABLE CSC_HELP)
+
+  IF("${CSC_HELP}" MATCHES "/platform:<string>")
+    SET(CSC_ACCEPTS_PLATFORM_FLAG 1)
+    SET(CSC_COMPILES_PARTIAL_CLASSES 1)
+  ENDIF("${CSC_HELP}" MATCHES "/platform:<string>")
+ENDIF(csc_EXECUTABLE)
+
+IF(NOT DEFINED CSC_PLATFORM_FLAG)
+  SET(CSC_PLATFORM_FLAG "")
+  IF(CSC_ACCEPTS_PLATFORM_FLAG)
+    SET(CSC_PLATFORM_FLAG "/platform:x86")
+    IF("${CMAKE_SIZEOF_VOID_P}" GREATER 4)
+      SET(CSC_PLATFORM_FLAG "/platform:x64")
+    ENDIF("${CMAKE_SIZEOF_VOID_P}" GREATER 4)
+  ENDIF(CSC_ACCEPTS_PLATFORM_FLAG)
+ENDIF(NOT DEFINED CSC_PLATFORM_FLAG)
+
+IF(NOT DEFINED CSC_DEBUG_FLAG)
+  SET(CSC_DEBUG_FLAG "")
+  IF("${CMAKE_BUILD_TYPE}" MATCHES "Debug|RelWithDebInfo")
+    SET(CSC_DEBUG_FLAG "/debug")
+  ENDIF("${CMAKE_BUILD_TYPE}" MATCHES "Debug|RelWithDebInfo")
+  IF("${BUILDNAME}" MATCHES "Debug|RelWithDebInfo")
+    SET(CSC_DEBUG_FLAG "/debug")
+  ENDIF("${BUILDNAME}" MATCHES "Debug|RelWithDebInfo")
+  IF("${CMAKE_BINARY_DIR}" MATCHES "Debug|RelWithDebInfo")
+    SET(CSC_DEBUG_FLAG "/debug")
+  ENDIF("${CMAKE_BINARY_DIR}" MATCHES "Debug|RelWithDebInfo")
+ENDIF(NOT DEFINED CSC_DEBUG_FLAG)

=== modified file 'cmake_modules/Windows/FindCURL.cmake'
--- cmake_modules/Windows/FindCURL.cmake	2011-06-23 21:51:47 +0000
+++ cmake_modules/Windows/FindCURL.cmake	2012-09-27 18:04:43 +0000
@@ -27,14 +27,33 @@
 #
 # See the FindCURL.cmake module shipped with CMake for more information.
 
-FIND_PACKAGE_WIN32(CURL CURL_FOUND curl)
+FIND_PACKAGE_WIN32(NAME "CURL" FOUND_VAR "CURL_FOUND" SEARCH_NAMES "curl")
 
 IF (CURL_FOUND)
 
-  # find the needed DLL's
-  FIND_PACKAGE_DLLS_WIN32 (${FOUND_LOCATION} "curllib.dll;libeay32.dll;openldap.dll;ssleay32.dll")
-
-  # find additional DLL's
-  FIND_DLL_WIN32 (libsasl.dll)
+  IF (EXISTS "${FOUND_LOCATION}/curl.exe")
+
+    MESSAGE (STATUS "Found CURL binary distribution")
+
+    # find the needed DLL's
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "libcurl" "curllib")
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "libeay32")
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "openldap")
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "ssleay32")
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "libsasl")
+
+  ELSE (EXISTS "${FOUND_LOCATION}/curl.exe")
+
+    MESSAGE (STATUS "Found CURL source build")
+
+    # find the needed DLL's
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "libcurl" "curllib")
+
+    # find additional DLL's
+    FIND_DLL_WIN32 ("libeay32.dll")
+    FIND_DLL_WIN32 ("ssleay32.dll")
+    #FIND_DLL_WIN32 (libsasl.dll)
+
+  ENDIF (EXISTS "${FOUND_LOCATION}/curl.exe")
 
 ENDIF (CURL_FOUND)

=== modified file 'cmake_modules/Windows/FindICU.cmake'
--- cmake_modules/Windows/FindICU.cmake	2011-07-01 12:32:17 +0000
+++ cmake_modules/Windows/FindICU.cmake	2012-09-27 18:04:43 +0000
@@ -29,7 +29,7 @@
 #
 # See the FindICU.cmake module shipped with Zorba for more information.
 
-FIND_PACKAGE_WIN32 (ICU ICU_FOUND icu)
+FIND_PACKAGE_WIN32 (NAME ICU FOUND_VAR ICU_FOUND SEARCH_NAMES icu)
 
 IF (ICU_FOUND)
 

=== modified file 'cmake_modules/Windows/FindIconv.cmake'
--- cmake_modules/Windows/FindIconv.cmake	2011-06-23 15:42:53 +0000
+++ cmake_modules/Windows/FindIconv.cmake	2012-09-27 18:04:43 +0000
@@ -27,7 +27,7 @@
 #
 # See the FindIconv.cmake module shipped with Zorba for more information.
 
-FIND_PACKAGE_WIN32 (Iconv ICONV_FOUND iconv)
+FIND_PACKAGE_WIN32 (NAME Iconv FOUND_VAR ICONV_FOUND SEARCH_NAMES iconv)
 
 IF (ICONV_FOUND)
 

=== modified file 'cmake_modules/Windows/FindLibXml2.cmake'
--- cmake_modules/Windows/FindLibXml2.cmake	2011-06-23 15:42:53 +0000
+++ cmake_modules/Windows/FindLibXml2.cmake	2012-09-27 18:04:43 +0000
@@ -15,8 +15,8 @@
 # - Try to find the LibXml2 xml processing library on Windows
 #
 # This is a proxy module that calls the FindLibXml2.cmake module shipped with
-# CMake. But before we try to guess where LibXml2 might be on the user's machine.
-# The user should provide ZORBA_THIRD_PARTY_REQUIREMENTS which is a path where
+# CMake. But before we try to guess where LibXml2 might be on the user's machine,
+# the user should provide ZORBA_THIRD_PARTY_REQUIREMENTS which is a path where
 # the LibXml2 directory can be found. The LibXml2 directory must have "libxml"
 # (case insensitive) in its name.
 #
@@ -27,7 +27,7 @@
 #
 # See the FindLibXml2.cmake module shipped with CMake for more information.
 
-FIND_PACKAGE_WIN32 (LibXml2 LIBXML2_FOUND libxml)
+FIND_PACKAGE_WIN32 (NAME "LibXml2" FOUND_VAR "LIBXML2_FOUND" SEARCH_NAMES "libxml")
 
 IF (LIBXML2_FOUND)
 

=== added file 'cmake_modules/Windows/FindLibXslt.cmake'
--- cmake_modules/Windows/FindLibXslt.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/Windows/FindLibXslt.cmake	2012-09-27 18:04:43 +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 LIBXSLT lib on Windows
+#
+# This is a proxy module that calls the FindLibXslt.cmake module. Before
+# doing that, we try to guess where LIBXSLT might be on the user's machine.
+# The user should provide ZORBA_THIRD_PARTY_REQUIREMENTS which is a path where
+# the LIBXSLT directory can be found. The LIBXSLT directory must have "libxslt"
+# (case insensitive) in its name.
+#
+# This module helps the Windows user to avoid providing the following two
+# variables when building Zorba:
+# -D LIBXSLT_INCLUDE="path_to_3rd_party_dir\*LIBXSLT*\src"
+# -D LIBXSLT_LIBRARY="path_to_3rd_party_dir\*LIBXSLT*\bin\[Release\]libxslt.lib"
+#
+# See the FindLibTidy.cmake module shipped with Zorba for more information.
+
+FIND_PACKAGE_WIN32(NAME LibXslt FOUND_VAR LIBXSLT_FOUND SEARCH_NAMES libxslt)
+
+IF (LIBXSLT_FOUND)
+
+  # find the needed DLL's
+  FIND_PACKAGE_DLLS_WIN32 (${FOUND_LOCATION} libxslt.dll)
+
+ENDIF (LIBXSLT_FOUND)

=== modified file 'cmake_modules/Windows/FindPHP5.cmake'
--- cmake_modules/Windows/FindPHP5.cmake	2011-06-23 15:42:53 +0000
+++ cmake_modules/Windows/FindPHP5.cmake	2012-09-27 18:04:43 +0000
@@ -16,4 +16,4 @@
 #
 # TODO: correct description missing
 
-FIND_PACKAGE_WIN32(PHP5 PHP5_FOUND php)
+FIND_PACKAGE_WIN32(NAME PHP5 FOUND_VAR PHP5_FOUND SEARCH_NAMES php)

=== added file 'cmake_modules/Windows/FindPythonInterp.cmake'
--- cmake_modules/Windows/FindPythonInterp.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/Windows/FindPythonInterp.cmake	2012-09-27 18:04:43 +0000
@@ -0,0 +1,29 @@
+# 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 Python interpreter on Windows
+#
+# This is a proxy module that calls the FindPythonInterp.cmake module shipped with
+# CMake. But before we try to guess where Python interpreter might be on the user's
+# machine, the user should provide ZORBA_THIRD_PARTY_REQUIREMENTS which is a list
+# of paths where the Python interpreter directory can be found. The Python
+# interpreter directory must have "python" (case insensitive) in its name.
+#
+# This module helps the Windows user to avoid providing the following two
+# variables when building Zorba:
+# -D PYTHON_EXECUTABLE="path_to_3rd_party_dir\*python*\python.exe"
+#
+# See the FindPythonInterp.cmake module shipped with CMake for more information.
+
+FIND_PACKAGE_WIN32 (NAME PythonInterp FOUND_VAR PYTHONINTERP_FOUND SEARCH_NAMES python)

=== added file 'cmake_modules/Windows/FindPythonLibs.cmake'
--- cmake_modules/Windows/FindPythonLibs.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/Windows/FindPythonLibs.cmake	2012-09-27 18:04:43 +0000
@@ -0,0 +1,30 @@
+# 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 Python include files and libraries on Windows
+#
+# This is a proxy module that calls the FindPythonLibs.cmake module shipped with
+# CMake. But before we try to guess where the Python libraries might be on the
+# user's machine, the user should provide ZORBA_THIRD_PARTY_REQUIREMENTS which
+# is a list of paths where the Python directory can be found. The Python
+# directory must have "python" (case insensitive) in its name.
+#
+# This module helps the Windows user to avoid providing the following two
+# variables when building Zorba:
+# -D PYTHON_LIBRARIES="path_to_3rd_party_dir\*python*\lib"
+# -D PYTHON_INCLUDE_DIRS="path_to_3rd_party_dir\*python*\include"
+#
+# See the FindPythonLibs.cmake module shipped with CMake for more information.
+
+FIND_PACKAGE_WIN32 (NAME PythonLibs FOUND_VAR PYTHONLIBS_FOUND SEARCH_NAMES python)

=== modified file 'cmake_modules/Windows/FindSWIG.cmake'
--- cmake_modules/Windows/FindSWIG.cmake	2011-06-23 15:42:53 +0000
+++ cmake_modules/Windows/FindSWIG.cmake	2012-09-27 18:04:43 +0000
@@ -12,8 +12,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# - Find SWIG on Windows
-#
-# TODO: correct description missing
+# - Try to find the SWIG library on Windows
+#
+# This is a proxy module that calls the FindSWIG.cmake module.
+# But before we try to guess where SWIG might be on the user's machine.
+# The user should provide ZORBA_THIRD_PARTY_REQUIREMENTS which is a path where
+# the SWIG directory can be found. The SWIG directory must have "swig"
+# (case insensitive) in its name.
+#
+# This module helps the Windows user to avoid providing the following two
+# variables when building Zorba:
+# -D SWIG_EXECUTABLE="path_to_3rd_party_dir\*swig*\include"
+#
+# See the FindSWIG.cmake module shipped with Zorba for more information.
 
-FIND_PACKAGE_WIN32(SWIG SWIG_FOUND swig)
+FIND_PACKAGE_WIN32(NAME SWIG FOUND_VAR SWIG_FOUND SEARCH_NAMES swig)

=== modified file 'cmake_modules/Windows/FindXercesC.cmake'
--- cmake_modules/Windows/FindXercesC.cmake	2011-07-01 12:32:17 +0000
+++ cmake_modules/Windows/FindXercesC.cmake	2012-09-27 18:04:43 +0000
@@ -27,7 +27,7 @@
 #
 # See the FindXercesC.cmake module shipped with Zorba for more information.
 
-FIND_PACKAGE_WIN32(XercesC XERCESC_FOUND xerces)
+FIND_PACKAGE_WIN32(NAME XercesC FOUND_VAR XERCESC_FOUND SEARCH_NAMES xerces)
 
 IF (XERCESC_FOUND)
 

=== modified file 'cmake_modules/Windows/ProxyFindModule.cmake'
--- cmake_modules/Windows/ProxyFindModule.cmake	2011-07-01 12:32:17 +0000
+++ cmake_modules/Windows/ProxyFindModule.cmake	2012-09-27 18:04:43 +0000
@@ -29,7 +29,28 @@
   ELSE (${LOCATION_VAR})
     MESSAGE (STATUS "*********** DONE (not found) ***********")
   ENDIF (${LOCATION_VAR})
-ENDMACRO (PRINT_FIND_END_TITLE MODULE_NAME)
+ENDMACRO (PRINT_FIND_END_TITLE)
+
+
+MACRO (PRINT_FIND_END_TITLE_SYSTEM MODULE_NAME FOUND)
+  IF (${FOUND})
+    MESSAGE (STATUS "************* DONE (found) *************")
+  ELSE (${FOUND})
+    MESSAGE (STATUS "*********** DONE (not found) ***********")
+  ENDIF (${FOUND})
+ENDMACRO (PRINT_FIND_END_TITLE_SYSTEM)
+
+
+MACRO (INSTALL_DLL DLL_PATH)
+  IF (${PROJECT_NAME} STREQUAL "zorba")
+    # for zorba core requirements, install this DLL
+    INSTALL (PROGRAMS ${DLL_PATH} DESTINATION bin)
+  ELSE (${PROJECT_NAME} STREQUAL "zorba")
+    # for zorba non-core requirements, install this DLL only if the component is spcified
+    STRING (REPLACE "-" "_"  component_name ${PROJECT_NAME})
+    INSTALL (PROGRAMS ${DLL_PATH} DESTINATION bin COMPONENT ${component_name})
+  ENDIF (${PROJECT_NAME} STREQUAL "zorba")
+ENDMACRO (INSTALL_DLL)
 
 
 MACRO (PRINT_FIND_TITLE MODULE_NAME)
@@ -51,23 +72,50 @@
 
 
 # This macro will try to find a third party library on Windows.
+# The parameters must be given the arguments using the following pattern:
+#   PARAM_NAME1 param_value1 PARAM_NAME2 param_value1 param_value2 ...
+# This macro will further call PARSE_ARGUMENTS to parse it's arguments.
+# In the patter above, PARAM_NAME1 will go in the single value parameter pool
+# while PARAM_NAME2 will go in the multiple value parameter pool.
+#
+# Therefore the following parameter names must be provided to this macro:
 # Parameters:
-#  MODULE_NAME  - the XXX in the FindXXX.cmake that is used for search
-#    e.g.: "ICU" when trying to find ICU with FindICU.cmake
-#  FOUND_VAR    - the variable the FindXXX.cmake module sets if the library is found
-#    e.g.: "XERCESC_FOUND" when trying to find XercesC
-#  SEARCH_NAMES - a list of possible directory name fragments that this library can have
-#    e.g.: "icu;i_c_u;uci"
+#   NAME
+#     - mandatory, single value
+#     - the value following it will be used to build the CMake module file name.
+#     - e.g.: providing NAME "ICU" as parameters, FindICU.cmake will be used for the search.
+#   FOUND_VAR
+#     - mandatory, single value
+#     - the variable that the FindXXX.cmake module sets if the library is found
+#     - e.g.: FOUND_VAR "XERCESC_FOUND" when trying to find XercesC
+#   SEARCH_NAMES
+#     - mandatory, multiple value
+#     - the possible directory name fragments that this library can have
+#     - e.g.: SEARCH_NAMES "icu" "i_c_u" "uci"
+#   COMPONENTS
+#     - optional, multiple value
 #
 # Once done this will define:
-#  FOUND_LOCATION - The directory where the library was found
+#   FOUND_LOCATION - The directory where the library was found
 #
-MACRO (FIND_PACKAGE_WIN32 MODULE_NAME FOUND_VAR SEARCH_NAMES)
+MACRO (FIND_PACKAGE_WIN32)
 
   IF (NOT WIN32)
-    MESSAGE(FATAL_ERROR "This macro is intended only for Windows platforms.")
+    MESSAGE (FATAL_ERROR "This macro is intended only for Windows platforms.")
   ENDIF (NOT WIN32)
 
+  PARSE_ARGUMENTS(MODULE "SEARCH_NAMES;COMPONENTS" "NAME;FOUND_VAR" "" ${ARGN})
+  
+  IF(NOT MODULE_NAME)
+    MESSAGE (FATAL_ERROR "'NAME' argument is required")
+  ENDIF(NOT MODULE_NAME)
+  IF(NOT MODULE_FOUND_VAR)
+    MESSAGE (FATAL_ERROR "'FOUND_VAR' argument is required")
+  ENDIF(NOT MODULE_FOUND_VAR)
+  IF(NOT MODULE_SEARCH_NAMES)
+    MESSAGE (FATAL_ERROR "'SEARCH_NAMES' argument is required")
+  ENDIF(NOT MODULE_SEARCH_NAMES)
+  
   PRINT_FIND_TITLE (${MODULE_NAME})
   
   # reset the output variable where the target library is found
@@ -83,7 +131,7 @@
   SET (PATH_REGEX)
   FOREACH (PATH ${SEARCH_PATHS})
     FILE (TO_CMAKE_PATH "${PATH}" PATH)
-    FOREACH (NAME ${SEARCH_NAMES})
+    FOREACH (NAME ${MODULE_SEARCH_NAMES})
       SET (PATH_REGEX ${PATH_REGEX} "${PATH}/*${NAME}*")
     ENDFOREACH (NAME)
   ENDFOREACH (PATH)
@@ -107,7 +155,7 @@
     STRING (TOLOWER "${PATH}" LC_PATH)
 
     # now iterate over all the possible names
-    FOREACH (NAME ${SEARCH_NAMES})
+    FOREACH (NAME ${MODULE_SEARCH_NAMES})
       STRING (TOLOWER "${NAME}" LC_NAME)
       IF ("${LC_PATH}" MATCHES ".*${LC_NAME}.*")
         IF (EXISTS "${PATH}/include")
@@ -147,12 +195,16 @@
     SET (CMAKE_PREFIX_PATH ${PATH})
 
     # call the real Find${MODULE_NAME}.cmake module
-    FIND_PACKAGE (${MODULE_NAME})
+    IF(NOT MODULE_COMPONENTS)
+      FIND_PACKAGE (${MODULE_NAME})
+    ELSE(NOT MODULE_COMPONENTS)
+      FIND_PACKAGE (${MODULE_NAME} COMPONENTS ${MODULE_COMPONENTS})
+    ENDIF(NOT MODULE_COMPONENTS)
     
-    IF (${FOUND_VAR})
+    IF (${MODULE_FOUND_VAR})
       SET (FOUND_LOCATION ${CMAKE_PREFIX_PATH})
       BREAK ()
-    ENDIF (${FOUND_VAR})
+    ENDIF (${MODULE_FOUND_VAR})
   ENDFOREACH(PATH)
 
   PRINT_FIND_END_TITLE (${MODULE_NAME} FOUND_LOCATION)
@@ -162,22 +214,130 @@
   # restore the prefix path
   SET (CMAKE_PREFIX_PATH ${OLD_CMAKE_PREFIX_PATH})
 
+  SET(MODULE_NAME)
+  SET(MODULE_FOUND_VAR)
+  SET(MODULE_SEARCH_NAMES)
+  SET(MODULE_COMPONENT)
+
 ENDMACRO (FIND_PACKAGE_WIN32)
 
 
-MACRO(FIND_PACKAGE_DLLS_WIN32 LIBRARY_LOCATION DLL_NAMES)
-
-  IF (NOT WIN32)
-    MESSAGE(FATAL_ERROR "This macro is intended only for Windows platforms.")
-  ENDIF (NOT WIN32)
-
-  # get the current DLLs and their paths
-  SET (ZORBA_REQUIRED_DLLS "$ENV{ZORBA_REQUIRED_DLLS}")
-  SET (ZORBA_REQUIRED_DLL_PATHS "$ENV{ZORBA_REQUIRED_DLL_PATHS}")
+# This macro will just perform a normal library search without trying to guess
+# locations. This should be used for searching libraries that can be found on
+# Windows using other means like registry entries (ImageMagick) or special
+# environment variables (Java or JNI)
+MACRO (FIND_PACKAGE_WIN32_NO_PROXY MODULE_NAME FOUND_VAR)
+
+  PRINT_FIND_TITLE (${MODULE_NAME})
+
+  # remove the Windows module path (both from Zorba or the external modules)
+  # to avoid an infinite recursion
+  FOREACH (PATH ${CMAKE_MODULE_PATH})
+    IF ("${PATH}" MATCHES ".*/cmake_modules/Windows")
+      LIST (REMOVE_ITEM CMAKE_MODULE_PATH "${PATH}")
+    ENDIF ("${PATH}" MATCHES ".*/cmake_modules/Windows")
+  ENDFOREACH (PATH)
+
+  FIND_PACKAGE (${MODULE_NAME})
+
+  # restore the module path
+  SET (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/Windows ${CMAKE_MODULE_PATH})
+  # restore the prefix path
+  SET (CMAKE_PREFIX_PATH ${OLD_CMAKE_PREFIX_PATH})
+
+  PRINT_FIND_END_TITLE_SYSTEM (${MODULE_NAME} ${FOUND_VAR})
+
+ENDMACRO (FIND_PACKAGE_WIN32_NO_PROXY)
+
+
+# This macro will search for a DLL in the given library location using extra
+# arguments as alternative names of the DLL. The first DLL found with that name
+# is considered. This is useful for some libraries that come with different DLL
+# names depending on the library version. For example, cURL library might
+# distribute it's main DLL with two different names: "libcurl.dll" or "curllib.dll"
+#
+# If the DLL is found it's full path will be added to ZORBA_REQUIRED_DLLS and
+# it's location to the ZORBA_REQUIRED_DLL_PATHS variable. These will be later
+# used when installing zorba.
+#
+MACRO (FIND_PACKAGE_DLL_WIN32 LIBRARY_LOCATION)
+
+  IF (NOT WIN32)
+    MESSAGE (FATAL_ERROR "This macro is intended only for Windows platforms.")
+  ENDIF (NOT WIN32)
+
+  # get the current DLLs and their paths
+  SET (dlls "${ZORBA_REQUIRED_DLLS}")
+  SET (paths "${ZORBA_REQUIRED_DLL_PATHS}")
+
+  FOREACH (NAME ${ARGN})
+
+    # first delete the cache entry used during FIND_FILE to make sure the correct file is chosen
+    UNSET (TMP_DLL_VAR CACHE)
+
+    # find now the DLL
+    FIND_FILE (
+      TMP_DLL_VAR
+      "${NAME}.dll"
+      PATHS "${LIBRARY_LOCATION}"
+      PATH_SUFFIXES "bin" "bin/Release" "lib"
+      NO_DEFAULT_PATH
+    )
+
+    IF (TMP_DLL_VAR)
+
+      LIST (APPEND dlls "${TMP_DLL_VAR}")
+      STRING (REPLACE "/${NAME}.dll" "" PATH "${TMP_DLL_VAR}")
+      FILE (TO_NATIVE_PATH ${PATH} NATIVE_PATH)
+      LIST (APPEND paths "${NATIVE_PATH}")
+      MESSAGE (STATUS "Added dll to ZORBA_REQUIRED_DLLS cache variable: ${TMP_DLL_VAR}")
+      INSTALL_DLL (${TMP_DLL_VAR})
+
+      # we break the loop if we found one DLL
+      BREAK ()
+
+    ENDIF (TMP_DLL_VAR)
+
+  ENDFOREACH (NAME)
+
+  # we report a warning if the DLL could not be found
+  IF (NOT TMP_DLL_VAR)
+    MESSAGE (WARNING "None of the names provided (${ARGN}) points to a DLL in: ${LIBRARY_LOCATION}. Zorba will not run properly unless you have it in the path.")
+  ENDIF (NOT TMP_DLL_VAR)
+
+  # make sure we don't leave garbage in the cache and don't influence other logic with this
+  UNSET (TMP_DLL_VAR CACHE)
+
+  # remove duplicates from the path list
+  LIST (LENGTH paths LEN)
+  IF (${LEN} GREATER 0)
+    LIST (REMOVE_DUPLICATES paths)
+  ENDIF (${LEN} GREATER 0)
+
+  # set the current DLLs and their paths in a variable
+  SET (ZORBA_REQUIRED_DLLS "${dlls}"
+    CACHE STRING "List of DLLs that must be installed" FORCE
+  )
+  SET (ZORBA_REQUIRED_DLL_PATHS "${paths}"
+    CACHE STRING "List of paths executable require in order to find the required DLLs" FORCE
+  )
+
+ENDMACRO (FIND_PACKAGE_DLL_WIN32)
+
+
+MACRO (FIND_PACKAGE_DLLS_WIN32 LIBRARY_LOCATION DLL_NAMES)
+
+  IF (NOT WIN32)
+    MESSAGE (FATAL_ERROR "This macro is intended only for Windows platforms.")
+  ENDIF (NOT WIN32)
+
+  # get the current DLLs and their paths
+  SET (dlls "${ZORBA_REQUIRED_DLLS}")
+  SET (paths "${ZORBA_REQUIRED_DLL_PATHS}")
 
   FOREACH (NAME ${DLL_NAMES})
 
-    # first delete the cache entry for DLL to make sure the correct one is chosen
+    # first delete the cache entry used during FIND_FILE to make sure the correct file is chosen
     UNSET (TMP_DLL_VAR CACHE)
 
     # find now the DLL
@@ -185,38 +345,41 @@
       TMP_DLL_VAR
       "${NAME}"
       PATHS "${LIBRARY_LOCATION}"
-      PATH_SUFFIXES "bin" "bin/Release" 
+      PATH_SUFFIXES "bin" "bin/Release" "lib"
       NO_DEFAULT_PATH
     )
 
     IF (TMP_DLL_VAR)
-      LIST (APPEND ZORBA_REQUIRED_DLLS "${TMP_DLL_VAR}")
+      LIST (APPEND dlls "${TMP_DLL_VAR}")
       STRING (REPLACE "/${NAME}" "" PATH "${TMP_DLL_VAR}")
-      FILE(TO_NATIVE_PATH ${PATH} NATIVE_PATH)
-      LIST (APPEND ZORBA_REQUIRED_DLL_PATHS "${NATIVE_PATH}")
-      MESSAGE(STATUS "Added dll to ZORBA_REQUIRED_DLLS environment variable: ${TMP_DLL_VAR}")
+      FILE (TO_NATIVE_PATH ${PATH} NATIVE_PATH)
+      LIST (APPEND paths "${NATIVE_PATH}")
+      MESSAGE (STATUS "Added dll to ZORBA_REQUIRED_DLLS cache variable: ${TMP_DLL_VAR}")
+      INSTALL_DLL (${TMP_DLL_VAR})
     ELSE (TMP_DLL_VAR)
-      MESSAGE (WARNING "${NAME} was not found in: ${LIBRARY_LOCATION}. Zorba will not run unless you have it in the path.")
+      MESSAGE (WARNING "${NAME} was not found in: ${LIBRARY_LOCATION}. Zorba will not run properly unless you have it in the path.")
     ENDIF (TMP_DLL_VAR)
-    
+
   ENDFOREACH (NAME)
 
   # make sure we don't leave garbage in the cache and don't influence other logic with this
   UNSET (TMP_DLL_VAR CACHE)
 
-  LIST(LENGTH ZORBA_REQUIRED_DLL_PATHS LEN)
+  # remove duplicates from the path list
+  LIST (LENGTH paths LEN)
   IF (${LEN} GREATER 0)
-    LIST(REMOVE_DUPLICATES ZORBA_REQUIRED_DLL_PATHS)
+    LIST (REMOVE_DUPLICATES paths)
   ENDIF (${LEN} GREATER 0)
 
-  # make sure we don't leave garbage in the cache and don't influence other logic with this
-  SET (TMP_DLL_VAR TMP_DLL_VAR-NOTFOUND CACHE FILEPATH "Path to a file." FORCE)
-
   # set the current DLLs and their paths in a variable
-  SET (ENV{ZORBA_REQUIRED_DLLS} "${ZORBA_REQUIRED_DLLS}")
-  SET (ENV{ZORBA_REQUIRED_DLL_PATHS} "${ZORBA_REQUIRED_DLL_PATHS}")
+  SET (ZORBA_REQUIRED_DLLS "${dlls}"
+    CACHE STRING "List of DLLs that must be installed" FORCE
+  )
+  SET (ZORBA_REQUIRED_DLL_PATHS "${paths}"
+    CACHE STRING "List of paths executable require in order to find the required DLLs" FORCE
+  )
 
-ENDMACRO(FIND_PACKAGE_DLLS_WIN32)
+ENDMACRO (FIND_PACKAGE_DLLS_WIN32)
 
 
 MACRO (FIND_DLL_WIN32 DLL_NAME)
@@ -226,8 +389,8 @@
   ENDIF (NOT WIN32)
 
   # get the current DLLs and their paths
-  SET (ZORBA_REQUIRED_DLLS "$ENV{ZORBA_REQUIRED_DLLS}")
-  SET (ZORBA_REQUIRED_DLL_PATHS "$ENV{ZORBA_REQUIRED_DLL_PATHS}")
+  SET (dlls "${ZORBA_REQUIRED_DLLS}")
+  SET (paths "${ZORBA_REQUIRED_DLL_PATHS}")
 
   # first delete the cache entry for DLL to make sure the correct one is chosen
   UNSET (TMP_DLL_VAR CACHE)
@@ -241,18 +404,19 @@
     TMP_DLL_VAR
     ${DLL_NAME}
     PATHS
-      ${ZORBA_REQUIRED_DLL_PATHS}
+      ${paths}
       ${ZORBA_THIRD_PARTY_REQUIREMENTS}
       $ENV{PATH}
     NO_DEFAULT_PATH
   )
 
   IF (TMP_DLL_VAR)
-    LIST (APPEND ZORBA_REQUIRED_DLLS "${TMP_DLL_VAR}")
+    LIST (APPEND dlls "${TMP_DLL_VAR}")
     STRING (REPLACE "/${DLL_NAME}" "" PATH "${TMP_DLL_VAR}")
     FILE(TO_NATIVE_PATH ${PATH} NATIVE_PATH)
-    LIST (APPEND ZORBA_REQUIRED_DLL_PATHS "${NATIVE_PATH}")
-    MESSAGE (STATUS "Added dll to ZORBA_REQUIRED_DLLS environment variable: ${TMP_DLL_VAR}")
+    LIST (APPEND paths "${NATIVE_PATH}")
+    MESSAGE (STATUS "Added dll to ZORBA_REQUIRED_DLLS cache variable: ${TMP_DLL_VAR}")
+    INSTALL_DLL (${TMP_DLL_VAR})
   ELSE (TMP_DLL_VAR)
     MESSAGE (STATUS "Did not find ${DLL_NAME}")
     MESSAGE (WARNING "You will not be able to run zorba unless you have ${DLL_NAME} in your path.")
@@ -261,9 +425,19 @@
   # make sure we don't leave garbage in the cache and don't influence other logic with this
   UNSET (TMP_DLL_VAR CACHE)
 
+  # remove duplicates from the path list
+  LIST (LENGTH paths LEN)
+  IF (${LEN} GREATER 0)
+    LIST (REMOVE_DUPLICATES paths)
+  ENDIF (${LEN} GREATER 0)
+
   # set the current DLLs and their paths in a variable
-  SET (ENV{ZORBA_REQUIRED_DLLS} "${ZORBA_REQUIRED_DLLS}")
-  SET (ENV{ZORBA_REQUIRED_DLL_PATHS} "${ZORBA_REQUIRED_DLL_PATHS}")
+  SET (ZORBA_REQUIRED_DLLS "${dlls}"
+    CACHE STRING "List of DLLs that must be installed" FORCE
+  )
+  SET (ZORBA_REQUIRED_DLL_PATHS "${paths}"
+    CACHE STRING "List of paths executable require in order to find the required DLLs" FORCE
+  )
 
 ENDMACRO (FIND_DLL_WIN32)
 
@@ -271,20 +445,26 @@
 MACRO (ADD_DLL_WIN32 DLL_PATH DLL_NAME)
 
   IF (NOT WIN32)
-    MESSAGE(FATAL_ERROR "This macro is intended only for Windows platforms.")
+    MESSAGE (FATAL_ERROR "This macro is intended only for Windows platforms.")
   ENDIF (NOT WIN32)
 
   # get the current DLLs and their paths
-  SET (ZORBA_REQUIRED_DLLS "$ENV{ZORBA_REQUIRED_DLLS}")
-  SET (ZORBA_REQUIRED_DLL_PATHS "$ENV{ZORBA_REQUIRED_DLL_PATHS}")
+  SET (dlls "${ZORBA_REQUIRED_DLLS}")
+  SET (paths "${ZORBA_REQUIRED_DLL_PATHS}")
 
-  LIST (APPEND ZORBA_REQUIRED_DLLS "${DLL_PATH}/${DLL_NAME}")
+  SET (DLL_FULL_PATH ${DLL_PATH}/${DLL_NAME})
+  LIST (APPEND dlls "${DLL_FULL_PATH}")
   FILE(TO_NATIVE_PATH ${DLL_PATH} NATIVE_PATH)
-  LIST (APPEND ZORBA_REQUIRED_DLL_PATHS "${NATIVE_PATH}")
-  MESSAGE (STATUS "Added dll to ZORBA_REQUIRED_DLLS environment variable: ${DLL_PATH}/${DLL_NAME}")
+  LIST (APPEND paths "${NATIVE_PATH}")
+  MESSAGE (STATUS "Added dll to ZORBA_REQUIRED_DLLS cache variable: ${DLL_FULL_PATH}")
+  INSTALL_DLL (${DLL_FULL_PATH})
 
   # set the current DLLs and their paths in a variable
-  SET (ENV{ZORBA_REQUIRED_DLLS} "${ZORBA_REQUIRED_DLLS}")
-  SET (ENV{ZORBA_REQUIRED_DLL_PATHS} "${ZORBA_REQUIRED_DLL_PATHS}")
+  SET (ZORBA_REQUIRED_DLLS "${dlls}"
+    CACHE STRING "List of DLLs that must be installed" FORCE
+  )
+  SET (ZORBA_REQUIRED_DLL_PATHS "${paths}"
+    CACHE STRING "List of paths executable require in order to find the required DLLs" FORCE
+  )
 
 ENDMACRO (ADD_DLL_WIN32)

=== modified file 'cmake_modules/ZorbaGenerateExe.cmake'
--- cmake_modules/ZorbaGenerateExe.cmake	2011-06-30 02:34:20 +0000
+++ cmake_modules/ZorbaGenerateExe.cmake	2012-09-27 18:04:43 +0000
@@ -53,34 +53,44 @@
   IF (NOT ${NEW_NAME} STREQUAL "")
     SET_TARGET_PROPERTIES ("${EXE_NAME}${SUFFIX}" PROPERTIES OUTPUT_NAME "${NEW_NAME}${SUFFIX}")
   ENDIF (NOT ${NEW_NAME} STREQUAL "")
+  
+  # select an appropriate folder to put this target into in the IDE
+  IF (${EXE_NAME} MATCHES ".*(T|t)est.*")
+    SET (folder "Tests")
+  ELSEIF (${EXE_NAME} MATCHES ".*(E|e)xample.*")
+    SET (folder "Examples")
+  ENDIF (${EXE_NAME} MATCHES ".*(T|t)est.*")
+  SET_TARGET_PROPERTIES ("${EXE_NAME}${SUFFIX}" PROPERTIES
+    FOLDER "${folder}"
+  )
 
   IF (NOT ${INSTALL_DESTINATION} STREQUAL "")
     INSTALL (TARGETS ${EXE_NAME}${SUFFIX} DESTINATION ${INSTALL_DESTINATION})
   ENDIF (NOT ${INSTALL_DESTINATION} STREQUAL "")
 
-  # generate list of bat scripts to set the PATH variable for the executables
   IF (WIN32)
+    # generate list of bat scripts to set the PATH variable for the executables
     IF (NOT ${NEW_NAME} STREQUAL "")
       SET (ZORBA_EXE_NAME "${NEW_NAME}${SUFFIX}")
     ELSE (NOT ${NEW_NAME} STREQUAL "")
       SET (ZORBA_EXE_NAME "${EXE_NAME}${SUFFIX}")
     ENDIF (NOT ${NEW_NAME} STREQUAL "")
 
-    SET (ENV{ZORBA_EXE_SCRIPT_LIST} "$ENV{ZORBA_EXE_SCRIPT_LIST}${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_EXE_NAME}.bat;")
+    SET (ZORBA_EXE_SCRIPT_LIST "${ZORBA_EXE_SCRIPT_LIST}${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_EXE_NAME}.bat;"
+      CACHE STRING "List of Windows batch scripts to be generated, one for each executable" FORCE
+    )
+
+
+    # generate list of Visual Studio project files to set the PATH variable
+    IF (MSVC_IDE)
+      SET (SYSTEM_NAME $ENV{USERDOMAIN})
+      SET (USER_NAME $ENV{USERNAME})
+      SET (ZORBA_VC_PROJECT_FILE_LIST "${ZORBA_VC_PROJECT_FILE_LIST}${EXE_NAME}.vcproj.${SYSTEM_NAME}.${USER_NAME}.user"
+        CACHE STRING "List of Visual Studio project files to be generated, one for each executable" FORCE
+      )
+    ENDIF (MSVC_IDE)
   ENDIF (WIN32)
   
-  # generating initial property file for each executable in visual studio
-  # is done to set the PATH variable correctly
-  IF (MSVC_IDE)
-    SET (SYSTEM_NAME $ENV{USERDOMAIN})
-    SET (USER_NAME $ENV{USERNAME})
-    SET (ZORBA_VC_PROJECT_CONFIG_FILE "${EXE_NAME}${SUFFIX}.vcproj.${SYSTEM_NAME}.${USER_NAME}.user")
-    # Do not overwrite old property files. The user might have adapted something.
-    IF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_VC_PROJECT_CONFIG_FILE})
-      CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/cmake_modules/VCProject.vcproj.in ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_VC_PROJECT_CONFIG_FILE})
-    ENDIF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_VC_PROJECT_CONFIG_FILE})
-  ENDIF (MSVC_IDE)
-
   IF (ZORBA_BUILD_STATIC_LIBRARY)
     ADD_EXECUTABLE ("${EXE_NAME}${SUFFIX}_static" ${SRCS})
     SET_TARGET_PROPERTIES ("${EXE_NAME}${SUFFIX}_static" PROPERTIES COMPILE_DEFINITIONS BUILDING_ZORBA_STATIC)
@@ -100,18 +110,18 @@
 ENDMACRO (ZORBA_GENERATE_EXE)
 
 
-# This macro will read the ZORBA_EXE_SCRIPT_LIST environments variable and will
-# generate them near each corresponding executable.
+# This macro will read the ZORBA_EXE_SCRIPT_LIST and ZORBA_VC_PROJECT_CONFIG_FILE 
+# environment variables and will generate them near each corresponding executable.
 # This macro must be invoked AFTER all the required libraries have been searched
 # for (both Zorba and external modules) in order to set a correct path in the
 # scripts.
-MACRO (ZORBA_GENERATE_EXE_SCRIPTS_WIN32)
+MACRO (ZORBA_GENERATE_EXE_HELPERS_WIN32)
 
   IF (NOT WIN32)
     MESSAGE (FATAL_ERROR "This macro is intended only for Windows platforms.")
   ENDIF (NOT WIN32)
 
-  FOREACH (SCRIPT $ENV{ZORBA_EXE_SCRIPT_LIST})
+  FOREACH (SCRIPT ${ZORBA_EXE_SCRIPT_LIST})
 
     MESSAGE (STATUS "Adding exe script: ${SCRIPT}")
 
@@ -121,13 +131,20 @@
     ENDIF (MSVC_IDE)
     # used to know where zorba_simplestore.dll is
     FILE (TO_NATIVE_PATH "${CMAKE_BINARY_DIR}" CMAKE_BINARY_DIR_NATIVE)
-    # used to populate the path when running the executable from the script
-    SET (ZORBA_REQUIRED_DLL_PATHS "$ENV{ZORBA_REQUIRED_DLL_PATHS}")
     # used to find out the original executable name
     FILE (TO_NATIVE_PATH "${SCRIPT}" SCRIPT_NATIVE)
 
+    # ZORBA_REQUIRED_DLL_PATHS is also needed and picked from the CACHE
     CONFIGURE_FILE ("${CMAKE_SOURCE_DIR}/scripts/win_exec.bat.in" ${SCRIPT} @ONLY)
 
   ENDFOREACH (SCRIPT)
 
-ENDMACRO (ZORBA_GENERATE_EXE_SCRIPTS_WIN32)
+  FOREACH (VCFILE ${ZORBA_VC_PROJECT_FILE_LIST})
+    # Do not overwrite old property files. The user might have adapted something.
+    IF (NOT EXISTS ${VCFILE})
+      CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/cmake_modules/VCProject.vcproj.in ${VCFILE})
+    ENDIF (NOT EXISTS ${VCFILE})
+  ENDFOREACH(VCFILE)
+
+
+ENDMACRO (ZORBA_GENERATE_EXE_HELPERS_WIN32)

=== modified file 'cmake_modules/ZorbaModule.cmake'
--- cmake_modules/ZorbaModule.cmake	2011-07-03 07:31:06 +0000
+++ cmake_modules/ZorbaModule.cmake	2012-09-27 18:04:43 +0000
@@ -15,11 +15,11 @@
 # Utility macro to parse CMake-style argument lists
 MACRO(PARSE_ARGUMENTS prefix arg_names onearg_names option_names)
   SET(DEFAULT_ARGS)
-  FOREACH(arg_name ${arg_names})
+  FOREACH(arg_name ${arg_names} ${onearg_names})
     SET(${prefix}_${arg_name})
   ENDFOREACH(arg_name)
   FOREACH(option ${option_names})
-    SET(${prefix}_${option} FALSE)
+    SET(${prefix}_${option} 0)
   ENDFOREACH(option)
 
   SET(current_arg_name DEFAULT_ARGS)
@@ -43,7 +43,7 @@
     ELSE (is_arg_name GREATER -1 OR is_onearg_name GREATER -1)
       LIST(FIND loption_names "${arg}" is_option)
       IF (is_option GREATER -1)
-        SET(${prefix}_${arg} TRUE)
+        SET(${prefix}_${arg} 1)
       ELSE (is_option GREATER -1)
         SET(current_arg_list ${current_arg_list} ${arg})
         IF (current_arg_is_singular)
@@ -66,7 +66,8 @@
 #
 # Parameters:
 #   URI - URI to mangle
-#   EXT - extension to ensure URI ends with
+#   EXT - extension to ensure URI ends with (may be empty; if set, must
+#         include leading "."
 #   DIR_VAR - variable to set with the directory part of the mangled path
 #   FILE_VAR - variable to set with the file part of the mangled path
 MACRO (MANGLE_URI URI EXT DIR_VAR FILE_VAR)
@@ -89,13 +90,14 @@
 
   # Convert final component into proper filename
   IF (NOT final_comp)
-    SET (${FILE_VAR} "index.${EXT}")
+    SET (${FILE_VAR} "index${EXT}")
   ELSE (NOT final_comp)
-    IF ("${final_comp}" MATCHES "\\.${EXT}$")
+    # \\ necessary to escape the leading . in EXT
+    IF ("${final_comp}" MATCHES "\\${EXT}$")
       SET (${FILE_VAR} "${final_comp}")
-    ELSE ("${final_comp}" MATCHES "\\.${EXT}$")
-      SET (${FILE_VAR} "${final_comp}.${EXT}")
-    ENDIF ("${final_comp}" MATCHES "\\.${EXT}$")
+    ELSE ("${final_comp}" MATCHES "\\${EXT}$")
+      SET (${FILE_VAR} "${final_comp}${EXT}")
+    ENDIF ("${final_comp}" MATCHES "\\${EXT}$")
   ENDIF (NOT final_comp)
 
   # Stick the reversed authority back on the front of the path: done!
@@ -112,7 +114,19 @@
 #              relative to CMAKE_CURRENT_SOURCE_DIR)
 #       LINK_LIBRARIES - (optional) List of libraries to link external
 #              function library against
-#       OUTPUT_DIRECTORY - (optional) Base path to produce output in
+#       CONFIG_FILES - (optional) List of files to configure with package
+#              information; see below
+#       TEST_ONLY - (optional) Module is for testcases only and should not
+#              be installed
+#
+# CONFIG_FILES - any files specific here will be copied to
+# CMAKE_CURRENT_BINARY_DIR using CONFIGURE_FILE(). They may contain
+# the following @VARIABLES@ which will be substituted:
+#       ZORBA_MODULE_RELATIVE_DIR - directory portion of mangled URI
+#       ZORBA_MODULE_LIBFILE_WE - filename (without extension) portion of
+#              mangled URI
+# The input files should have a .in extension. The resulting file in
+# the build directory will have the .in removed.
 #
 # QQQ this currently doesn't support modules with multiple component
 # .xq files. (Neither does Zorba's automatic loading mechanism, so
@@ -122,80 +136,105 @@
 # file enough to deduce the URI and version?
 MACRO (DECLARE_ZORBA_MODULE)
   # Parse and validate arguments
-  PARSE_ARGUMENTS(MODULE "LINK_LIBRARIES" "URI;FILE;VERSION;OUTPUT_DIRECTORY"
-    "" ${ARGN})
+  PARSE_ARGUMENTS(MODULE "LINK_LIBRARIES;EXTRA_SOURCES;CONFIG_FILES"
+    "URI;FILE;VERSION" "TEST_ONLY" ${ARGN})
+  IF (NOT MODULE_FILE)
+    MESSAGE (FATAL_ERROR "'FILE' argument is required for ZORBA_DECLARE_MODULE()")
+  ENDIF (NOT MODULE_FILE)
+  IF (NOT MODULE_URI)
+    MESSAGE (FATAL_ERROR "'URI' argument is required for ZORBA_DECLARE_MODULE()")
+  ENDIF (NOT MODULE_URI)
   IF (NOT IS_ABSOLUTE "${MODULE_FILE}")
     SET (SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILE}")
-    SET (module_name "${MODULE_FILE}")
   ELSE (NOT IS_ABSOLUTE "${MODULE_FILE}")
     SET (SOURCE_FILE "${MODULE_FILE}")
-    GET_FILENAME_COMPONENT (module_name "${MODULE_FILE}" NAME)
   ENDIF (NOT IS_ABSOLUTE "${MODULE_FILE}")
+  GET_FILENAME_COMPONENT (module_name "${MODULE_FILE}" NAME)
+
+  MANGLE_URI (${MODULE_URI} ".xq" module_path module_filename)
 
   # Determine which module this is, numerically. This number will be
-  # used to generate unique target names for the external library (if
-  # any) and the target to copy files into URI_PATH. I wish I could
-  # name these targets after the URI rather than an int to avoid any
-  # possibility of conflicts, but when you do that you quickly run up
-  # against Windows' pathetic 260-character path limitation.
-  GET_PROPERTY (num_mod_targets GLOBAL PROPERTY ZORBA_MODULE_TARGET_COUNT)
-  IF (NOT num_mod_targets)
-    SET (num_mod_targets 0)
-  ENDIF (NOT num_mod_targets)
-  MATH (EXPR num_mod_targets "${num_mod_targets} + 1")
-  SET_PROPERTY (GLOBAL PROPERTY ZORBA_MODULE_TARGET_COUNT ${num_mod_targets})
-
-
-  MANGLE_URI (${MODULE_URI} "xq" module_path module_filename)
-
-  # Compute a CMake-symbol-safe version of the target URI, for storing
-  # things in CMake properties and declaring CMake targets.
-  STRING (REGEX REPLACE "[/ ]" "_" uri_sym "${module_path}/${module_filename}")
-
-  # Compute the version numbers, if any provided.
-  IF (MODULE_VERSION)
-    STRING (REPLACE "." ";" version "${MODULE_VERSION}")
-    LIST (LENGTH version version_len)
-    IF (NOT (version_len EQUAL 2) OR (version_len EQUAL 3))
-      MESSAGE (FATAL_ERROR
-        "Version ${MODULE_VERSION} not of form 'major.minor[.patch]'")
-    ENDIF (NOT (version_len EQUAL 2) OR (version_len EQUAL 3))
-    LIST (GET version 0 major_ver)
-    LIST (GET version 1 minor_ver)
-    IF (version_len EQUAL 3)
-      LIST (GET version 2 patch_ver)
-      MATH (EXPR version_int
-        "${major_ver} * 100000000 + ${minor_ver} * 100000 + ${patch_ver}")
-    ELSE (version_len EQUAL 3)
-      SET (patch_ver)
-      MATH (EXPR version_int "${major_ver} * 100000000 + ${minor_ver} * 100000")
-    ENDIF (version_len EQUAL 3)
-
-    # We maintain a global CMake property named after the target URI
-    # which remembers all versions of this URI which have been
-    # declared. If a *lower* version has already been declared, the
-    # output file rules will be messed up, so die.
-    GET_PROPERTY (target_versions GLOBAL PROPERTY "${uri_sym}-versions")
-    FOREACH (known_ver ${target_versions})
-      IF (known_ver LESS version_int)
-        MESSAGE (FATAL_ERROR
-          "The module ${MODULE_URI} has already been declared with a "
-          "lower version number than ${MODULE_VERSION}. "
-          "Please call DECLARE_ZORBA_MODULE() for higher versions of the same "
-          "module first.")
-      ENDIF (known_ver LESS version_int)
-    ENDFOREACH (known_ver)
-    SET_PROPERTY (GLOBAL APPEND PROPERTY "${uri_sym}-versions" ${version_int})
-  ENDIF (MODULE_VERSION)
+  # used to generate unique names, for instance for the target name
+  # for the external library (if any) and for the compilation test. I
+  # wish I could name these targets after the URI rather than an int
+  # to avoid any possibility of conflicts, but when you do that you
+  # quickly run up against Windows' pathetic 260-character path
+  # limitation.
+  GET_PROPERTY (num_zorba_modules GLOBAL PROPERTY ZORBA_MODULE_COUNT)
+  IF (NOT num_zorba_modules)
+    SET (num_zorba_modules 0)
+  ENDIF (NOT num_zorba_modules)
+  MATH (EXPR num_zorba_modules "${num_zorba_modules} + 1")
+  SET_PROPERTY (GLOBAL PROPERTY ZORBA_MODULE_COUNT ${num_zorba_modules})
+
+  # If no version specified, it is effectively treated as 0.0.0.
+  IF (NOT MODULE_VERSION)
+    SET (MODULE_VERSION "0.0.0")
+  ENDIF (NOT MODULE_VERSION)
+
+  # Compute a unique integer, version_int, based on the version
+  # number, so we can more easily compare with other versions later.
+  STRING (REPLACE "." ";" version "${MODULE_VERSION}")
+  LIST (LENGTH version version_len)
+  IF (NOT ( (version_len EQUAL 2) OR (version_len EQUAL 3) ) )
+    MESSAGE (FATAL_ERROR
+      "Version ${version_len} ${MODULE_VERSION} not of form 'major.minor[.patch]'")
+  ENDIF (NOT ( (version_len EQUAL 2) OR (version_len EQUAL 3) ) )
+  LIST (GET version 0 major_ver)
+  LIST (GET version 1 minor_ver)
+  IF (version_len EQUAL 3)
+    LIST (GET version 2 patch_ver)
+    MATH (EXPR version_int
+      "${major_ver} * 100000000 + ${minor_ver} * 100000 + ${patch_ver}")
+  ELSE (version_len EQUAL 3)
+    SET (patch_ver)
+    MATH (EXPR version_int "${major_ver} * 100000000 + ${minor_ver} * 100000")
+  ENDIF (version_len EQUAL 3)
+
+  # We maintain a global CMake property named after the target URI
+  # which remembers all versions of this URI which have been
+  # declared. If a *lower* version has already been declared, the
+  # output file rules will be messed up, so die. If the *same* version
+  # has already been declare, XQdoc will be messed up, so die.
+  STRING (REGEX REPLACE "[/:#% ]" "_" uri_sym "${MODULE_URI}")
+  GET_PROPERTY (target_versions GLOBAL PROPERTY "${uri_sym}-versions")
+  FOREACH (known_ver ${target_versions})
+    IF (known_ver LESS version_int)
+      MESSAGE (FATAL_ERROR
+        "The module ${MODULE_URI} has already been declared with a "
+        "lower version number than ${MODULE_VERSION}. "
+        "Please call DECLARE_ZORBA_MODULE() for higher versions of the same "
+        "module first.")
+    ElSEIF (known_ver EQUAL version_int)
+      MESSAGE (FATAL_ERROR
+        "The module ${MODULE_URI} has already been declared with the "
+        "version number ${MODULE_VERSION}. You cannot declare the same "
+        "module twice.")
+    ENDIF (known_ver LESS version_int)
+  ENDFOREACH (known_ver)
+  SET_PROPERTY (GLOBAL APPEND PROPERTY "${uri_sym}-versions" ${version_int})
+
+  # Add to module manifest (except test modules).
+  IF (NOT MODULE_TEST_ONLY)
+    ADD_ZORBA_MANIFEST_ENTRY("module" ${MODULE_URI} "${MODULE_VERSION}")
+  ENDIF (NOT MODULE_TEST_ONLY)
 
   # Now, deal with associated C++ source for external functions.
 
-  IF(EXISTS "${SOURCE_FILE}.src/")
-    # all the cpp files found in the ${module_name}.xq.src
-    # directory are added to the sources list
+  SET (module_lib_target)
+  IF(MODULE_EXTRA_SOURCES OR EXISTS "${SOURCE_FILE}.src/")
+    # all the cpp files found in the ${module_name}.xq.src directory
+    # are added to the sources list, as are any cpp files found in any
+    # directory in EXTRA_SOURCES
     SET (SRC_FILES)
-    FILE(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
-      "${SOURCE_FILE}.src/*.cpp")
+    FOREACH (_src_dir "${SOURCE_FILE}.src" ${MODULE_EXTRA_SOURCES})
+      IF (NOT IS_ABSOLUTE "${_src_dir}")
+        SET (_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/${_src_dir}")
+      ENDIF (NOT IS_ABSOLUTE "${_src_dir}")
+      FILE(GLOB_RECURSE _srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 
+        "${_src_dir}/*.cpp" "${_src_dir}/*.c")
+      LIST (APPEND SRC_FILES ${_srcs})
+    ENDFOREACH (_src_dir)
 
     MESSAGE(STATUS "Add library " ${module_name})
     SET(SUFFIX)
@@ -227,9 +266,22 @@
 
     # Add the library target. Ensure that the output name is based on
     # the module *URI*'s final component.
-    SET(module_lib_target "modlib_${num_mod_targets}")
+    SET(module_lib_target "modlib${num_zorba_modules}_${module_name}")
     ADD_LIBRARY(${module_lib_target} SHARED ${SRC_FILES})
     GET_FILENAME_COMPONENT(module_filewe "${module_filename}" NAME_WE)
+    IF (MODULE_VERSION)
+      # If there's a version, insert it into the module library name
+      SET (module_filewe "${module_filewe}_${MODULE_VERSION}")
+    ENDIF (MODULE_VERSION)
+
+    # Compute the output path for the library. Note: This is copied
+    # from ADD_COPY_RULE(); probably should refactor this logic.
+    IF (${MODULE_TEST_ONLY} EQUAL 1)
+      SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_LIB_PATH")
+    ELSE (${MODULE_TEST_ONLY} EQUAL 1)
+      SET (_output_basedir "${CMAKE_BINARY_DIR}/LIB_PATH")
+    ENDIF (${MODULE_TEST_ONLY} EQUAL 1)
+
     # It seems like it would be nice to set the VERSION and/or
     # SOVERSION target properties here. However: On Windows, it
     # doesn't seem to do anything (the .rc file configured above
@@ -238,25 +290,67 @@
     # "libext.so.2.0", which is difficult to transmogrify into the
     # target filename we actually want later. So in either case, the
     # target property isn't desirable.
-    SET_TARGET_PROPERTIES(${module_lib_target} PROPERTIES
+    # FOLDER is to group IDE projects into folders.
+    SET_TARGET_PROPERTIES (${module_lib_target} PROPERTIES
       OUTPUT_NAME "${module_filewe}${SUFFIX}"
-      ${target_type}_OUTPUT_DIRECTORY
-      "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.src")
-    TARGET_LINK_LIBRARIES(${module_lib_target}
-      zorba_${ZORBA_STORE_NAME} ${MODULE_LINK_LIBRARIES})
-
-  ENDIF(EXISTS "${SOURCE_FILE}.src/")
-
-
-  # Done dealing with C++. Now, set up CMake custom commands which
-  # will copy the module source file and dynamic library to each
-  # target filename in the output directory.
-
-  IF (MODULE_OUTPUT_DIRECTORY)
-    SET (output_dir "${MODULE_OUTPUT_DIRECTORY}/${module_path}")
-  ELSE (MODULE_OUTPUT_DIRECTORY)
-    SET (output_dir "${CMAKE_BINARY_DIR}/URI_PATH/${module_path}")
-  ENDIF (MODULE_OUTPUT_DIRECTORY)
+      ${target_type}_OUTPUT_DIRECTORY "${_output_basedir}/${module_path}"
+      FOLDER "Modules"
+      )
+    TARGET_LINK_LIBRARIES(${module_lib_target} zorba_${ZORBA_STORE_NAME})
+ 
+    # Ridiculous hack: CMake doesn't seem to (reliably) set up
+    # dependencies if you specify a library to TARGET_LINK_LIBRARIES()
+    # which is the output of some other ADD_LIBRARY(). We can't solve
+    # this problem in the general case. We can work around it,
+    # however, in the specific case where the target library was
+    # generated by an earlier call to DECLARE_ZORBA_MODULE() - by
+    # remembering that output library's path and its corresponding
+    # target in a global property.
+    FOREACH (_lib ${MODULE_LINK_LIBRARIES})
+      GET_PROPERTY (_targetname GLOBAL PROPERTY "${_lib}_TARGET")
+      IF ("${_targetname}" STREQUAL "")
+	TARGET_LINK_LIBRARIES(${module_lib_target} "${_lib}")
+      ELSE ("${_targetname}" STREQUAL "")
+	TARGET_LINK_LIBRARIES(${module_lib_target} "${_targetname}")
+      ENDIF ("${_targetname}" STREQUAL "")
+    ENDFOREACH (_lib)
+
+    # Remember this library for the auto-generated module Config.cmake
+    # file. Also remember the target name for the hack mentioned
+    # above.  QQQ and what about the installed version?
+    GET_TARGET_PROPERTY (_lib_location "${module_lib_target}" LOCATION)
+    SET_PROPERTY (GLOBAL APPEND PROPERTY "${PROJECT_NAME}_LIBRARIES"
+      "${_lib_location}")
+    SET_PROPERTY (GLOBAL PROPERTY "${_lib_location}_TARGET"
+      "${module_lib_target}")
+
+    # If this is a core module, remember the target that builds the
+    # library so zorbacmd can depend on it.
+    IF (${PROJECT_NAME} STREQUAL "zorba")
+      SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_CORE_MODULE_LIB_TARGETS
+	"${module_lib_target}")
+    ENDIF (${PROJECT_NAME} STREQUAL "zorba")
+      
+    # Install the library, if it's not a TEST_ONLY module
+    IF (NOT MODULE_TEST_ONLY)
+      IF(NOT ${PROJECT_NAME} STREQUAL "zorba")
+        STRING(REPLACE "-" "_"  component_name ${PROJECT_NAME})
+        INSTALL(TARGETS ${module_lib_target}
+          ${target_type} DESTINATION ${ZORBA_NONCORE_LIB_DIR}/${module_path}
+          COMPONENT ${component_name})
+      
+      ELSE(NOT ${PROJECT_NAME} STREQUAL "zorba")
+        INSTALL(TARGETS ${module_lib_target}
+          ${target_type} DESTINATION ${ZORBA_CORE_LIB_DIR}/${module_path})
+      ENDIF(NOT ${PROJECT_NAME} STREQUAL "zorba")
+    ENDIF (NOT MODULE_TEST_ONLY)
+      
+  ENDIF(MODULE_EXTRA_SOURCES OR EXISTS "${SOURCE_FILE}.src/")
+
+  # Done dealing with C++. Now, set up rules which will copy the
+  # module source file and dynamic library to each target filename in
+  # the output directory.
+
   SET (output_files)
   SET (version_infixes)
   IF (MODULE_VERSION)
@@ -266,118 +360,379 @@
     ENDIF (patch_ver)
   ENDIF (MODULE_VERSION)
   FOREACH (version_infix "" ${version_infixes})
-    ADD_COPY_RULE ("${SOURCE_FILE}" "${output_dir}/${module_filename}"
-      "${version_infix}" "${SOURCE_FILE}")
+    ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${module_path}/${module_filename}"
+      "${version_infix}" "" 1 "${MODULE_TEST_ONLY}")
   ENDFOREACH (version_infix)
 
-  # Also copy the dynamic library from the location it was built.
-  # Because the dynamic library is only loaded after the .xq file, the
-  # exact module version is known; thus only one copy needs to be
-  # made.
-  IF (module_lib_target)
-    GET_TARGET_PROPERTY (lib_location "${module_lib_target}" LOCATION)
-    GET_FILENAME_COMPONENT (lib_filename "${lib_location}" NAME)
-    ADD_COPY_RULE ("${lib_location}" "${output_dir}/${lib_filename}"
-      "${MODULE_VERSION}" "${module_lib_target}")
-  ENDIF (module_lib_target)
-
-  # Associate these custom commands with the "all" target via a custom
-  # target. (I couldn't find any neater way to do this in CMake; you
-  # can't directly add a dependency to "all", nor is it possible to
-  # add additional file dependencies to an already-created target.)
-  ADD_CUSTOM_TARGET ("chkmod_${num_mod_targets}" ALL DEPENDS ${output_files})
-
-  ENSURE_URI_PATH_INSTALLED()
+  # Configure any module-specified config files.
+  SET (ZORBA_MODULE_RELATIVE_DIR ${module_path})
+  SET (ZORBA_MODULE_LIBFILE_WE ${module_filewe})
+  FOREACH (_config_file ${MODULE_CONFIG_FILES})
+    # Strip off .in - can't use GET_FILENAME_COMPONENT as it always removes
+    # the longest possible extension
+    STRING (REGEX REPLACE "\\.in$" "" _config_filename_we "${_config_file}")
+    IF (NOT IS_ABSOLUTE "${_config_file}")
+      SET (_config_file "${CMAKE_CURRENT_SOURCE_DIR}/${_config_file}")
+    ENDIF (NOT IS_ABSOLUTE "${_config_file}")
+    CONFIGURE_FILE (${_config_file}
+      "${CMAKE_CURRENT_BINARY_DIR}/${_config_filename_we}" @ONLY)
+  ENDFOREACH (_config_file)
+
+  # Last but not least, whip up a test case that ensures the module
+  # can at least be compiled. Don't bother for test-only modules
+  # (presumably they're there to be tested!).
+  IF (NOT MODULE_TEST_ONLY)
+    SET (module_test_query
+      "${CMAKE_CURRENT_BINARY_DIR}/test_mod_${num_zorba_modules}.xq")
+    IF (MODULE_VERSION)
+      SET (_mod_fragment "#${MODULE_VERSION}")
+    ELSE (MODULE_VERSION)
+      SET (_mod_fragment)
+    ENDIF (MODULE_VERSION)
+    FILE (WRITE "${module_test_query}"
+      "import module namespace t = \"${MODULE_URI}${_mod_fragment}\";\n1\n")
+    ADD_TEST (check_mod_${num_zorba_modules}_${module_name}
+      "${Zorba_EXE}" -f -q "${module_test_query}"
+      --module-path "${CMAKE_BINARY_DIR}/URI_PATH")
+  ENDIF (NOT MODULE_TEST_ONLY)
 
 ENDMACRO (DECLARE_ZORBA_MODULE)
 
+# Macro to see whether a given module has been declared, by URI.
+# For now this only returns a true or false value; version introspection
+# is not supported.
+MACRO (IS_ZORBA_MODULE_DECLARED IS_SET_VAR MODULE_URI)
+  # Just check for the existence of the "URI-versions" global property,
+  # as set by DECLARE_ZORBA_MODULE()
+  STRING (REGEX REPLACE "[/:#% ]" "_" uri_sym "${MODULE_URI}")
+  GET_PROPERTY (${IS_SET_VAR} GLOBAL PROPERTY "${uri_sym}-versions" SET)
+ENDMACRO (IS_ZORBA_MODULE_DECLARED)
+
 # Macro which declares a schema. This sets up the installation of the
 # schema into the URI_PATH folder so it will be found at runtime.
 #
 # Args: URI - the namespace URI of the schema
 #       FILE - path to .xsd file (if not absolute, will be resolved
 #              relative to CMAKE_CURRENT_SOURCE_DIR)
-#       OUTPUT_DIRECTORY - (optional) Base path to produce output in
+#       TEST_ONLY - (optional) Schema is for testcases only and should not
+#              be installed
 MACRO (DECLARE_ZORBA_SCHEMA)
-  PARSE_ARGUMENTS(SCHEMA "" "URI;FILE;OUTPUT_DIRECTORY" "" ${ARGN})
+  PARSE_ARGUMENTS(SCHEMA "" "URI;FILE" "TEST_ONLY" ${ARGN})
+  IF (NOT SCHEMA_FILE)
+    MESSAGE (FATAL_ERROR "'FILE' argument is required for ZORBA_DECLARE_SCHEMA()")
+  ENDIF (NOT SCHEMA_FILE)
+  IF (NOT SCHEMA_URI)
+    MESSAGE (FATAL_ERROR "'URI' argument is required for ZORBA_DECLARE_SCHEMA()")
+  ENDIF (NOT SCHEMA_URI)
   IF (NOT IS_ABSOLUTE "${SCHEMA_FILE}")
     SET (SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_FILE}")
   ELSE (NOT IS_ABSOLUTE "${SCHEMA_FILE}")
     SET (SOURCE_FILE "${SCHEMA_FILE}")
   ENDIF (NOT IS_ABSOLUTE "${SCHEMA_FILE}")
-  MANGLE_URI (${SCHEMA_URI} "xsd" schema_path schema_filename)
-
-  IF (SCHEMA_OUTPUT_DIRECTORY)
-    SET (output_dir "${SCHEMA_OUTPUT_DIRECTORY}/${schema_path}")
-  ELSE (SCHEMA_OUTPUT_DIRECTORY)
-    SET (output_dir "${CMAKE_BINARY_DIR}/URI_PATH/${schema_path}")
-  ENDIF (SCHEMA_OUTPUT_DIRECTORY)
-  ADD_CUSTOM_COMMAND (OUTPUT "${output_dir}/${schema_filename}"
-    COMMAND "${CMAKE_COMMAND}" -E copy
-    "${SOURCE_FILE}" "${output_dir}/${schema_filename}"
-    COMMENT "Copying ${SOURCE_FILE} to URI path" VERBATIM)
-  GET_PROPERTY (num_schema_targets GLOBAL PROPERTY ZORBA_SCHEMA_TARGET_COUNT)
-  IF (NOT num_schema_targets)
-    SET (num_schema_targets 0)
-  ENDIF (NOT num_schema_targets)
-  MATH (EXPR num_schema_targets "${num_schema_targets} + 1")
-  ADD_CUSTOM_TARGET ("chkschema_${num_schema_targets}" ALL
-    DEPENDS "${output_dir}/${schema_filename}")
-  SET_PROPERTY (GLOBAL PROPERTY ZORBA_SCHEMA_TARGET_COUNT ${num_schema_targets})
-
-  ENSURE_URI_PATH_INSTALLED()
+  GET_FILENAME_COMPONENT (schema_name "${SCHEMA_FILE}" NAME)
+  MANGLE_URI (${SCHEMA_URI} ".xsd" schema_path schema_filename)
+
+  # Add to schema manifest (except test schema).
+  IF (NOT SCHEMA_TEST_ONLY)
+    ADD_ZORBA_MANIFEST_ENTRY("schema" ${SCHEMA_URI} "")
+  ENDIF (NOT SCHEMA_TEST_ONLY)
+
+  ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${schema_path}/${schema_filename}"
+    "" "" 1 "${SCHEMA_TEST_ONLY}")
+
 ENDMACRO (DECLARE_ZORBA_SCHEMA)
 
-# Utility macro for setting up a build rule to copy a file to a particular
-# versioned name.
-MACRO (ADD_COPY_RULE INPUT_FILE OUTPUT_FILE VERSION_ARG DEPEND_TARGET)
+# Macro which declares a file to be loaded by URI. This sets up the
+# installation of the file into the URI_PATH folder so it will be
+# found at runtime.
+#
+# Args: URI - the URI of the file
+#       FILE - path to file (if not absolute, will be resolved
+#              relative to CMAKE_CURRENT_SOURCE_DIR)
+#       TEST_ONLY - (optional) File is for testcases only and should not
+#              be installed
+MACRO (DECLARE_ZORBA_URI_FILE)
+  # QQQ Refactor - this macro is basically identical to DECLARE_ZORBA_SCHEMA
+  PARSE_ARGUMENTS(URI_FILE "" "URI;FILE" "TEST_ONLY" ${ARGN})
+  IF (NOT URI_FILE_FILE)
+    MESSAGE (FATAL_ERROR "'FILE' argument is required for ZORBA_DECLARE_URI_FILE()")
+  ENDIF (NOT URI_FILE_FILE)
+  IF (NOT URI_FILE_URI)
+    MESSAGE (FATAL_ERROR "'URI' argument is required for ZORBA_DECLARE_URI_FILE()")
+  ENDIF (NOT URI_FILE_URI)
+  IF (NOT IS_ABSOLUTE "${URI_FILE_FILE}")
+    SET (SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${URI_FILE_FILE}")
+  ELSE (NOT IS_ABSOLUTE "${URI_FILE_FILE}")
+    SET (SOURCE_FILE "${URI_FILE_FILE}")
+  ENDIF (NOT IS_ABSOLUTE "${URI_FILE_FILE}")
+  GET_FILENAME_COMPONENT (uri_file_name "${URI_FILE_FILE}" NAME)
+  # Don't enforce any extension on general files
+  MANGLE_URI (${URI_FILE_URI} "" uri_file_path uri_file_filename)
+
+  ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${uri_file_path}/${uri_file_filename}"
+    "" "" 1 "${URI_FILE_TEST_ONLY}")
+
+ENDMACRO (DECLARE_ZORBA_URI_FILE)
+
+
+# Inform Zorba of a .jar file that should be made available on the CLASSPATH
+# of the JVM, should the JVM be started. QQQ more doc needed
+#
+# Args: FILE - path to file(s) (must be absolute)
+#       TARGET - (optional) a CMake target that must be executed in order
+#              for FILEs to be generated
+#       EXTERNAL - (optional) FILE specifies a path that should be added
+#              to CLASSPATH as-is
+#       TEST_ONLY - (optional) Jar file is for testcases only and should not
+#              be installed
+#
+# Must supply at least one value to FILE or TARGET.
+MACRO (DECLARE_ZORBA_JAR)
+  PARSE_ARGUMENTS (JAR "FILE;TARGET" "TARGET" "TEST_ONLY;EXTERNAL" ${ARGN})
+  IF (NOT JAR_FILE)
+    MESSAGE (FATAL_ERROR "'FILE' argument is required for DECLARE_ZORBA_JAR")
+  ENDIF (NOT JAR_FILE)
+
+  # Initialize classpath file and set up copy rule (once per project)
+  SET (_CP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-classpath.txt")
+  GET_PROPERTY (_known_project GLOBAL PROPERTY "${PROJECT_NAME}-jars")
+  IF (NOT _known_project)
+    FILE (REMOVE "${_CP_FILE}")
+    SET_PROPERTY (GLOBAL PROPERTY "${PROJECT_NAME}-jars" 1)
+    ADD_COPY_RULE ("LIB" "${_CP_FILE}" "jars/${PROJECT_NAME}-classpath.txt"
+      "" "" 1 "${JAR_TEST_ONLY}")
+  ENDIF (NOT _known_project)
+
+  # Iterate over all supplied jar files
+  FOREACH (_jar_file ${JAR_FILE})
+
+    IF (JAR_EXTERNAL AND NOT ZORBA_PACKAGE_EXTERNAL_JARS)
+      # Put absolute path into classpath file
+      FILE (APPEND "${_CP_FILE}" "${_jar_file}\n")
+    ELSE (JAR_EXTERNAL AND NOT ZORBA_PACKAGE_EXTERNAL_JARS)
+      # Copy jar to jars/ directory and add relative path to classpath file
+      GET_FILENAME_COMPONENT (_output_filename "${_jar_file}" NAME)
+      ADD_COPY_RULE ("LIB" "${_jar_file}" "jars/${_output_filename}" "" 
+	"${JAR_TARGET}" 1 "${JAR_TEST_ONLY}")
+      FILE (APPEND "${_CP_FILE}" "${_output_filename}\n")
+    ENDIF (JAR_EXTERNAL AND NOT ZORBA_PACKAGE_EXTERNAL_JARS)
+
+  ENDFOREACH (_jar_file)
+ENDMACRO (DECLARE_ZORBA_JAR)
+
+
+# Utility macro for setting up a build rule to copy a file to a
+# particular (possibly versioned) file in a shared directory if such a
+# file has not already been output.
+#
+# FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared
+#    directory to place output in (URI_PATH or LIB_PATH).
+# INPUT_FILE: Absolute path to file to copy.
+# OUTPUT_FILE: Relative path to output file (relative to URI_PATH).
+# VERSION_ARG: Version; may be "" for non-versioned files.
+# DEPEND_TARGET: A CMake target name upon which the copy rule should depend;
+#    may be "".
+# INSTALL: If 1, an INSTALL() directive will be executed to put the
+#    file into the install image.
+# TEST_ONLY: If 1, file is for testcases only; will be copied into
+#    TEST_URI_PATH/TEST_LIB_PATH and will not be installed.
+MACRO (ADD_COPY_RULE FILE_TYPE INPUT_FILE OUTPUT_FILE VERSION_ARG
+       DEPEND_TARGET INSTALL TEST_ONLY)
+  # Choose output base directory
+  IF (${TEST_ONLY} EQUAL 1)
+    SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_${FILE_TYPE}_PATH")
+  ELSE (${TEST_ONLY} EQUAL 1)
+    SET (_output_basedir "${CMAKE_BINARY_DIR}/${FILE_TYPE}_PATH")
+  ENDIF (${TEST_ONLY} EQUAL 1)
+
   # Compute the modified output filename by inserting VERSION_ARG (if
   # non-empty) in front of its extension.
-  GET_FILENAME_COMPONENT (_output_dir "${OUTPUT_FILE}" PATH)
+  GET_FILENAME_COMPONENT (_output_path "${OUTPUT_FILE}" PATH)
   GET_FILENAME_COMPONENT (_output_filename "${OUTPUT_FILE}" NAME_WE)
   GET_FILENAME_COMPONENT (_output_ext "${OUTPUT_FILE}" EXT)
   IF (NOT "${VERSION_ARG}" STREQUAL "")
-    SET (_output_file
-      "${_output_dir}/${_output_filename}_${VERSION_ARG}${_output_ext}")
+    SET (_output_filename "${_output_filename}_${VERSION_ARG}${_output_ext}")
   ELSE (NOT "${VERSION_ARG}" STREQUAL "")
-    SET (_output_file "${OUTPUT_FILE}")
+    SET (_output_filename "${_output_filename}${_output_ext}")
   ENDIF (NOT "${VERSION_ARG}" STREQUAL "")
+  SET (_output_file "${_output_basedir}/${_output_path}/${_output_filename}")
 
-  # We maintain a global CMake property named after the target URI
-  # which remembers all known output source files. If the output
-  # file we just computed is already on that list, that means that a
-  # module with the same URI but a higher version number has already
-  # declared that output file, so we skip it now.
-  GET_PROPERTY (target_files GLOBAL PROPERTY "${uri_sym}-output-files")
+  # We maintain a global CMake property named after the output
+  # directory which remembers all known output source files. If the
+  # output file we just computed is already on that list, that means
+  # that a module with the same URI but a higher version number has
+  # already declared that output file, so we skip it now.
+  STRING (REGEX REPLACE "[/ ]" "_" _dir_sym
+    "${_output_basedir}/${_output_path}")
+  GET_PROPERTY (target_files GLOBAL PROPERTY "${_dir_sym}-output-files")
   LIST (FIND target_files "${_output_file}" file_found)
   IF (file_found EQUAL -1)
-    LIST (APPEND output_files "${_output_file}")
-    ADD_CUSTOM_COMMAND (OUTPUT "${_output_file}"
-      COMMAND "${CMAKE_COMMAND}" -E copy
-      "${INPUT_FILE}" "${_output_file}"
-      DEPENDS "${DEPEND_TARGET}"
-      COMMENT "Copying ${INPUT_FILE} to URI path" VERBATIM)
-    SET_PROPERTY (GLOBAL APPEND PROPERTY "${uri_sym}-output-files"
+    SET_PROPERTY (GLOBAL APPEND PROPERTY "${_dir_sym}-output-files"
       "${_output_file}")
+    # Detect whether this is a core URI or not
+    IF (PROJECT_NAME STREQUAL "zorba")
+      SET (_is_core 1)
+    ELSE (PROJECT_NAME STREQUAL "zorba")
+      SET (_is_core 0)
+    ENDIF (PROJECT_NAME STREQUAL "zorba")
+
+    # Save the (input file, output file, any library dependency
+    # target, and whether this is a core or non-core file) for this
+    # rule in a global property
+    SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_URI_FILES
+      "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}" "${_is_core}")
+
+    # Also set up an INSTALL rule (unless TEST_ONLY).
+    IF ( (${INSTALL} EQUAL 1) AND (NOT ${TEST_ONLY} EQUAL 1) )
+        
+      IF(NOT _is_core)
+        STRING(REPLACE "-" "_"  component_name ${PROJECT_NAME})   
+        INSTALL (FILES "${INPUT_FILE}"
+          DESTINATION "${ZORBA_NONCORE_${FILE_TYPE}_DIR}/${_output_path}"
+          RENAME "${_output_filename}"
+          COMPONENT "${component_name}")
+          
+        IF (NOT ${component_name}_cpack)
+          SET (${component_name}_cpack 1)
+        
+          STRING(TOUPPER ${component_name} component_name2)
+          FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_GROUP \"external_modules\")\n")
+            
+          STRING(REPLACE "zorba_" "" component_display_name ${component_name})
+          STRING(REPLACE "_" " " component_display_name ${component_display_name})
+          FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_DISPLAY_NAME \"${component_display_name}\")\n")
+            
+          FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_DESCRIPTION \"Install the functionalities of the ${component_display_name}.\")\n")
+          FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_INSTALL_TYPES Full)\n")
+        ENDIF (NOT ${component_name}_cpack)  
+            
+      ELSE(NOT _is_core)
+        INSTALL (FILES "${INPUT_FILE}"
+          DESTINATION "${ZORBA_CORE_${FILE_TYPE}_DIR}/${_output_path}"
+          RENAME "${_output_filename}")
+      ENDIF(NOT _is_core)
+          
+    ENDIF ( (${INSTALL} EQUAL 1) AND (NOT ${TEST_ONLY} EQUAL 1) )
   ENDIF (file_found EQUAL -1)
 ENDMACRO (ADD_COPY_RULE)
 
-MACRO (ENSURE_URI_PATH_INSTALLED)
-  # Ensure there exactly one INSTALL() directive for the URI path.
-  GET_PROPERTY (is_installed GLOBAL PROPERTY ZORBA_URI_PATH_INSTALLED)
-  IF(NOT is_installed)
-    INSTALL(DIRECTORY "${PROJECT_BINARY_DIR}/URI_PATH/."
-      DESTINATION "include/zorba/modules/")
-    SET_PROPERTY(GLOBAL PROPERTY ZORBA_URI_PATH_INSTALLED 1)
-  ENDIF(NOT is_installed)
-ENDMACRO (ENSURE_URI_PATH_INSTALLED)
-
-# Initialize output file when first included
+# Utility macro for adding a line to either the schema or module
+# manifest file.
+MACRO (ADD_ZORBA_MANIFEST_ENTRY ENTRY_TYPE URI VERSION)
+  SET (_version_attr)
+  IF (NOT "${VERSION}" STREQUAL "")
+    SET (_version_attr " version=\"${VERSION}\"")
+  ENDIF (NOT "${VERSION}" STREQUAL "")
+  # A module or schema is "core" if it's part of the Zorba
+  # distribution. The Zorba project is named "zorba", so see if we're
+  # in that project.
+  IF ("${zorba_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
+    SET (_is_core true)
+  ELSE ("${zorba_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
+    SET (_is_core false)
+  ENDIF ("${zorba_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
+
+  FILE (APPEND "${zorba_manifest_file}"
+    "<z:${ENTRY_TYPE} isCore=\"${_is_core}\"${_version_attr}>\n")
+  FILE (APPEND "${zorba_manifest_file}"
+    "  <z:uri>${URI}</z:uri>\n")
+  FILE (APPEND "${zorba_manifest_file}"
+    "  <z:projectRoot>${PROJECT_SOURCE_DIR}</z:projectRoot>\n")
+  FILE (APPEND "${zorba_manifest_file}" "</z:${ENTRY_TYPE}>\n")
+ENDMACRO (ADD_ZORBA_MANIFEST_ENTRY)
+
+# Macro which states the project is done calling
+# DECLARE_ZORBA_MODULE() and DECLARE_ZORBA_SCHEMA(). Causes a single
+# target to be declared which will copy all declared module/schema
+# files to their corresponding output directories, with appropriate
+# dependencies. This macro will only have any effect when called by
+# the top-level project in a build.
+# Also, this function automatically generates a CMake projectConfig.cmake
+# file for the project, based on config/ExternalModuleConfig.cmake.in.
+MACRO (DONE_DECLARING_ZORBA_URIS)
+  IF (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
+    # Close out the zorba modules and schemas manifests
+    FILE (APPEND "${zorba_manifest_file}" "</z:manifest>\n")
+    IF (POLICY CMP0007)
+      CMAKE_POLICY (SET CMP0007 NEW)
+    ENDIF (POLICY CMP0007)
+    MESSAGE (STATUS "Creating check_core_uris and check_uris targets")
+    GET_PROPERTY (copy_rules GLOBAL PROPERTY ZORBA_URI_FILES)
+    SET (_output_files)
+    WHILE (copy_rules)
+      # Pop four items off the list, and set up the corresponding
+      # rule
+      LIST (GET copy_rules 0 _input_file)
+      LIST (GET copy_rules 1 _output_file)
+      LIST (GET copy_rules 2 _depend_target)
+      LIST (GET copy_rules 3 _is_core)
+      LIST (REMOVE_AT copy_rules 0 1 2 3)
+      IF (_depend_target)
+        SET (_depends "${_depend_target}")
+      ELSE (_depend_target) 
+	SET (_depends "${_input_file}")
+      ENDIF (_depend_target)
+      ADD_CUSTOM_COMMAND (OUTPUT "${_output_file}"
+        COMMAND "${CMAKE_COMMAND}" -E copy
+        "${_input_file}" "${_output_file}"
+        DEPENDS ${_depends}
+        COMMENT "Copying ${_input_file} to URI path" VERBATIM)
+      IF (_is_core)
+        LIST (APPEND _core_output_files "${_output_file}")
+      ELSE (_is_core)
+        LIST (APPEND _noncore_output_files "${_output_file}")
+      ENDIF (_is_core)
+    ENDWHILE (copy_rules)
+
+    # Targets and dependencies:
+    #   ALL depends on check_uris; check_uris depends on check_core_uris;
+    #   zorbacmd depends on check_core_uris as well as all core module
+    #   library targets.
+    ADD_CUSTOM_TARGET (check_uris ALL
+      DEPENDS ${_noncore_output_files} VERBATIM)
+    SET_TARGET_PROPERTIES(check_uris PROPERTIES FOLDER "Modules")
+    # Only create check_core_uris target and associated dependencies if
+    # there are any core URIs; there should never be any when building a
+    # standalone module project.
+    LIST (LENGTH _core_output_files _num_core)
+    IF (_num_core GREATER 0)
+      ADD_CUSTOM_TARGET (check_core_uris 
+        DEPENDS ${_core_output_files} VERBATIM)
+      ADD_DEPENDENCIES(check_uris check_core_uris)
+      ADD_DEPENDENCIES(zorbacmd check_core_uris)
+      GET_PROPERTY (_corelibs GLOBAL PROPERTY ZORBA_CORE_MODULE_LIB_TARGETS)
+      ADD_DEPENDENCIES(zorbacmd ${_corelibs})
+      SET_TARGET_PROPERTIES(check_core_uris PROPERTIES FOLDER "Modules")
+    ENDIF (_num_core GREATER 0)
+    SET_PROPERTY (GLOBAL PROPERTY ZORBA_URI_FILES)
+
+    #add 'xqdoc' and 'xqdoc-xml' targets
+    ADD_XQDOC_TARGETS()
+  ENDIF (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
+
+  # Now, do things that should be done at the end of *any* project, not
+  # just the top-level project.
+
+  # Generate project's projectConfig.cmake file.
+  # QQQ need to create an installable version of this too, once we know
+  # how installing a module package should work.
+  GET_PROPERTY (ZORBA_MODULE_LIBRARIES
+    GLOBAL PROPERTY "${PROJECT_NAME}_LIBRARIES")
+  CONFIGURE_FILE("${Zorba_EXTERNALMODULECONFIG_FILE}"
+    "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY)
+
+ENDMACRO (DONE_DECLARING_ZORBA_URIS)
+
+# Initialize expected failures and zorba modules output files when
+# first included
 set (expected_failures_file "${CMAKE_BINARY_DIR}/ExpectedFailures.xml")
-GET_PROPERTY (is_init GLOBAL PROPERTY expected_failures_initialized)
+set (zorba_manifest_file "${CMAKE_BINARY_DIR}/ZorbaManifest.xml")
+GET_PROPERTY (is_init GLOBAL PROPERTY ZorbaModule_initialized)
 IF (NOT is_init)
   file (WRITE "${expected_failures_file}" "")
-  SET_PROPERTY (GLOBAL PROPERTY expected_failures_initialized 1)
+  file (WRITE "${zorba_manifest_file}"
+    "<z:manifest xmlns:z=\"http://www.zorba-xquery.com/manifest\";>\n")
+  SET_PROPERTY (GLOBAL PROPERTY ZorbaModule_initialized 1)
 ENDIF (NOT is_init)
 
 # The expected_failure() function is used to mark a test which is currently
@@ -395,13 +750,7 @@
     set (willfail 1)
   endif (willfail)
 
-  # simplestore executable doesn't need an extension
-  SET(SUFFIX)
-  IF (NOT ${ZORBA_STORE_NAME} STREQUAL "simplestore")
-    SET(SUFFIX "_${ZORBA_STORE_NAME}")
-  ENDIF (NOT ${ZORBA_STORE_NAME} STREQUAL "simplestore")
-
-  set_tests_properties ("${testname}${SUFFIX}"
+  set_tests_properties ("${testname}"
     PROPERTIES WILL_FAIL ${willfail})
 
   # Also store the name and bug ID of this test in our output file
@@ -410,59 +759,118 @@
 
 ENDMACRO(expected_failure)
 
-# Convenience macro for adding tests in a standard format. QQQ doc!
-MACRO(ADD_TEST_DIRECTORY TEST_DIR)
+# Convenience macro for adding tests in a standard format. All test
+# cases (.xq files) in "Queries" subdirectory of the named directory
+# will be automatically added for CTest. Each test will be named
+# ${PROJECT_NAME}/<filename>, where <filename> is the path relative to
+# the Queries/ subdirectory.
+# 
+# The optional second argument exists for Windows. Normally,
+# EXPECTED_FAILURE() can be used even for tests that crash
+# (segfault). However, on Windows, when a test crashes, it pops up a
+# dialog box. This prevents tests running unattended.  Since it is not
+# possible with CMake to remove a test once added,
+# ADD_TEST_DIRECTORY() needs to be told not to add the test at all on
+# Windows platforms. Therefore, after the directory name, you may
+# additional arguments in the form (testname bugnumber testname
+# bugnumber ...) to ADD_TEST_DIRECTORY().  On Windows, the named tests
+# will be skipped entirely. On other platforms, they will be passed to
+# EXPECTED_FAILURE() with the corresponding bug number.
+#
+# This second argument should only be used for test cases that are 
+# currently *crashing* on Windows. If the test is simply failing, then
+# you should use EXPECTED_FAILURE() after calling ADD_TEST_DIRECTORY().
+#
+# Parameters:
+#   TEST_DIR - all the .xq files in this directory will be added as tests
+#   (additional args)  - expected crashing tests, as discussed above.
+MACRO (ADD_TEST_DIRECTORY TEST_DIR)
   # QQQ error-check: Queries directory exists, some tests found...
   FILE(GLOB_RECURSE TESTFILES FOLLOW_SYMLINKS
     RELATIVE "${TEST_DIR}/Queries" "${TEST_DIR}/Queries/*.xq")
+
+  # Convert extra arguments to two lists: test names and bug IDs
+  SET (crash_tests)
+  SET (crash_bugids)
+  SET (known_crashes ${ARGN})
+  LIST (LENGTH known_crashes num_crashes)
+  WHILE (num_crashes GREATER 0)
+    LIST (GET known_crashes 0 _testcase)
+    LIST (APPEND crash_tests ${_testcase})
+    LIST (GET known_crashes 1 _bugid)
+    LIST (APPEND crash_bugids ${_bugid})
+    LIST (REMOVE_AT known_crashes 0 1)
+    MATH (EXPR num_crashes "${num_crashes} - 2")
+  ENDWHILE (num_crashes GREATER 0)
+
+  IF(WIN32)
+    SET(PATH_SEP ",")
+  ELSE(WIN32)
+    SET(PATH_SEP ":")
+  ENDIF(WIN32)
   SET(TESTCOUNTER 0)
   FOREACH(TESTFILE ${TESTFILES})
     SET(TESTNAME "${PROJECT_NAME}/${TESTFILE}")
 
-    IF(WIN32)
-      SET(PATH_SEP ",")
-    ELSE(WIN32)
-      SET(PATH_SEP ":")
-    ENDIF(WIN32)
-    ZORBA_ADD_TEST(${TESTNAME} testdriver
-      "--rbkt-src" "${TEST_DIR}"
-      "--module-path" "${PROJECT_SOURCE_DIR}/src/${PATH_SEP}${PROJECT_BINARY_DIR}/src/${PATH_SEP}${SECONDARY_MODULE_PATHS}"
-      "${TESTFILE}")
-
-    MATH(EXPR TESTCOUNTER ${TESTCOUNTER}+1)
-    MATH(EXPR TESTMOD "${TESTCOUNTER}%100")
-    IF (${TESTMOD} EQUAL 0)
-      MESSAGE(STATUS "Adding another 100 Tests")
-    ENDIF (${TESTMOD} EQUAL 0)
+    # See if this test is in the known-crashing list
+    SET (_crash_bugid)
+    LIST (FIND crash_tests ${TESTNAME} _crash_idx)
+    IF (${_crash_idx} GREATER -1)
+      # Get corresponding bug ID
+      LIST (GET crash_bugids ${_crash_idx} _crash_bugid)
+      # Remove from known-crashing list
+      LIST (REMOVE_AT crash_tests ${_crash_idx})
+    ENDIF (${_crash_idx} GREATER -1)
+
+    # On Windows, skip calling ADD_TEST() for any known crashing tests
+    IF (WIN32 AND (${_crash_idx} GREATER -1) )
+      MESSAGE (STATUS "WARNING: Skipping test case ${TESTNAME} which is expected to crash - bug ${_crash_bugid}")
+    ELSE (WIN32 AND (${_crash_idx} GREATER -1) )
+      # DEPENDENCY_MODULE_PATH will always start with an appropriate
+      # path separator
+      ADD_TEST(${TESTNAME} "${Zorba_TESTDRIVER}"
+	"--rbkt-src" "${TEST_DIR}"
+	"--module-path"
+	"${CMAKE_BINARY_DIR}/URI_PATH/${PATH_SEP}${DEPENDENCY_MODULE_PATH}"
+	"${TESTFILE}")
+
+      # On non-Windows, call EXPECTED_FAILURE() for known crashes
+      IF (${_crash_idx} GREATER -1)
+	MESSAGE (STATUS "Marking test case ${TESTNAME} as expected to crash - bug ${bugid}")
+	EXPECTED_FAILURE (${TESTNAME} ${_bugid})
+      ENDIF (${_crash_idx} GREATER -1)
+
+      MATH(EXPR TESTCOUNTER ${TESTCOUNTER}+1)
+      MATH(EXPR TESTMOD "${TESTCOUNTER}%100")
+      IF (${TESTMOD} EQUAL 0)
+	MESSAGE(STATUS "Adding another 100 Tests")
+      ENDIF (${TESTMOD} EQUAL 0)
+
+    ENDIF (WIN32 AND (${_crash_idx} GREATER -1) )
+
   ENDFOREACH(TESTFILE)
+
+  # Ensure that known-crashes list is empty - otherwise some tests were
+  # named that didn't exist
+  IF (NOT "${crash_tests}" STREQUAL "")
+    MESSAGE (FATAL_ERROR "The following non-existing test cases were passed to ADD_TEST_DIRECTORY(): ${crash_tests}")
+  ENDIF (NOT "${crash_tests}" STREQUAL "")
+
   MESSAGE(STATUS "Added ${TESTCOUNTER} tests in ${TEST_DIR}")
-ENDMACRO(ADD_TEST_DIRECTORY)
-
-# Macro to install a basic CMake config file for a module. Provide a
-# source and binary directory. Result will be installed in binary
-# directory. This is a macro because it is called from two different
-# places: ZorbaUse.cmake, and Zorba's modules/CMakeLists.txt.
-MACRO(CREATE_MODULE_CONFIG name src_dir bin_dir)
-  # Set variables referenced in ExternalModuleConfig.cmake.in
-  SET(MODULE_SOURCE_DIR ${src_dir})
-  SET(MODULE_BINARY_DIR ${bin_dir})
-  CONFIGURE_FILE("${Zorba_EXTERNALMODULECONFIG_FILE}"
-    "${MODULE_BINARY_DIR}/${name}Config.cmake" @ONLY)
-ENDMACRO(CREATE_MODULE_CONFIG)
-
-# This macro easies the process of adding test for store dependent executables
-# (e.g. if the rbkt tests must be added for the executables testdriver and testdriver_firststore).
-# It adds one test for each store registered. It has the same naming convection for the target as
-# the macro that is used to generated store dependent executables (thus,
-# 'testdriver' must be passed as TARGET if the test should be executed with the executables
-# testdriver and testdriver_firststore).
+ENDMACRO (ADD_TEST_DIRECTORY)
+
+# This macro easies the process of adding test for store dependent
+# executables. It has the same naming convection for the target as the
+# macro that is used to generated store dependent executables (thus,
+# 'testdriver' must be passed as TARGET if the test should be executed
+# with the executable testdriver or testdriver_firststore).
 #
 # Syntax:
 #
-#   ZORBA_ADD_TEST_SIMPLE(NAME TARGET ...)
+#   ZORBA_ADD_TEST(NAME TARGET ...)
 #
 #     NAME - the name of the added test
-#     TARGET - target that will be executed when the test is run. For each registered store,
+#     TARGET - target that will be executed when the test is run. For the registered store,
 #              a suffix will be added to the target
 #              (similar convention than in ZORBA_GENERATE_EXE)
 #     ... - arguments that will be passed to the target
@@ -515,59 +923,97 @@
 #if the external module is not compiled in zorba, it will set the variables to point to executables and files in the installed zorba
 #if you want to use the files from your local zorba build, you have to set the variables manually
 #the variables are:
-# ZORBA_XQDOC_MAIN_EXTMODULES_XML_XQ - points to file xqdoc-main-extmodules-xml.xq
-# ZORBA_XQDOC_MAIN_EXTMODULES_HTML_XQ - points to file xqdoc-main-extmodules-html.xq
-# ZORBA_EXTMODULE_XQDOC_OUTPUT_DIR - points to the output dir for xml and html
+# ZORBA_XQDOC_XML_XQ  - points to file xqdoc-xml.xq
+# ZORBA_XQDOC_HTML_XQ - points to file xqdoc-html.xq
+# ZORBA_XQDOC_OUTPUT_DIR - points to the output dir for xml and html
 # ZORBA_XHTML_REQUISITES_PATH - points to the dir containing the html requisites (images, lib, styles, templates dirs)
-# ZORBA_EXE_SCRIPT - points to zorba.exe (or zorba.bat)
+# Zorba_EXE - points to zorba.exe (or zorba.bat)
 MACRO (ADD_XQDOC_TARGETS)
-
-  MESSAGE(STATUS "ADD_XQDOC_TARGETS for project ${PROJECT_NAME}")
-
-  # Add the xqdoc command for which a working zorba cmd is required.
-  SET(ZORBA_EXE_SCRIPT  ${Zorba_DIR}/bin/zorba CACHE PATH "Path to installed zorba.exe")
-
-  FILE(GLOB_RECURSE LOCAL_MODULES  ${PROJECT_SOURCE_DIR}/src/*.xq)
-  SET(ZORBA_XQDOC_MAIN_EXTMODULES_XML_XQ  ${Zorba_DIR}/xqdoc/generator/xqdoc-main-extmodules-xml.xq CACHE PATH "The xqdoc xml generator for external modules")
-  SET(ZORBA_XQDOC_MAIN_EXTMODULES_HTML_XQ  ${Zorba_DIR}/xqdoc/generator/xqdoc-main-extmodules-html.xq CACHE PATH "The xqdoc html generator for external modules")
-  SET(ZORBA_EXTMODULE_XQDOC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Dir where to store xqdoc generated files, xml and html")
-  ADD_CUSTOM_TARGET(xqdoc-xml-${PROJECT_NAME}
-    ${ZORBA_EXE_SCRIPT}
-      --omit-xml-declaration
-      -f
-      -q "${ZORBA_XQDOC_MAIN_EXTMODULES_XML_XQ}"
-      -e "\"modulePath:=${PROJECT_SOURCE_DIR}/src\""
-      -e "\"xqdocBuildPath:=${ZORBA_EXTMODULE_XQDOC_OUTPUT_DIR}\""
-      DEPENDS ${LOCAL_MODULES}
-      COMMENT "Building XQDoc XML documentation for ${PROJECT_NAME} module..."
-  )
-  #SET_TARGET_PROPERTIES(xqdoc-xml-${PROJECT_NAME} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
-  IF(TARGET xqdoc-xml)
-    ADD_DEPENDENCIES(xqdoc-xml-${PROJECT_NAME} zorba_simplestore)
-    ADD_DEPENDENCIES(xqdoc-xml-${PROJECT_NAME} xqdoc-xml)
-    ADD_DEPENDENCIES(xqdoc xqdoc-xml-${PROJECT_NAME})
-  ENDIF(TARGET xqdoc-xml)
-
-  SET(ZORBA_XHTML_REQUISITES_PATH ${Zorba_DIR}/xqdoc/requisites CACHE PATH "Dir where to the html requisites are stored")
-  ADD_CUSTOM_TARGET(xqdoc-${PROJECT_NAME}
-    ${ZORBA_EXE_SCRIPT}
-      --omit-xml-declaration
-      -f
-      -q "${ZORBA_XQDOC_MAIN_EXTMODULES_HTML_XQ}"
-      -e "\"modulePath:=${PROJECT_SOURCE_DIR}/src\""
+  MESSAGE(STATUS "ADD_XQDOC_TARGETS")
+
+  SET(ZORBA_XQDOC_XML_XQ
+    ${CMAKE_BINARY_DIR}/xqdoc/generator/xqdoc-xml.xq
+      CACHE PATH
+      "The XQDoc XML generator for external modules.")
+  SET(ZORBA_XQDOC_HTML_XQ
+    ${CMAKE_BINARY_DIR}/xqdoc/generator/xqdoc-html.xq
+      CACHE PATH
+      "The XQDoc XHTML generator for external modules.")
+
+  ADD_CUSTOM_TARGET(xqdoc-xml
+    ${Zorba_EXE}
+      --omit-xml-declaration
+      -f
+      -q "${ZORBA_XQDOC_XML_XQ}"
+      -e "\"zorbaManifestPath:=${zorba_manifest_file}\""
+      -e "\"xqdocBuildPath:=${CMAKE_BINARY_DIR}/doc/zorba/xqdoc\""
+      DEPENDS ${LOCAL_MODULES} ${zorba_manifest_file}
+      COMMENT "Building XQDoc XML documentation ..."
+  )
+  MESSAGE(STATUS "  added target xqdoc-xml")
+  ADD_DEPENDENCIES(xqdoc-xml zorbacmd check_core_uris)
+
+  SET_TARGET_PROPERTIES (xqdoc-xml PROPERTIES
+    EXCLUDE_FROM_DEFAULT_BUILD 1
+    FOLDER "Docs"
+  )
+
+  SET(ZORBA_XHTML_REQUISITES_PATH
+      ${CMAKE_SOURCE_DIR}/doc/zorba/xqdoc
+      CACHE PATH
+      "Dir where to the XHTML requisites are stored.")
+  ADD_CUSTOM_TARGET(xqdoc
+    ${Zorba_EXE}
+      --omit-xml-declaration
+      -f
+      -q "${ZORBA_XQDOC_HTML_XQ}"
+      -e "\"zorbaManifestPath:=${zorba_manifest_file}\""
       -e "\"xhtmlRequisitesPath:=${ZORBA_XHTML_REQUISITES_PATH}\""
-      -e "\"xqdocBuildPath:=${ZORBA_EXTMODULE_XQDOC_OUTPUT_DIR}\""
-      -e "\"examplePath:=${Zorba_DIR}/..\""
+      -e "\"xqdocBuildPath:=${CMAKE_BINARY_DIR}/doc/zorba/xqdoc\""
       -e "\"zorbaVersion:=${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}\""
-      COMMENT "Building XQDoc documentation for the ${PROJECT_NAME} module ..."
-  )
-  ADD_DEPENDENCIES(xqdoc-${PROJECT_NAME} xqdoc-xml-${PROJECT_NAME})
-  SET_TARGET_PROPERTIES(xqdoc-${PROJECT_NAME} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
-
+      DEPENDS ${zorba_manifest_file}
+      COMMENT "Building XQDoc XHTML documentation ..."
+  )
+  MESSAGE(STATUS "  added target xqdoc")
+  ADD_DEPENDENCIES(xqdoc xqdoc-xml modules_svg)
+  SET_TARGET_PROPERTIES (xqdoc PROPERTIES
+    EXCLUDE_FROM_DEFAULT_BUILD 1
+    FOLDER "Docs"
+  )
+  ADD_TEST( test/xqdoc/make_xqdoc
+      ${Zorba_EXE}
+      --omit-xml-declaration
+      -f
+      -q "${CMAKE_SOURCE_DIR}/test/rbkt/Queries/zorba/xqdoc/make_xqdoc.xqi"
+      -e "zorbaManifestPath:=${zorba_manifest_file}"
+      -e "xhtmlRequisitesPath:=${ZORBA_XHTML_REQUISITES_PATH}"
+      -e "xqdocBuildPath:=${CMAKE_BINARY_DIR}/test/rbkt/QueryResults/zorba/xqdoc"
+      -e "zorbaVersion:=${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}"
+  )
+  SET_TESTS_PROPERTIES("test/xqdoc/make_xqdoc" PROPERTIES PASS_REGULAR_EXPRESSION "XQDoc generated successfully!")
+  MESSAGE(STATUS "  added test test/xqdoc/make_xqdoc")
+  MESSAGE(STATUS "ADD_XQDOC_TARGETS END")
 ENDMACRO(ADD_XQDOC_TARGETS)
 
-#macro to be called from CMakeLists.txt in the root of external module
-#should be called by all external modules that comply with this build system
-MACRO (SETUP_EXTERNAL_MODULE)
- ADD_XQDOC_TARGETS()
-ENDMACRO(SETUP_EXTERNAL_MODULE)
+
+# Macro that takes care of the CMake module path in a project. This will prepend
+# "cmake_modules" and "cmake_modules/Windows" to the existing CMAKE_MODULE_PATH
+MACRO (SET_CMAKE_MODULE_PATH)
+
+  # first we prepend the "cmake_modules" directory in the project root
+  SET (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules ${CMAKE_MODULE_PATH})
+
+  # now we prepend the "cmake_modules/Windows" directory in the project root
+  # this takes care about the finding and installing DLL for these libraries
+  IF (WIN32)
+    # Since the user can install libraries on Windows at any location we use
+    # proxy modules that try to guess first the location of the required third
+    # party libraries. This will search in order in:
+    # 1. the path pointed by ZORBA_THIRD_PARTY_REQUIREMENTS
+    # 2. the Program Files directory available on the users computer
+    # 3. the PATH environment variable
+    # The logic is implemented by the macros in the ProxyFindModule.cmake module.
+    SET (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/Windows ${CMAKE_MODULE_PATH})
+  ENDIF (WIN32)
+  
+ENDMACRO (SET_CMAKE_MODULE_PATH)

=== modified file 'cmake_modules/ZorbaRuntimeGenerator.cmake'
--- cmake_modules/ZorbaRuntimeGenerator.cmake	2011-07-02 17:16:37 +0000
+++ cmake_modules/ZorbaRuntimeGenerator.cmake	2012-09-27 18:04:43 +0000
@@ -53,7 +53,7 @@
     COMMAND "${CMAKE_COMMAND}"
     -D "source_dir=\"${CMAKE_SOURCE_DIR}\""
     -D "binary_dir=\"${CMAKE_BINARY_DIR}\""
-    -D "ZORBA_EXE=\"${ZORBA_EXE_SCRIPT}\"" 
+    -D "ZORBA_EXE=\"${ZORBA_EXE}\"" 
     -D "query=\"${GEN_QUERY}\"" 
     -D "gen_file=\"${OUTPUT}\""
     -D "extvars:STRING=\"${EXTVARS}\""
@@ -62,10 +62,25 @@
     MAIN_DEPENDENCY ${GEN_QUERY}
     DEPENDS ${ABSOLUTE_SPEC_FILES} ${EXTRA_DEPS}
     ${GEN_SCRIPT} ${CMAKE_SOURCE_DIR}/cmake_modules/ZorbaRuntimeGenerator.cmake)
-  ADD_TEST("RuntimeGeneratorTest-${TEST_NAME}" "${CMAKE_COMMAND}"
+#MESSAGE(STATUS  "     ADD_CUSTOM_COMMAND(OUTPUT \"${OUTPUT}\" ")
+#MESSAGE(STATUS  "       COMMAND \"${CMAKE_COMMAND}\" ")
+#MESSAGE(STATUS  "       -D \"source_dir=${CMAKE_SOURCE_DIR}\" ")
+#MESSAGE(STATUS  "       -D \"binary_dir=${CMAKE_BINARY_DIR}\" ")
+#MESSAGE(STATUS  "       -D \"ZORBA_EXE=${ZORBA_EXE}\"  ")
+#MESSAGE(STATUS  "       -D \"query=${GEN_QUERY}\"  ")
+#MESSAGE(STATUS  "       -D \"gen_file=${OUTPUT}\" ")
+#MESSAGE(STATUS  "       -D \"extvars:STRING=${EXTVARS}\" ")
+#MESSAGE(STATUS  "       -D \"files:STRING=${SPEC_FILES}\" ")
+#MESSAGE(STATUS  "       -P \"${GEN_SCRIPT}\" ")
+#MESSAGE(STATUS  "       MAIN_DEPENDENCY ${GEN_QUERY} ")
+#MESSAGE(STATUS  "       DEPENDS ${ABSOLUTE_SPEC_FILES} ${EXTRA_DEPS} ")
+#MESSAGE(STATUS  "       ${GEN_SCRIPT} ${CMAKE_SOURCE_DIR}/cmake_modules/ZorbaRuntimeGenerator.cmake) ")
+#MESSAGE(STATUS  "***************************************************************************************** ")
+
+ADD_TEST("RuntimeGeneratorTest-${TEST_NAME}" "${CMAKE_COMMAND}"
     -D "source_dir=${CMAKE_SOURCE_DIR}"
     -D "binary_dir=${CMAKE_BINARY_DIR}"
-    -D "ZORBA_EXE=${ZORBA_EXE_SCRIPT}"
+    -D "ZORBA_EXE=${ZORBA_EXE}"
     -D "query=${GEN_QUERY}" 
     -D "gen_file=${OUTPUT}"
     -D "extvars:STRING=${EXTVARS}"
@@ -92,7 +107,7 @@
     COMMAND "${CMAKE_COMMAND}"
     -D "source_dir=\"${CMAKE_SOURCE_DIR}\""
     -D "binary_dir=\"${CMAKE_BINARY_DIR}\""
-    -D "ZORBA_EXE=\"${ZORBA_EXE_SCRIPT}\"" 
+    -D "ZORBA_EXE=\"${ZORBA_EXE}\"" 
     -D "query=\"${GEN_QUERY}\"" 
     -D "gen_file=\"${OUTPUT}\""
     -D "extvars:STRING=\"${EXTVARS}\""
@@ -104,7 +119,7 @@
   ADD_TEST("RuntimeGeneratorTest-${TEST_NAME}" "${CMAKE_COMMAND}"
     -D "source_dir=${CMAKE_SOURCE_DIR}"
     -D "binary_dir=${CMAKE_BINARY_DIR}"
-    -D "ZORBA_EXE=${ZORBA_EXE_SCRIPT}"
+    -D "ZORBA_EXE=${ZORBA_EXE}"
     -D "query=${GEN_QUERY}" 
     -D "gen_file=${OUTPUT}"
     -D "extvars:STRING=${EXTVARS}"

=== modified file 'config/CMakeLists.txt'
--- config/CMakeLists.txt	2011-06-16 19:30:58 +0000
+++ config/CMakeLists.txt	2012-09-27 18:04:43 +0000
@@ -13,29 +13,34 @@
 # limitations under the License.
 
 
-# Subdir of the installed "share" directory for CMake files, relative
-# to CMAKE_INSTALL_PREFIX. QQQ probably should be set in top-level
-# CMakeLists.
-SET(CURRENCY_SYMBOL "$")
-
-SET(ZORBA_SHARE_DIR "share/zorba-${ZORBA_VERSION}/cmake")
-
+# Calculate ZORBA_ROOT, which is the base dir of the Zorba installation.
+# Zorba_DIR will be set to the directory containing ZorbaConfig.cmake,
+# which is in a different place on Windows than Unix, so work from there.
+IF (WIN32)
+  # ZORBA_ROOT/cmake/ZorbaConfig.cmake
+  SET (ZORBA_ROOT "\${Zorba_DIR}/..")
+ELSE (WIN32)
+  # ZORBA_ROOT/share/zorba-VERSION/cmake/ZorbaConfig.cmake
+  SET (ZORBA_ROOT "\${Zorba_DIR}/../../..")
+ENDIF (WIN32)
 
 # Create ZorbaConfig.cmake file for projects that wish to build
-# against the installed Zorba project
-
- 
-SET(Zorba_INCLUDE_DIRS "${CURRENCY_SYMBOL}{Zorba_DIR}/include")
-SET(Zorba_LIBRARY_DIRS "${CURRENCY_SYMBOL}{Zorba_DIR}/lib")
-SET(Zorba_USE_FILE "${CURRENCY_SYMBOL}{Zorba_DIR}/${ZORBA_SHARE_DIR}/ZorbaUse.cmake")
-SET(Zorba_CMAKE_MODULES_DIR "${CURRENCY_SYMBOL}{Zorba_DIR}/${ZORBA_SHARE_DIR}")
-SET(Zorba_TESTDRIVER "${CURRENCY_SYMBOL}{Zorba_DIR}/bin/testdriver")
+# against the installed Zorba project.
+SET(Zorba_INCLUDE_DIRS "${ZORBA_ROOT}/include")
+SET(Zorba_LIBRARY_DIRS "${ZORBA_ROOT}/lib")
+SET(Zorba_USE_FILE "${ZORBA_ROOT}/${ZORBA_CMAKE_DIR}/ZorbaUse.cmake")
+SET(Zorba_CMAKE_MODULES_DIR "${ZORBA_ROOT}/${ZORBA_CMAKE_DIR}")
+SET(Zorba_TESTDRIVER "${ZORBA_ROOT}/bin/testdriver")
+SET(Zorba_EXE_PATH "${ZORBA_ROOT}/bin/zorba")
 SET(Zorba_EXTERNALMODULECONFIG_FILE
-  "${CURRENCY_SYMBOL}{Zorba_DIR}/${ZORBA_SHARE_DIR}/ExternalModuleConfig.cmake.in")
-  
+  "${ZORBA_ROOT}/${ZORBA_CMAKE_DIR}/ExternalModuleConfig.cmake.in")   
+SET(Zorba_NONCORE_URI_DIR "${ZORBA_ROOT}/${ZORBA_NONCORE_URI_DIR}")
+SET(Zorba_NONCORE_LIB_DIR "${ZORBA_ROOT}/${ZORBA_NONCORE_LIB_DIR}")
+
 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaConfig.cmake.in"
   "${CMAKE_CURRENT_BINARY_DIR}/ZorbaConfig.cmake" @ONLY)
-INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/ZorbaConfig.cmake" DESTINATION .)
+INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/ZorbaConfig.cmake"
+ DESTINATION ${ZORBA_CMAKE_DIR})
 
 # Create ZorbaConfig.cmake file for projects that wish to build
 # against this Zorba source installation.
@@ -46,13 +51,26 @@
 SET(Zorba_CMAKE_MODULES_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 SET(Zorba_USE_FILE     "${CMAKE_CURRENT_SOURCE_DIR}/ZorbaUse.cmake")
 GET_TARGET_PROPERTY(Zorba_TESTDRIVER testdriver LOCATION)
-# Note: We also set this one into the parent's scope, so that it is
-# available for modules/CMakeLists.txt.
+
+IF (WIN32)
+  IF (MSVC_IDE)
+    STRING (REPLACE "/${CMAKE_CFG_INTDIR}" "" Zorba_TESTDRIVER ${Zorba_TESTDRIVER})
+  ENDIF (MSVC_IDE)
+  STRING (REPLACE ".exe" ".bat" Zorba_TESTDRIVER ${Zorba_TESTDRIVER})
+ENDIF (WIN32)
+
+SET(Zorba_EXE_PATH "${ZORBA_EXE}")
+SET(Zorba_EXTERNALMODULECONFIG_FILE
+  "${CMAKE_CURRENT_SOURCE_DIR}/ExternalModuleConfig.cmake.in")
+# Note: We also set these two into the parent's scope, so that it is
+# available for the rest of the build.
 SET(Zorba_EXTERNALMODULECONFIG_FILE
   "${CMAKE_CURRENT_SOURCE_DIR}/ExternalModuleConfig.cmake.in"
   PARENT_SCOPE)
-SET(Zorba_EXTERNALMODULECONFIG_FILE
-  "${CMAKE_CURRENT_SOURCE_DIR}/ExternalModuleConfig.cmake.in")
+SET(Zorba_EXE "${ZORBA_EXE}" PARENT_SCOPE)
+SET(Zorba_NONCORE_URI_DIR "${ZORBA_NONCORE_URI_DIR}")
+SET(Zorba_NONCORE_LIB_DIR "${ZORBA_NONCORE_LIB_DIR}")
+
 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaConfig.cmake.in"
   "${CMAKE_BINARY_DIR}/ZorbaConfig.cmake" @ONLY)
 
@@ -62,22 +80,23 @@
   "${CMAKE_BINARY_DIR}/ZorbaConfigVersion.cmake" @ONLY)
 INSTALL(FILES
   "${CMAKE_BINARY_DIR}/ZorbaConfigVersion.cmake"
-  DESTINATION ${ZORBA_SHARE_DIR})
+  DESTINATION ${ZORBA_CMAKE_DIR})
 
 
 # Install ZorbaUse.cmake file for sharing build settings and macros
 # with dependent projects.
 INSTALL(FILES
   "${CMAKE_CURRENT_SOURCE_DIR}/ZorbaUse.cmake"
-  DESTINATION ${ZORBA_SHARE_DIR})
+  DESTINATION ${ZORBA_CMAKE_DIR})
 
 
 # Install ExternalModuleConfig.cmake.in as-is (will be configured by
 # the modules themselves)
 INSTALL(FILES
   "${CMAKE_CURRENT_SOURCE_DIR}/ExternalModuleConfig.cmake.in"
-  DESTINATION ${ZORBA_SHARE_DIR})
+  DESTINATION ${ZORBA_CMAKE_DIR})
 
 
 ADD_SUBDIRECTORY(fedora)
 ADD_SUBDIRECTORY(debian)
+ADD_SUBDIRECTORY(thesaurus)

=== modified file 'config/ExternalModuleConfig.cmake.in'
--- config/ExternalModuleConfig.cmake.in	2011-06-24 19:58:33 +0000
+++ config/ExternalModuleConfig.cmake.in	2012-09-27 18:04:43 +0000
@@ -12,12 +12,29 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-IF(WIN32)
-  SET(PATH_SEP ",")
-ELSE(WIN32)
-  SET(PATH_SEP ":")
-ENDIF(WIN32)
-
-# QQQ When all the module versioning and external-module work is
-# complete, this should contain ONLY MODULE_BINARY_DIR/modules.
-SET(SECONDARY_MODULE_PATHS "${SECONDARY_MODULE_PATHS}${PATH_SEP}@MODULE_SOURCE_DIR@/src/${PATH_SEP}@MODULE_BINARY_DIR@/src/${PATH_SEP}@MODULE_BINARY_DIR@/modules/")
+IF (WIN32)
+  SET (PATH_SEP ",")
+ELSE (WIN32)
+  SET (PATH_SEP ":")
+ENDIF (WIN32)
+
+# Probably should have separate URI and LIB paths here someday; will
+# require testdriver to accept --uri-path and --lib-path args
+# Note that this path is meaningless if the module is installed; see
+# bug 966999.
+SET (DEPENDENCY_MODULE_PATH 
+  "${DEPENDENCY_MODULE_PATH}${PATH_SEP}@PROJECT_BINARY_DIR@/URI_PATH/${PATH_SEP}${DEPENDENCY_LIB_PATH}${PATH_SEP}@PROJECT_BINARY_DIR@/LIB_PATH/")
+
+# Dynamic libraries created by this project to link against
+SET (@PROJECT_NAME@_LIBRARIES @ZORBA_PROJECT_LIBRARIES@ @ZORBA_MODULE_LIBRARIES@)
+
+# Include directories exported by this project
+SET (@PROJECT_NAME@_INCLUDE_DIRS @ZORBA_PROJECT_INCLUDE_DIRS@)
+
+# Offer a "use file" to the user of this module. For most module
+# packages, this is unnecessary. However it can be utilized by
+# advanced packages which wish to, for example, export a C++ header
+# file to dependent packages. As above, note that this currently is
+# non-functional if this module package is installed; this will only
+# work from a project build directory.
+SET (@PROJECT_NAME@_USE_FILE "@ZORBA_PROJECT_USE_FILE@")

=== modified file 'config/ZorbaConfig.cmake.in'
--- config/ZorbaConfig.cmake.in	2011-07-05 14:39:33 +0000
+++ config/ZorbaConfig.cmake.in	2012-09-27 18:04:43 +0000
@@ -17,36 +17,55 @@
 #  Zorba_INCLUDE_DIRS - include directories for Zorba
 #  Zorba_LIBRARY_DIRS - library directories for Zorba (normally not used!)
 #  Zorba_LIBRARIES    - libraries to link against QQQ
-#  Zorba_EXECUTABLE   - the Zorba executable QQQ
+#  Zorba_EXE          - the Zorba executable (or .bat script inside Zorba build)
 #  Zorba_TESTDRIVER   - the Zorba testdriver executable
-#  ZORBA_STORE_NAMES  - all available store implementations
+#  ZORBA_STORE_NAME   - the name of the store in this installation
 #  Zorba_USE_FILE     - file which projects depending on Zorba should INCLUDE()
 #  Zorba_EXTERNALMODULECONFIG_FILE - file which modules should use to
 #    export their module paths for dependent modules
 
+MACRO (SET_NORMALIZED VARNAME VALUE)
+  SET (_tmp)
+  FOREACH (_path ${VALUE})
+    GET_FILENAME_COMPONENT (_abspath ${_path} ABSOLUTE)
+    LIST (APPEND _tmp ${_abspath})
+  ENDFOREACH (_path)
+  SET (${VARNAME} ${_tmp} ${ARGN})
+ENDMACRO (SET_NORMALIZED)
+
 # Pass through some variables from main Zorba CMake configuration.
-SET(ZORBA_STORE_NAMES "@ZORBA_STORE_NAMES@")
-SET(ZORBA_VERSION "@ZORBA_VERSION@")
-SET(ZORBA_STORE_NAME "@ZORBA_STORE_NAME@")
+SET (ZORBA_VERSION "@ZORBA_VERSION@" CACHE STRING "Zorba's version" FORCE)
+SET (ZORBA_STORE_NAME "@ZORBA_STORE_NAME@" CACHE STRING
+  "Name of the store implementation this Zorba was built with" FORCE)
 
 # Tell the user project where to find our headers, libraries, and
 # CMake modules
-SET(Zorba_INCLUDE_DIRS "@Zorba_INCLUDE_DIRS@")
-SET(Zorba_LIBRARY_DIRS "@Zorba_LIBRARY_DIRS@")
-SET(Zorba_CMAKE_MODULES_DIR "@Zorba_CMAKE_MODULES_DIR@")
-SET(Zorba_TESTDRIVER "@Zorba_TESTDRIVER@")
+SET_NORMALIZED (Zorba_INCLUDE_DIRS "@Zorba_INCLUDE_DIRS@")
+SET_NORMALIZED (Zorba_LIBRARY_DIRS "@Zorba_LIBRARY_DIRS@")
+SET_NORMALIZED (Zorba_CMAKE_MODULES_DIR "@Zorba_CMAKE_MODULES_DIR@")
+SET_NORMALIZED (Zorba_TESTDRIVER "@Zorba_TESTDRIVER@" CACHE PATH
+  "Path to Zorba's testdriver" FORCE)
+SET_NORMALIZED (Zorba_EXE "@Zorba_EXE_PATH@" CACHE PATH "Path to Zorba executable" FORCE)
 
+# Tell the user project where (non-core) modules are installed. Note:
+# These variables are all-uppercase because they are also used
+# internally by Zorba's build.
+SET (ZORBA_NONCORE_URI_DIR "@Zorba_NONCORE_URI_DIR@"
+  CACHE STRING "Path to Zorba to non-core modules/schemas in this Zorba installation" FORCE)
+SET (ZORBA_NONCORE_LIB_DIR "@Zorba_NONCORE_LIB_DIR@"
+  CACHE STRING "Path to Zorba to non-core libraries in this Zorba installation" FORCE)
 
 # Tell the user project where to find the "USE" file.
 # This file uses the above settings to configure the user project.
-SET(Zorba_USE_FILE "@Zorba_USE_FILE@")
+SET_NORMALIZED (Zorba_USE_FILE "@Zorba_USE_FILE@")
 
 # Set the path to ExternalModuleConfig.cmake.in, used by module
 # projects to export their module paths.
-SET(Zorba_EXTERNALMODULECONFIG_FILE "@Zorba_EXTERNALMODULECONFIG_FILE@")
+SET_NORMALIZED (Zorba_EXTERNALMODULECONFIG_FILE
+  "@Zorba_EXTERNALMODULECONFIG_FILE@")
 
 IF(NOT Zorba_FIND_QUIETLY)
-  MESSAGE(STATUS "Found Zorba @ZORBA_VERSION@ (stores: ${ZORBA_STORE_NAMES})")
+  MESSAGE(STATUS "Found Zorba @ZORBA_VERSION@ (store: ${ZORBA_STORE_NAME})")
   MESSAGE(STATUS " - Include dirs: ${Zorba_INCLUDE_DIRS}")
   MESSAGE(STATUS " - Library dirs: ${Zorba_LIBRARY_DIRS}")
 ENDIF(NOT Zorba_FIND_QUIETLY)

=== modified file 'config/ZorbaUse.cmake'
--- config/ZorbaUse.cmake	2011-05-19 05:06:55 +0000
+++ config/ZorbaUse.cmake	2012-09-27 18:04:43 +0000
@@ -31,7 +31,3 @@
   # Load Zorba module support macros.
   INCLUDE("${Zorba_CMAKE_MODULES_DIR}/Windows/ProxyFindModule.cmake")
 ENDIF(WIN32)
-
-# Generate project's projectConfig.cmake file.
-CREATE_MODULE_CONFIG(${PROJECT_NAME} "${PROJECT_SOURCE_DIR}"
-  "${PROJECT_BINARY_DIR}")

=== modified file 'config/debian/ZorbaDebianDependencies.cmake.in'
--- config/debian/ZorbaDebianDependencies.cmake.in	2011-02-23 12:49:34 +0000
+++ config/debian/ZorbaDebianDependencies.cmake.in	2012-09-27 18:04:43 +0000
@@ -1,1 +1,16 @@
+# 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.
+#
+
 SET(DEBIAN_REQUIRED_DEPENDENCIES "@debian-required-packages@")

=== added directory 'config/thesaurus'
=== added file 'config/thesaurus/CMakeLists.txt'
--- config/thesaurus/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ config/thesaurus/CMakeLists.txt	2012-09-27 18:04:43 +0000
@@ -0,0 +1,26 @@
+# 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.
+
+#Add wordnet-en.zth to the correct directory
+IF(ZORBA_WITH_THESAURUS)
+  CONFIGURE_FILE(
+    "${CMAKE_CURRENT_SOURCE_DIR}/wordnet-en.zth"
+    "${CMAKE_BINARY_DIR}/LIB_PATH/edu/princeton/wordnet/wordnet-en.zth" 
+    COPYONLY
+  )
+
+  INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/wordnet-en.zth"
+    DESTINATION "${ZORBA_CORE_LIB_DIR}/edu/princeton/wordnet"
+    COMPONENT thesaurus)
+ENDIF(ZORBA_WITH_THESAURUS)

=== added file 'config/thesaurus/wordnet-en.zth'
Binary files config/thesaurus/wordnet-en.zth	1970-01-01 00:00:00 +0000 and config/thesaurus/wordnet-en.zth	2012-09-27 18:04:43 +0000 differ
=== modified file 'doc/CMakeLists.txt'
--- doc/CMakeLists.txt	2011-06-28 17:47:40 +0000
+++ doc/CMakeLists.txt	2012-09-27 18:04:43 +0000
@@ -23,12 +23,13 @@
 # - manually written documentation (also generated by doxygen; build instructions, ...)
 # - xquery api documentation generated by zorba (xqdoc; all modules in the modules directory)
 # - code documentation
-ADD_CUSTOM_TARGET(doc
-COMMENT "Building Zorba documentation...")
-
-SET_TARGET_PROPERTIES(doc PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
-
-# generate xqdoc documentation
+ADD_CUSTOM_TARGET(doc COMMENT "Building Zorba documentation...")
+SET_TARGET_PROPERTIES (doc PROPERTIES
+  EXCLUDE_FROM_DEFAULT_BUILD 1
+  FOLDER "Docs"
+)
+
+# generate Zorba Doxygen documentation and XQDoc documentation for Zorba modules
 ADD_SUBDIRECTORY(zorba)
 
 FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/zorba/html)
@@ -37,12 +38,15 @@
 ADD_SUBDIRECTORY(cxx)
 ADD_SUBDIRECTORY(c)
 
-IF(ZORBA_USE_SWIG AND BUILDING_SIMPLESTORE)
+IF (SWIG_FOUND)
   ADD_SUBDIRECTORY(java)
+  ADD_SUBDIRECTORY(xqj)
   ADD_SUBDIRECTORY(python)
   ADD_SUBDIRECTORY(ruby)
   ADD_SUBDIRECTORY(php)
-ENDIF(ZORBA_USE_SWIG AND BUILDING_SIMPLESTORE)
+  ADD_SUBDIRECTORY(csharp)
+  
+ENDIF (SWIG_FOUND)
 
 # generate Doxygen code documentation
 ADD_SUBDIRECTORY(code)
@@ -61,38 +65,65 @@
   FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ruby/html)
 ENDIF (SWIG_FOUND)
 
-INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cxx/html 
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cxx/html
+        COMPONENT "doc" 
         DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/cxx)
 
-INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/c/html 
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/c/html  
+        COMPONENT "doc"
         DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/c)
 
-INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/code/html 
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/code/html  
+        COMPONENT "doc"
         DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/code)
 
 IF (SWIG_FOUND)
   INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/java/html 
-          DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/java)
+        COMPONENT "doc"
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/java)
   
-  INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/php/html 
-          DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/php)
+  INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/php/html
+        COMPONENT "doc" 
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/php)
   
   INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python/html 
-          DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/python)
+        COMPONENT "doc"
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/python)
   
-  INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ruby/html 
-          DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/ruby)
+  INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ruby/html  
+        COMPONENT "doc"
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/ruby)
+
+  INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/xqj/html 
+        COMPONENT "doc"
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/xqj)
+        
+  INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/csharp/html 
+        COMPONENT "doc"
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/csharp)        
 ENDIF (SWIG_FOUND)
 
 INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/zorba/html 
+        COMPONENT "doc"
         DESTINATION
         share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/zorba)
 
 INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/zorba/xqdoc 
+        COMPONENT "doc"
         DESTINATION
-        share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/zorba)
+        share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/zorba
+        PATTERN "*.vcxproj" EXCLUDE
+        PATTERN "*.vcxproj.*" EXCLUDE
+        PATTERN "*.cmake" EXCLUDE
+        PATTERN "Win32" EXCLUDE
+        PATTERN "CMakeFiles" EXCLUDE)
+        
 
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE.txt DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/README.txt  DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/NOTICE.txt  DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/AUTHORS.txt DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE.txt 
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/README.txt  
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/NOTICE.txt  
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/AUTHORS.txt 
+        DESTINATION share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})

=== modified file 'doc/c/doxy.config.in'
--- doc/c/doxy.config.in	2011-06-30 20:03:46 +0000
+++ doc/c/doxy.config.in	2012-09-27 18:04:43 +0000
@@ -1,442 +1,623 @@
-# Doxyfile 1.4.5
+# Doxyfile 1.7.5
 
 # This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
+# doxygen (www.doxygen.org) for a project.
 #
-# All text after a hash (#) is considered a comment and will be ignored
+# All text after a hash (#) is considered a comment and will be ignored.
 # The format is:
 #       TAG = value [value, ...]
 # For lists items can also be appended using:
 #       TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
+# Values that contain spaces should be placed between quotes (" ").
 
 #---------------------------------------------------------------------------
 # Project related configuration options
 #---------------------------------------------------------------------------
 
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
-# by quotes) that should identify the project.
-
-PROJECT_NAME           = Zorba C-API
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
-# This could be handy for archiving the generated documentation or 
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME           = "Zorba C-API"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
 PROJECT_NUMBER         = @ZORBA_MAJOR_NUMBER@.@ZORBA_MINOR_NUMBER@.@ZORBA_PATCH_NUMBER@
 
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
-# base path where the generated documentation will be put. 
-# If a relative path is entered, it will be relative to the location 
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          =
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO           =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
 # where doxygen was started. If left blank the current directory will be used.
 
 OUTPUT_DIRECTORY       = @CMAKE_CURRENT_BINARY_DIR@
 
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
-# 4096 sub-directories (in 2 levels) under the output directory of each output 
-# format and will distribute the generated files over these directories. 
-# Enabling this option can be useful when feeding doxygen a huge amount of 
-# source files, where putting all generated files in the same directory would 
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
 # otherwise cause performance problems for the file system.
 
 CREATE_SUBDIRS         = NO
 
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
-# documentation generated by doxygen is written. Doxygen will use this 
-# information to generate all constant output in the proper language. 
-# The default language is English, other supported languages are: 
-# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, 
-# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, 
-# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, 
-# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, 
-# Swedish, and Ukrainian.
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
 
 OUTPUT_LANGUAGE        = English
 
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
-# include brief member descriptions after the members that are listed in 
-# the file and class documentation (similar to JavaDoc). 
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
 # Set to NO to disable this.
 
 BRIEF_MEMBER_DESC      = YES
 
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
-# the brief description of a member or function before the detailed description. 
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
 # brief descriptions will be completely suppressed.
 
 REPEAT_BRIEF           = YES
 
-# This tag implements a quasi-intelligent brief description abbreviator 
-# that is used to form the text in various listings. Each string 
-# in this list, if found as the leading text of the brief description, will be 
-# stripped from the text and the result after processing the whole list, is 
-# used as the annotated text. Otherwise, the brief description is used as-is. 
-# If left blank, the following values are used ("$name" is automatically 
-# replaced with the name of the entity): "The $name class" "The $name widget" 
-# "The $name file" "is" "provides" "specifies" "contains" 
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
 # "represents" "a" "an" "the"
 
-ABBREVIATE_BRIEF       = 
+ABBREVIATE_BRIEF       =
 
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
-# Doxygen will generate a detailed section even if there is only a brief 
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
 # description.
 
 ALWAYS_DETAILED_SEC    = NO
 
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
-# inherited members of a class in the documentation of that class as if those 
-# members were ordinary class members. Constructors, destructors and assignment 
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
 # operators of the base classes will not be shown.
 
 INLINE_INHERITED_MEMB  = YES
 
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
-# path before files name in the file list and in the header files. If set 
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
 # to NO the shortest path that makes the file name unique will be used.
 
 FULL_PATH_NAMES        = NO
 
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
-# can be used to strip a user-defined part of the path. Stripping is 
-# only done if one of the specified strings matches the left-hand part of 
-# the path. The tag can be used to show relative paths in the file list. 
-# If left blank the directory from which doxygen is run is used as the 
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
 # path to strip.
 
-STRIP_FROM_PATH        = @CMAKE_SOURCE_DIR@/src @CMAKE_BINARY_DIR@/src
-
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
-# the path mentioned in the documentation of a class, which tells 
-# the reader which header file to include in order to use a class. 
-# If left blank only the name of the header file containing the class 
-# definition is used. Otherwise one should specify the include paths that 
+STRIP_FROM_PATH        = @CMAKE_SOURCE_DIR@/src \
+                         @CMAKE_BINARY_DIR@/src
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
 # are normally passed to the compiler using the -I flag.
 
-STRIP_FROM_INC_PATH    = @CMAKE_SOURCE_DIR@/include @CMAKE_BINARY_DIR@/include
+STRIP_FROM_INC_PATH    = @CMAKE_SOURCE_DIR@/include \
+                         @CMAKE_BINARY_DIR@/include
 
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
-# (but less readable) file names. This can be useful is your file systems 
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful if your file system
 # doesn't support long names like on DOS, Mac, or CD-ROM.
 
 SHORT_NAMES            = NO
 
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
-# will interpret the first line (until the first dot) of a JavaDoc-style 
-# comment as the brief description. If set to NO, the JavaDoc 
-# comments will behave just like the Qt-style comments (thus requiring an 
-# explicit @brief command for a brief description.
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
 
 JAVADOC_AUTOBRIEF      = YES
 
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
-# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
-# comments) as a brief description. This used to be the default behaviour. 
-# The new default is to treat a multi-line C++ comment block as a detailed 
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
 # description. Set this tag to YES if you prefer the old behaviour instead.
 
 MULTILINE_CPP_IS_BRIEF = NO
 
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member 
-# documentation.
-
-DETAILS_AT_TOP         = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
-# member inherits the documentation from any documented member that it 
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
 # re-implements.
 
 INHERIT_DOCS           = YES
 
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
-# a new page for each member. If set to NO, the documentation of a member will 
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
 # be part of the file/class/namespace that contains it.
 
 SEPARATE_MEMBER_PAGES  = NO
 
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
 # Doxygen uses this value to replace tabs by spaces in code fragments.
 
 TAB_SIZE               = 2
 
-# This tag can be used to specify a number of aliases that acts 
-# as commands in the documentation. An alias has the form "name=value". 
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
-# put the command \sideeffect (or @sideeffect) in the documentation, which 
-# will result in a user-defined paragraph with heading "Side Effects:". 
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
 # You can put \n's in the value part of an alias to insert newlines.
 
-ALIASES                = 
+ALIASES                =
 
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
-# sources only. Doxygen will then generate output that is more tailored for C. 
-# For instance, some of the names that are used will be different. The list 
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
 # of all members will be omitted, etc.
 
 OPTIMIZE_OUTPUT_FOR_C  = YES
 
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
-# sources only. Doxygen will then generate output that is more tailored for Java. 
-# For instance, namespaces will be presented as packages, qualified scopes 
-# will look different, etc.
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
 
 OPTIMIZE_OUTPUT_JAVA   = NO
 
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to 
-# include (a tag file for) the STL sources as input, then you should 
-# set this tag to YES in order to let doxygen match functions declarations and 
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
-# func(std::string) {}). This also make the inheritance and collaboration 
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also makes the inheritance and collaboration
 # diagrams that involve STL classes more complete and accurate.
 
-# BUILTIN_STL_SUPPORT    = NO
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
-# tag is set to YES, then doxygen will reuse the documentation of the first 
-# member in the group (if any) for the other members of the group. By default 
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
 # all members of a group must be documented explicitly.
 
 DISTRIBUTE_GROUP_DOC   = NO
 
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
-# the same type (for instance a group of public functions) to be put as a 
-# subgroup of that type (e.g. under the Public Functions section). Set it to 
-# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
 # the \nosubgrouping command.
 
 SUBGROUPING            = YES
 
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields will be shown inline in the documentation
+# of the scope in which they are defined (i.e. file, namespace, or group
+# documentation), provided this scope is documented. If set to NO (the default),
+# structs, classes, and unions are shown on a separate page (for HTML and Man
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penalty.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will roughly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
 
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
-# documentation are documented, even if no documentation was available. 
-# Private class members and static file members will be hidden unless 
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
 # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
 
 EXTRACT_ALL            = YES
 
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
 # will be included in the documentation.
 
 EXTRACT_PRIVATE        = NO
 
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
 # will be included in the documentation.
 
 EXTRACT_STATIC         = NO
 
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
-# defined locally in source files will be included in the documentation. 
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
 # If set to NO only classes defined in header files are included.
 
 EXTRACT_LOCAL_CLASSES  = YES
 
-# This flag is only useful for Objective-C code. When set to YES local 
-# methods, which are defined in the implementation section but not in 
-# the interface are included in the documentation. 
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
 # If set to NO (the default) only methods in the interface are included.
 
 EXTRACT_LOCAL_METHODS  = NO
 
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
-# undocumented members of documented classes, files or namespaces. 
-# If set to NO (the default) these members will be included in the 
-# various overviews, but no documentation section is generated. 
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
 # This option has no effect if EXTRACT_ALL is enabled.
 
 HIDE_UNDOC_MEMBERS     = YES
 
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
-# undocumented classes that are normally visible in the class hierarchy. 
-# If set to NO (the default) these classes will be included in the various 
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
 # overviews. This option has no effect if EXTRACT_ALL is enabled.
 
 HIDE_UNDOC_CLASSES     = YES
 
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
-# friend (class|struct|union) declarations. 
-# If set to NO (the default) these declarations will be included in the 
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
 # documentation.
 
 HIDE_FRIEND_COMPOUNDS  = NO
 
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
-# documentation blocks found inside the body of a function. 
-# If set to NO (the default) these blocks will be appended to the 
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
 # function's detailed documentation block.
 
 HIDE_IN_BODY_DOCS      = NO
 
-# The INTERNAL_DOCS tag determines if documentation 
-# that is typed after a \internal command is included. If the tag is set 
-# to NO (the default) then the documentation will be excluded. 
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
 # Set it to YES to include the internal documentation.
 
 INTERNAL_DOCS          = NO
 
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
-# file names in lower-case letters. If set to YES upper-case letters are also 
-# allowed. This is useful if you have classes or files whose names only differ 
-# in case and if your file system supports case sensitive file names. Windows 
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
 # and Mac users are advised to set this option to NO.
 
 CASE_SENSE_NAMES       = YES
 
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
-# will show members with their full class and namespace scopes in the 
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
 # documentation. If set to YES the scope will be hidden.
 
 HIDE_SCOPE_NAMES       = NO
 
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
-# will put a list of the files that are included by a file in the documentation 
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
 # of that file.
 
 SHOW_INCLUDE_FILES     = YES
 
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
 # is inserted in the documentation for inline members.
 
 INLINE_INFO            = YES
 
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
-# will sort the (detailed) documentation of file and class members 
-# alphabetically by member name. If set to NO the members will appear in 
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
 # declaration order.
 
 SORT_MEMBER_DOCS       = YES
 
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
-# brief documentation of file, namespace and class members alphabetically 
-# by member name. If set to NO (the default) the members will appear in 
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
 # declaration order.
 
 SORT_BRIEF_DOCS        = YES
 
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
-# sorted by fully-qualified names, including namespaces. If set to 
-# NO (the default), the class list will be sorted only by class name, 
-# not including the namespace part. 
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
 # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the 
+# Note: This option applies only to the class list, not to the
 # alphabetical list.
 
 SORT_BY_SCOPE_NAME     = NO
 
-# The GENERATE_TODOLIST tag can be used to enable (YES) or 
-# disable (NO) the todo list. This list is created by putting \todo 
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
 # commands in the documentation.
 
 GENERATE_TODOLIST      = YES
 
-# The GENERATE_TESTLIST tag can be used to enable (YES) or 
-# disable (NO) the test list. This list is created by putting \test 
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
 # commands in the documentation.
 
 GENERATE_TESTLIST      = YES
 
-# The GENERATE_BUGLIST tag can be used to enable (YES) or 
-# disable (NO) the bug list. This list is created by putting \bug 
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
 # commands in the documentation.
 
 GENERATE_BUGLIST       = YES
 
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
-# disable (NO) the deprecated list. This list is created by putting 
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
 # \deprecated commands in the documentation.
 
 GENERATE_DEPRECATEDLIST= YES
 
-# The ENABLED_SECTIONS tag can be used to enable conditional 
+# The ENABLED_SECTIONS tag can be used to enable conditional
 # documentation sections, marked by \if sectionname ... \endif.
 
 ENABLED_SECTIONS       =
 
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
-# the initial value of a variable or define consists of for it to appear in 
-# the documentation. If the initializer consists of more lines than specified 
-# here it will be hidden. Use a value of 0 to hide initializers completely. 
-# The appearance of the initializer of individual variables and defines in the 
-# documentation can be controlled using \showinitializer or \hideinitializer 
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or macro consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and macros in the
+# documentation can be controlled using \showinitializer or \hideinitializer
 # command in the documentation regardless of this setting.
 
 MAX_INITIALIZER_LINES  = 30
 
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
-# at the bottom of the documentation of classes and structs. If set to YES the 
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
 # list will mention the files that were used to generate the documentation.
 
 SHOW_USED_FILES        = YES
 
-# If the sources in your project are distributed over multiple directories 
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
-# in the documentation. The default is YES.
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
 
 SHOW_DIRECTORIES       = YES
 
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
-# doxygen should invoke to get the current version for each file (typically from the 
-# version control system). Doxygen will invoke the program by executing (via 
-# popen()) the command <command> <input-file>, where <command> is the value of 
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
-# provided by doxygen. Whatever the program writes to standard output 
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
 # is used as the file version. See the manual for examples.
 
-FILE_VERSION_FILTER    = 
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. The create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE            =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE.
+
+CITE_BIB_FILES         =
 
 #---------------------------------------------------------------------------
 # configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
 
-# The QUIET tag can be used to turn on/off the messages that are generated 
+# The QUIET tag can be used to turn on/off the messages that are generated
 # by doxygen. Possible values are YES and NO. If left blank NO is used.
 
 QUIET                  = NO
 
-# The WARNINGS tag can be used to turn on/off the warning messages that are 
-# generated by doxygen. Possible values are YES and NO. If left blank 
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
 # NO is used.
 
 WARNINGS               = YES
 
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
 # automatically be disabled.
 
 WARN_IF_UNDOCUMENTED   = YES
 
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
-# potential errors in the documentation, such as not documenting some 
-# parameters in a documented function, or documenting parameters that 
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
 # don't exist or using markup commands wrongly.
 
 WARN_IF_DOC_ERROR      = YES
 
-# This WARN_NO_PARAMDOC option can be abled to get warnings for 
-# functions that are documented, but have no documentation for their parameters 
-# or return value. If set to NO (the default) doxygen will only warn about 
-# wrong or incomplete parameter documentation, but not about the absence of 
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
 # documentation.
 
 WARN_NO_PARAMDOC       = NO
 
-# The WARN_FORMAT tag determines the format of the warning messages that 
-# doxygen can produce. The string should contain the $file, $line, and $text 
-# tags, which will be replaced by the file and line number from which the 
-# warning originated and the warning text. Optionally the format may contain 
-# $version, which will be replaced by the version of the file (if it could 
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
 # be obtained via FILE_VERSION_FILTER)
 
 WARN_FORMAT            = @DOXY_WARN_FORMAT@
 
-# The WARN_LOGFILE tag can be used to specify a file to which warning 
-# and error messages should be written. If left blank the output is written 
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
 # to stderr.
 
 WARN_LOGFILE           = Doc/doxy.log
@@ -445,9 +626,9 @@
 # configuration options related to the input files
 #---------------------------------------------------------------------------
 
-# The INPUT tag can be used to specify the files and/or directories that contain 
-# documented source files. You may enter file names like "myfile.cpp" or 
-# directories like "/usr/src/myproject". Separate the files or directories 
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
 INPUT                  = @CMAKE_SOURCE_DIR@/include/zorba/zorbac.h \
@@ -455,140 +636,176 @@
                          @CMAKE_SOURCE_DIR@/include/zorba/static_context_consts.h \
                          @CMAKE_SOURCE_DIR@/include/zorba/options.h \
                          @CMAKE_CURRENT_SOURCE_DIR@/manual
-                          
-
-# If the value of the INPUT tag contains directories, you can use the 
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank the following patterns are tested: 
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
-
-FILE_PATTERNS          = *.h *.dox
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
-# should be searched for input files as well. Possible values are YES and NO. 
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS          = *.h \
+                         *.dox
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
 # If left blank NO is used.
 
 RECURSIVE              = YES
 
-# The EXCLUDE tag can be used to specify files and/or directories that should 
-# excluded from the INPUT source files. This way you can easily exclude a 
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE                = 
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
-# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# Note that relative paths are relative to directory from which doxygen is run.
+
+EXCLUDE                =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
 # from the input.
 
 EXCLUDE_SYMLINKS       = NO
 
-# If the value of the INPUT tag contains directories, you can use the 
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
-# certain files from those directories. Note that the wildcards are matched 
-# against the file with absolute path, so to exclude all test directories 
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
 # for example use the pattern */test/*
 
 EXCLUDE_PATTERNS       = */.svn \
                          */.svn/*
 
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
-# directories that contain example code fragments that are included (see 
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
 # the \include command).
 
 EXAMPLE_PATH           = @CMAKE_CURRENT_SOURCE_DIR@/examples
 
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
 # blank all files are included.
 
 EXAMPLE_PATTERNS       = *.c
 
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
-# searched for input files to be used with the \include or \dontinclude 
-# commands irrespective of the value of the RECURSIVE tag. 
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
 # Possible values are YES and NO. If left blank NO is used.
 
 EXAMPLE_RECURSIVE      = YES
 
-# The IMAGE_PATH tag can be used to specify one or more files or 
-# directories that contain image that are included in the documentation (see 
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
 # the \image command).
 
 IMAGE_PATH             = @CMAKE_CURRENT_SOURCE_DIR@
 
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should 
-# invoke to filter for each input file. Doxygen will invoke the filter program 
-# by executing (via popen()) the command <filter> <input-file>, where <filter> 
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
-# input file. Doxygen will then use the output that the filter program writes 
-# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
 # ignored.
 
-INPUT_FILTER           = 
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
-# basis.  Doxygen will compare the file name with each pattern and apply the 
-# filter if there is a match.  The filters are a list of the form: 
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
-# is applied to all files.
-
-FILTER_PATTERNS        = 
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
-# INPUT_FILTER) will be used to filter the input files when producing source 
+INPUT_FILTER           =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
 # files to browse (i.e. when SOURCE_BROWSER is set to YES).
 
 FILTER_SOURCE_FILES    = NO
 
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
 #---------------------------------------------------------------------------
 # configuration options related to source browsing
 #---------------------------------------------------------------------------
 
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
-# be generated. Documented entities will be cross-referenced with these sources. 
-# Note: To get rid of all source code in the generated output, make sure also 
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
 # VERBATIM_HEADERS is set to NO.
 
 SOURCE_BROWSER         = YES
 
-# Setting the INLINE_SOURCES tag to YES will include the body 
+# Setting the INLINE_SOURCES tag to YES will include the body
 # of functions and classes directly in the documentation.
 
 INLINE_SOURCES         = NO
 
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
-# doxygen to hide any special comment blocks from generated source code 
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
 # fragments. Normal C and C++ comments will always remain visible.
 
 STRIP_CODE_COMMENTS    = NO
 
-# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
-# then for each documented function all documented 
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
 # functions referencing it will be listed.
 
 REFERENCED_BY_RELATION = YES
 
-# If the REFERENCES_RELATION tag is set to YES (the default) 
-# then for each documented function all documented entities 
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
 # called/used by that function will be listed.
 
 REFERENCES_RELATION    = YES
 
-# If the USE_HTAGS tag is set to YES then the references to source code 
-# will point to the HTML generated by the htags(1) tool instead of doxygen 
-# built-in source browser. The htags tool is part of GNU's global source 
-# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
 # will need version 4.8.6 or higher.
 
 USE_HTAGS              = NO
 
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
-# will generate a verbatim copy of the header file for each class for 
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
 # which an include is specified. Set to NO to disable this.
 
 VERBATIM_HEADERS       = YES
@@ -597,281 +814,548 @@
 # configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
 
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
-# of all compounds will be generated. Enable this if the project 
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
 # contains a lot of classes, structs, unions or interfaces.
 
 ALPHABETICAL_INDEX     = YES
 
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
 # in which this list will be split (can be a number in the range [1..20])
 
 COLS_IN_ALPHA_INDEX    = 2
 
-# In case all classes in a project start with a common prefix, all 
-# classes will be put under the same header in the alphabetical index. 
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
 # should be ignored while generating the index headers.
 
-IGNORE_PREFIX          = 
+IGNORE_PREFIX          =
 
 #---------------------------------------------------------------------------
 # configuration options related to the HTML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
 # generate HTML output.
 
 GENERATE_HTML          = YES
 
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `html' will be used as the default path.
 
 HTML_OUTPUT            = html
 
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
 # doxygen will generate files with .html extension.
 
 HTML_FILE_EXTENSION    = .html
 
-# The HTML_HEADER tag can be used to specify a personal HTML header for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard header.
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header. Note that when using a custom header you are responsible
+#  for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is adviced to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
 HTML_HEADER            = @CMAKE_CURRENT_SOURCE_DIR@/../style/header.html
 
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
-# each generated HTML page. If it is left blank doxygen will generate a 
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
 # standard footer.
 
 HTML_FOOTER            = @CMAKE_CURRENT_SOURCE_DIR@/../style/footer.html
 
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
-# style sheet that is used by each HTML page. It can be used to 
-# fine-tune the look of the HTML output. If the tag is left blank doxygen 
-# will generate a default style sheet. Note that doxygen will try to copy 
-# the style sheet file to the HTML output directory, so don't put your own 
+# If the HTML_TIMESTAMP tag is set to YES then the generated HTML documentation will contain the timesstamp.
+
+HTML_TIMESTAMP         = NO
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
 # stylesheet in the HTML output directory as well, or it will be erased!
 
 HTML_STYLESHEET        = @CMAKE_CURRENT_SOURCE_DIR@/../style/stylesheet.css
 
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
-# files or namespaces will be aligned in HTML using tables. If set to 
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES       =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the stylesheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
 # NO a bullet list will be used.
 
 HTML_ALIGN_MEMBERS     = YES
 
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
-# will be generated that can be used as input for tools like the 
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
 # of the generated HTML documentation.
 
 GENERATE_HTMLHELP      = YES
 
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
-# be used to specify the file name of the resulting .chm file. You 
-# can add a path in front of the file if the result should not be 
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
 # written to the html output directory.
 
-CHM_FILE               = 
+CHM_FILE               =
 
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
-# be used to specify the location (absolute path including file name) of 
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
 # the HTML help compiler on the generated index.hhp.
 
-HHC_LOCATION           = 
+HHC_LOCATION           =
 
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
-# controls if a separate .chi index file is generated (YES) or that 
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
 # it should be included in the master .chm file (NO).
 
 GENERATE_CHI           = NO
 
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
-# controls whether a binary table of contents is generated (YES) or a 
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
 # normal table of contents (NO) in the .chm file.
 
 BINARY_TOC             = NO
 
-# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
 # to the contents of the HTML help documentation and to the tree view.
 
 TOC_EXPAND             = NO
 
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
-# top of each HTML page. The value NO (the default) enables the index and 
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters";>
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes";>
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+#  will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
 # the value YES disables it.
 
 DISABLE_INDEX          = NO
 
-# This tag can be used to set the number of enum values (range [1..20]) 
-# that doxygen will group on one line in the generated HTML documentation.
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
 
 ENUM_VALUES_PER_LINE   = 4
 
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that 
-# is generated for HTML Help). For this to work a browser that supports 
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
-# probably better off using the HTML help feature.
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
 
 GENERATE_TREEVIEW      = NO
 
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
-# used to set the initial width (in pixels) of the frame in which the tree 
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
 # is shown.
 
 TREEVIEW_WIDTH         = 250
 
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the
+# mathjax.org site, so you can quickly see the result without installing
+# MathJax, but it is strongly recommended to install a local copy of MathJax
+# before deployment.
+
+MATHJAX_RELPATH        = http://www.mathjax.org/mathjax
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS     =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = NO
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvantages are that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
 # generate Latex output.
 
 GENERATE_LATEX         = NO
 
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `latex' will be used as the default path.
 
 LATEX_OUTPUT           = latex
 
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
 # invoked. If left blank `latex' will be used as the default command name.
-
-#LATEX_CMD_NAME         = latex
-LATEX_CMD_NAME          = @LATEX_COMPILER@
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
-# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME         = @LATEX_COMPILER@
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
 # default command name.
 
-#MAKEINDEX_CMD_NAME     = makeindex
 MAKEINDEX_CMD_NAME     = @MAKEINDEX_COMPILER@
 
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
-# LaTeX documents. This may be useful for small projects and may help to 
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
 # save some trees in general.
 
 COMPACT_LATEX          = NO
 
-# The PAPER_TYPE tag can be used to set the paper type that is used 
-# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, letter, legal and
 # executive. If left blank a4wide will be used.
 
 PAPER_TYPE             = a4
 
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
 # packages that should be included in the LaTeX output.
 
-EXTRA_PACKAGES         = 
+EXTRA_PACKAGES         =
 
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
-# the generated latex document. The header should contain everything until 
-# the first chapter. If it is left blank doxygen will generate a 
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
 # standard header. Notice: only use this tag if you know what you are doing!
 
-LATEX_HEADER           = 
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
-# contain links (just like the HTML output) instead of page references 
+LATEX_HEADER           =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER           =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
 # This makes the output suitable for online browsing using a pdf viewer.
 
 PDF_HYPERLINKS         = YES
 
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
-# plain latex in the generated Makefile. Set this option to YES to get a 
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
 # higher quality PDF documentation.
 
 USE_PDFLATEX           = YES
 
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
-# command to the generated LaTeX files. This will instruct LaTeX to keep 
-# running if errors occur, instead of asking the user for help. 
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
 # This option is also used when generating formulas in HTML.
 
 LATEX_BATCHMODE        = YES
 
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
-# include the index chapters (such as File Index, Compound Index, etc.) 
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
 # in the output.
 
 LATEX_HIDE_INDICES     = NO
 
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE        = plain
+
 #---------------------------------------------------------------------------
 # configuration options related to the RTF output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
-# The RTF output is optimized for Word 97 and may not look very pretty with 
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
 # other RTF readers or editors.
 
 GENERATE_RTF           = NO
 
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `rtf' will be used as the default path.
 
 RTF_OUTPUT             = rtf
 
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
-# RTF documents. This may be useful for small projects and may help to 
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
 # save some trees in general.
 
 COMPACT_RTF            = NO
 
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
-# will contain hyperlink fields. The RTF file will 
-# contain links (just like the HTML output) instead of page references. 
-# This makes the output suitable for online browsing using WORD or other 
-# programs which support those fields. 
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
 # Note: wordpad (write) and others do not support links.
 
 RTF_HYPERLINKS         = NO
 
-# Load stylesheet definitions from file. Syntax is similar to doxygen's 
-# config file, i.e. a series of assignments. You only have to provide 
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
 # replacements, missing definitions are set to their default value.
 
-RTF_STYLESHEET_FILE    = 
+RTF_STYLESHEET_FILE    =
 
-# Set optional variables used in the generation of an rtf document. 
+# Set optional variables used in the generation of an rtf document.
 # Syntax is similar to doxygen's config file.
 
-RTF_EXTENSIONS_FILE    = 
+RTF_EXTENSIONS_FILE    =
 
 #---------------------------------------------------------------------------
 # configuration options related to the man page output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
 # generate man pages
 
 GENERATE_MAN           = NO
 
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `man' will be used as the default path.
 
 MAN_OUTPUT             = man
 
-# The MAN_EXTENSION tag determines the extension that is added to 
+# The MAN_EXTENSION tag determines the extension that is added to
 # the generated man pages (default is the subroutine's section .3)
 
 MAN_EXTENSION          = .3
 
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
-# then it will generate one additional man file for each entity 
-# documented in the real man page(s). These additional files 
-# only source the real man page, but without them the man command 
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
 # would be unable to find the correct page. The default is NO.
 
 MAN_LINKS              = NO
@@ -880,33 +1364,33 @@
 # configuration options related to the XML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_XML tag is set to YES Doxygen will 
-# generate an XML file that captures the structure of 
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
 # the code including all documentation.
 
-GENERATE_XML           = NO
+GENERATE_XML           = YES
 
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `xml' will be used as the default path.
 
 XML_OUTPUT             = xml
 
-# The XML_SCHEMA tag can be used to specify an XML schema, 
-# which can be used by a validating XML parser to check the 
-# syntax of the XML files.
-
-XML_SCHEMA             = 
-
-# The XML_DTD tag can be used to specify an XML DTD, 
-# which can be used by a validating XML parser to check the 
-# syntax of the XML files.
-
-XML_DTD                = 
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
-# dump the program listings (including syntax highlighting 
-# and cross-referencing information) to the XML output. Note that 
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA             =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD                =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
 # enabling this will significantly increase the size of the XML output.
 
 XML_PROGRAMLISTING     = YES
@@ -915,10 +1399,10 @@
 # configuration options for the AutoGen Definitions output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
-# generate an AutoGen Definitions (see autogen.sf.net) file 
-# that captures the structure of the code including all 
-# documentation. Note that this feature is still experimental 
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
 # and incomplete at the moment.
 
 GENERATE_AUTOGEN_DEF   = NO
@@ -927,286 +1411,359 @@
 # configuration options related to the Perl module output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
-# generate a Perl module file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
 # moment.
 
 GENERATE_PERLMOD       = NO
 
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
 # to generate PDF and DVI output from the Perl module output.
 
 PERLMOD_LATEX          = NO
 
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
-# nicely formatted so it can be parsed by a human reader.  This is useful 
-# if you want to understand what is going on.  On the other hand, if this 
-# tag is set to NO the size of the Perl module output will be much smaller 
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
 # and Perl will parse it just the same.
 
 PERLMOD_PRETTY         = YES
 
-# The names of the make variables in the generated doxyrules.make file 
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
-# This is useful so different doxyrules.make files included by the same 
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
 # Makefile don't overwrite each other's variables.
 
-PERLMOD_MAKEVAR_PREFIX = 
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
-# evaluate all C-preprocessor directives found in the sources and include 
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
 # files.
 
 ENABLE_PREPROCESSING   = YES
 
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
-# names in the source code. If set to NO (the default) only conditional 
-# compilation will be performed. Macro expansion can be done in a controlled 
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
 # way by setting EXPAND_ONLY_PREDEF to YES.
 
 MACRO_EXPANSION        = YES
 
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
-# then the macro expansion is limited to the macros specified with the 
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
 # PREDEFINED and EXPAND_AS_DEFINED tags.
 
 EXPAND_ONLY_PREDEF     = YES
 
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
 
 SEARCH_INCLUDES        = YES
 
-# The INCLUDE_PATH tag can be used to specify one or more directories that 
-# contain include files that are not input files but should be processed by 
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
 # the preprocessor.
 
-INCLUDE_PATH           = 
+INCLUDE_PATH           =
 
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
-# patterns (like *.h and *.hpp) to filter out the header-files in the 
-# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
 # be used.
 
-INCLUDE_F

Follow ups