← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1180220-schema-tools into lp:zorba

 

Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/bug-1180220-schema-tools into lp:zorba.

Commit message:
Removed unnecessary #include.  This is a prerequisite for the fix of bug 1180220.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1180220-schema-tools/+merge/167349

Removed unnecessary #include.  This is a prerequisite for the fix of bug 1180220.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1180220-schema-tools/+merge/167349
Your team Zorba Coders is subscribed to branch lp:zorba.
=== added file 'CMakeLists.txt'
--- CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ CMakeLists.txt	2013-06-04 17:22:40 +0000
@@ -0,0 +1,70 @@
+# 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.
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT (zorba_schema-tools_module)
+
+FIND_PACKAGE (zorba_util-jvm_module QUIET)
+INCLUDE ("${zorba_util-jvm_module_USE_FILE}")
+
+IF (zorba_util-jvm_module_FOUND)
+  FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}")
+  INCLUDE ("${Zorba_USE_FILE}")
+
+  SET_CMAKE_MODULE_PATH ()
+  FIND_PACKAGE(JNI)
+  FIND_PACKAGE(Java)
+  
+  IF (JNI_FOUND)
+    INCLUDE_DIRECTORIES (${zorba_util-jvm_module_INCLUDE_DIRS})
+
+    SET (XMLBEANS_PATHS)
+    IF (NOT WIN32)
+      SET (XMLBEANS_PATHS /usr/share/java /usr/share/java/xmlbeans)
+    ENDIF (NOT WIN32)
+    FIND_FILE(XMLBEANS_JAR NAMES xmlbeans.jar xbean.jar
+      PATHS "$ENV{XMLBEANS_HOME}" ${XMLBEANS_PATHS}
+      PATH_SUFFIXES lib build/lib)
+
+    IF( EXISTS ${XMLBEANS_JAR} )
+      
+      MESSAGE (STATUS "xmlbeans.jar found at: " ${XMLBEANS_JAR} )
+      # if everything is found build this module
+      SET (SCHEMA_TOOLS_VERSION 1.0)
+
+      ENABLE_TESTING ()
+      INCLUDE (CTest)
+
+      SET_CMAKE_MODULE_PATH ()
+
+      FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}")
+      INCLUDE ("${Zorba_USE_FILE}")
+
+      ADD_SUBDIRECTORY ("src")
+      ADD_SUBDIRECTORY ("srcJava")
+      ADD_TEST_DIRECTORY("${PROJECT_SOURCE_DIR}/test")
+      DONE_DECLARING_ZORBA_URIS ()
+
+    ELSE( EXISTS ${XMLBEANS_JAR} )
+      MESSAGE (STATUS "xmlbeans.jar not found; skipping schema-tools module.")
+    ENDIF( EXISTS ${XMLBEANS_JAR} )
+
+  ELSE (JNI_FOUND)
+    MESSAGE (STATUS "Java and/or JNI not found; skipping schema-tools module.")
+  ENDIF (JNI_FOUND)
+
+ELSE (zorba_util-jvm_module_FOUND)
+  MESSAGE (STATUS "Zorba's util-jvm module not found; skipping schema-tools module.")
+ENDIF (zorba_util-jvm_module_FOUND)

=== renamed file 'CMakeLists.txt' => 'CMakeLists.txt.moved'
=== added directory 'cmake_modules'
=== renamed directory 'cmake_modules' => 'cmake_modules.moved'
=== added file 'cmake_modules/FindJNI.cmake'
--- cmake_modules/FindJNI.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/FindJNI.cmake	2013-06-04 17:22:40 +0000
@@ -0,0 +1,310 @@
+# - Find JNI java libraries.
+# This module finds if Java is installed and determines where the
+# include files and libraries are. It also determines what the name of
+# the library is. This code sets the following variables:
+#   
+#  JNI_INCLUDE_DIRS      = the include dirs to use
+#  JNI_LIBRARIES         = the libraries to use
+#  JNI_FOUND             = TRUE if JNI headers and libraries were found.
+#  JAVA_AWT_LIBRARY      = the path to the jawt library
+#  JAVA_JVM_LIBRARY      = the path to the jvm library
+#  JAVA_INCLUDE_PATH     = the include path to jni.h
+#  JAVA_INCLUDE_PATH2    = the include path to jni_md.h
+#  JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
+#
+
+#=============================================================================
+# Copyright 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.
+#=============================================================================
+
+# Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var}
+MACRO(java_append_library_directories _var)
+    # Determine java arch-specific library subdir
+    # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk
+    # 1.6.0_18 + icedtea patches. However, it would be much better to base the
+    # guess on the first part of the GNU config.guess platform triplet.
+    IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+        SET(_java_libarch "amd64")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
+        SET(_java_libarch "i386")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
+        SET(_java_libarch "alpha")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
+        # Subdir is "arm" for both big-endian (arm) and little-endian (armel).
+        SET(_java_libarch "arm")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
+        # mips* machines are bi-endian mostly so processor does not tell
+        # endianess of the underlying system.
+        SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
+        SET(_java_libarch "ppc64")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
+        SET(_java_libarch "ppc")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
+        # Both flavours can run on the same processor
+        SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
+        SET(_java_libarch "parisc" "parisc64")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
+        # s390 binaries can run on s390x machines
+        SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
+    ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
+        SET(_java_libarch "sh")
+    ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+        SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}")
+    ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+
+    # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
+    # system is non-Linux (where the code above has not been well tested)
+    IF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+        LIST(APPEND _java_libarch "i386" "amd64" "ppc")
+    ENDIF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+
+    # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
+    # current value to a hardcoded list. Remove possible duplicates.
+    LIST(REMOVE_DUPLICATES _java_libarch)
+
+    FOREACH(_path ${ARGN})
+        IF(_path MATCHES "{libarch}")
+            FOREACH(_libarch ${_java_libarch})
+                STRING(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}")
+                LIST(APPEND ${_var} "${_newpath}")
+            ENDFOREACH(_libarch)
+        ELSE(_path MATCHES "{libarch}")
+            LIST(APPEND ${_var} "${_path}")
+        ENDIF(_path MATCHES "{libarch}")
+    ENDFOREACH(_path)
+ENDMACRO(java_append_library_directories)
+
+GET_FILENAME_COMPONENT(java_install_version
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
+
+SET(JAVA_AWT_LIBRARY_DIRECTORIES
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
+  )
+
+FILE(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME)
+
+JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+  ${_JAVA_HOME}/jre/lib/{libarch}
+  ${_JAVA_HOME}/jre/lib
+  ${_JAVA_HOME}/lib
+  ${_JAVA_HOME}
+  /usr/lib/jvm/java-6-openjdk/jre/lib
+  /usr/lib/jvm/java-6-openjdk-i386/jre/lib
+  /usr/lib/jvm/java-6-openjdk-amd64/jre/lib
+  /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-openjdk-i386/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/{libarch}
+  /usr/lib/jvm/java-7-openjdk/jre/lib
+  /usr/lib/jvm/java-7-openjdk-i386/jre/lib
+  /usr/lib/jvm/java-7-openjdk-amd64/jre/lib
+  /usr/lib/jvm/java-7-openjdk/jre/lib/{libarch}
+  /usr/lib/jvm/java-7-openjdk-i386/jre/lib/{libarch}
+  /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/{libarch}
+  /usr/lib
+  /usr/local/lib
+  /usr/lib/jvm/java/lib
+  /usr/lib/java/jre/lib/{libarch}
+  /usr/local/lib/java/jre/lib/{libarch}
+  /usr/local/share/java/jre/lib/{libarch}
+  /usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
+  /usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
+  /opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-sun/jre/lib/{libarch}
+  /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
+  /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch}       # can this one be removed according to #8821 ? Alex
+  /usr/lib/jvm/java-openjdk/jre/lib/{libarch}
+  # Debian specific paths for default JVM
+  /usr/lib/jvm/default-java/jre/lib/{libarch}
+  /usr/lib/jvm/default-java/jre/lib
+  /usr/lib/jvm/default-java/lib
+  )
+
+SET(JAVA_JVM_LIBRARY_DIRECTORIES)
+FOREACH(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
+  SET(JAVA_JVM_LIBRARY_DIRECTORIES
+    ${JAVA_JVM_LIBRARY_DIRECTORIES}
+    "${dir}"
+    "${dir}/client"
+    "${dir}/server"
+    )
+ENDFOREACH(dir)
+
+
+SET(JAVA_AWT_INCLUDE_DIRECTORIES
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
+  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
+  ${_JAVA_HOME}/include
+  /usr/lib/jvm/java-6-openjdk/include
+  /usr/lib/jvm/java-6-openjdk-amd64/include
+  /usr/lib/jvm/java-6-openjdk-i386/include
+  /usr/include 
+  /usr/local/include
+  /usr/lib/java/include
+  /usr/local/lib/java/include
+  /usr/lib/jvm/java/include
+  /usr/lib/jvm/java-6-sun/include
+  /usr/lib/jvm/java-1.5.0-sun/include
+  /usr/lib/jvm/java-6-sun-1.6.0.00/include       # can this one be removed according to #8821 ? Alex
+  /usr/lib/jvm/java-6-openjdk/include
+  /usr/local/share/java/include
+  /usr/lib/j2sdk1.4-sun/include
+  /usr/lib/j2sdk1.5-sun/include
+  /opt/sun-jdk-1.5.0.04/include
+  # Debian specific path for default JVM
+  /usr/lib/jvm/default-java/include
+  )
+
+FOREACH(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
+  GET_FILENAME_COMPONENT(jpath "${JAVA_PROG}" PATH)
+  FOREACH(JAVA_INC_PATH ../include ../java/include ../share/java/include)
+    IF(EXISTS ${jpath}/${JAVA_INC_PATH})
+      SET(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}")
+    ENDIF(EXISTS ${jpath}/${JAVA_INC_PATH})
+  ENDFOREACH(JAVA_INC_PATH)
+  FOREACH(JAVA_LIB_PATH 
+    ../lib ../jre/lib ../jre/lib/i386 
+    ../java/lib ../java/jre/lib ../java/jre/lib/i386 
+    ../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
+    IF(EXISTS ${jpath}/${JAVA_LIB_PATH})
+      SET(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}")
+    ENDIF(EXISTS ${jpath}/${JAVA_LIB_PATH})
+  ENDFOREACH(JAVA_LIB_PATH)
+ENDFOREACH(JAVA_PROG)
+
+IF(APPLE)
+  IF(EXISTS ~/Library/Frameworks/JavaVM.framework)
+    SET(JAVA_HAVE_FRAMEWORK 1)
+  ENDIF(EXISTS ~/Library/Frameworks/JavaVM.framework)
+  IF(EXISTS /Library/Frameworks/JavaVM.framework)
+    SET(JAVA_HAVE_FRAMEWORK 1)
+  ENDIF(EXISTS /Library/Frameworks/JavaVM.framework)
+  IF(EXISTS /System/Library/Frameworks/JavaVM.framework)
+    SET(JAVA_HAVE_FRAMEWORK 1)
+  ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework)
+
+  IF(JAVA_HAVE_FRAMEWORK)
+    IF(NOT JAVA_AWT_LIBRARY)
+      SET (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
+    ENDIF(NOT JAVA_AWT_LIBRARY)
+
+    IF(NOT JAVA_JVM_LIBRARY)
+      SET (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
+    ENDIF(NOT JAVA_JVM_LIBRARY)
+
+    IF(NOT JAVA_AWT_INCLUDE_PATH)
+      IF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
+        SET (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE)
+      ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
+    ENDIF(NOT JAVA_AWT_INCLUDE_PATH)
+
+    # If using "-framework JavaVM", prefer its headers *before* the others in
+    # JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here)
+    #
+    SET(JAVA_AWT_INCLUDE_DIRECTORIES
+      ~/Library/Frameworks/JavaVM.framework/Headers
+      /Library/Frameworks/JavaVM.framework/Headers
+      /System/Library/Frameworks/JavaVM.framework/Headers
+      ${JAVA_AWT_INCLUDE_DIRECTORIES}
+      )
+  ENDIF(JAVA_HAVE_FRAMEWORK)
+ELSE(APPLE)
+  FIND_LIBRARY(JAVA_AWT_LIBRARY jawt 
+    PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES}
+  )
+  FIND_LIBRARY(JAVA_JVM_LIBRARY NAMES jvm JavaVM java
+    PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES}
+  )
+ENDIF(APPLE)
+
+# add in the include path    
+FIND_PATH(JAVA_INCLUDE_PATH jni.h 
+  ${JAVA_AWT_INCLUDE_DIRECTORIES}
+)
+
+FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h 
+  ${JAVA_INCLUDE_PATH}
+  ${JAVA_INCLUDE_PATH}/win32
+  ${JAVA_INCLUDE_PATH}/linux
+  ${JAVA_INCLUDE_PATH}/freebsd
+  ${JAVA_INCLUDE_PATH}/solaris
+)
+
+FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h
+  ${JAVA_INCLUDE_PATH}
+)
+
+
+IF (APPLE)
+  # On Mac, the java headers files are broken symlinks if the Apple Developer Tools for Java are not installed
+  EXECUTE_PROCESS(COMMAND cat ${JAVA_INCLUDE_PATH}/jni.h
+                  OUTPUT_QUIET
+                  ERROR_QUIET
+                  RESULT_VARIABLE SYMLINK_CHECK_RESULT_VARIABLE)
+  IF (SYMLINK_CHECK_RESULT_VARIABLE GREATER 0)
+    SET (JAVA_INCLUDE_PATH "JAVA_INCLUDE_PATH-NOTFOUND")
+    SET (JAVA_INCLUDE_PATH2 "JAVA_INCLUDE_PATH2-NOTFOUND")
+    SET (JAVA_AWT_INCLUDE_PATH "JAVA_AWT_INCLUDE_PATH-NOTFOUND")
+  ENDIF()
+ENDIF (APPLE)
+
+
+#INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake")
+#FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI  DEFAULT_MSG  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
+#                                                    JAVA_INCLUDE_PATH  JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
+
+MARK_AS_ADVANCED(
+  JAVA_AWT_LIBRARY
+  JAVA_JVM_LIBRARY
+  JAVA_AWT_INCLUDE_PATH
+  JAVA_INCLUDE_PATH
+  JAVA_INCLUDE_PATH2
+)
+
+IF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH)
+  SET(JNI_FOUND 1)
+  SET(JNI_LIBRARIES
+    ${JAVA_AWT_LIBRARY}
+    ${JAVA_JVM_LIBRARY}
+  )
+  SET(JNI_INCLUDE_DIRS
+    ${JAVA_INCLUDE_PATH}
+    ${JAVA_INCLUDE_PATH2}
+    ${JAVA_AWT_INCLUDE_PATH}
+  )
+ELSE (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH) 
+  SET(JNI_FOUND 0)
+  SET(JNI_LIBRARIES "")
+  SET(JNI_INCLUDE_DIRS "")
+ENDIF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH)

=== added directory 'cmake_modules/Windows'
=== added file 'cmake_modules/Windows/FindJNI.cmake'
--- cmake_modules/Windows/FindJNI.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/Windows/FindJNI.cmake	2013-06-04 17:22:40 +0000
@@ -0,0 +1,37 @@
+# Copyright 2010 The FLWOR Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# - Try to find the JNI libraries on Windows
+#
+# See the FindJNI.cmake module shipped with Zorba for more information.
+
+FIND_PACKAGE_WIN32_NO_PROXY (JNI JNI_FOUND)
+
+IF (JNI_FOUND)
+
+  STRING (REPLACE "/jvm.lib" "" JAVA_JVM_LIBRARY_PATH "${JAVA_JVM_LIBRARY}")
+
+  IF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+    SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+    # find the needed DLL's
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm")
+  ELSEIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server")
+    SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server")
+    # find the needed DLL's
+    FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm")
+  ELSE (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+    MESSAGE (WARNING "Could not find the jvm.dll for the JVM library: ${JAVA_JVM_LIBRARY}. Please extend this module to find the jvm.dll somewhere in your JVM directory or make sure that jvm.dll is in the PATH.")
+  ENDIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client")
+
+ENDIF (JNI_FOUND)

=== added directory 'src'
=== renamed directory 'src' => 'src.moved'
=== added file 'src/CMakeLists.txt'
--- src/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ src/CMakeLists.txt	2013-06-04 17:22:40 +0000
@@ -0,0 +1,36 @@
+# Copyright 2006-2010 The FLWOR Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SET (ZORBA_WITH_SCHEMATOOLS ON CACHE BOOL "Compile Zorba with Schema-Tools support" FORCE)
+INCLUDE (CMakeJavaInformation )
+MESSAGE(STATUS "Generating Java API")
+EXECUTE_PROCESS (
+  COMMAND ${JAVA_RUNTIME} -version
+  RESULT_VARIABLE JAVA_VERSION
+  OUTPUT_QUIET
+  ERROR_QUIET
+  )
+MESSAGE (STATUS "Building Zorba with Schema Tools support.")
+  
+INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
+INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH})
+
+DECLARE_ZORBA_SCHEMA (FILE schema-tools-options.xsd
+  URI "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";)
+
+DECLARE_ZORBA_MODULE (
+  URI "http://www.zorba-xquery.com/modules/schema-tools";
+  VERSION 1.0
+  FILE "schema-tools.xq"
+  LINK_LIBRARIES "${JAVA_JVM_LIBRARY}" ${zorba_util-jvm_module_LIBRARIES})

=== added file 'src/options-example.xml'
--- src/options-example.xml	1970-01-01 00:00:00 +0000
+++ src/options-example.xml	2013-06-04 17:22:40 +0000
@@ -0,0 +1,25 @@
+<!--
+:: 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.
+::
+-->
+<options xmlns='http://www.zorba-xquery.com/modules/schema-tools/schemma-tools-options'>
+   <design>vbd</design>
+   <simple-content-types>smart</simple-content-types>
+   <use-enumeration>10</use-enumeration>
+
+   <network-downloads>false</network-downloads>
+   <no-pvr>false</no-pvr>
+   <no-upa>false</no-upa>
+</options>
\ No newline at end of file

=== added file 'src/schema-tools-options.xsd'
--- src/schema-tools-options.xsd	1970-01-01 00:00:00 +0000
+++ src/schema-tools-options.xsd	2013-06-04 17:22:40 +0000
@@ -0,0 +1,58 @@
+<!--
+:: 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.
+::
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+  xmlns:sto="http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";
+  targetNamespace="http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";
+  elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+  <xs:element name="inst2xsd-options" type="sto:inst2xsdOptionsType"/>
+  <xs:element name="xsd2inst-options" type="sto:xsd2instOptionsType"/>
+
+  <xs:complexType name="inst2xsdOptionsType">
+      <xs:all>
+        <xs:element name="design" default="vbd" minOccurs="0">
+          <xs:simpleType>
+            <xs:restriction base="xs:string">
+              <xs:enumeration value="rdd"/>
+              <xs:enumeration value="ssd"/>
+              <xs:enumeration value="vbd"/>
+            </xs:restriction>
+          </xs:simpleType>
+        </xs:element>
+        <xs:element name="simple-content-types" default="smart" minOccurs="0">
+          <xs:simpleType>
+            <xs:restriction base="xs:string">
+              <xs:enumeration value="always-string"/>
+              <xs:enumeration value="smart"/>
+            </xs:restriction>
+          </xs:simpleType>
+        </xs:element>
+        <xs:element name="use-enumeration" minOccurs="0"
+            type="xs:int" default="10"/>
+        <xs:element name="verbose" minOccurs="0"
+            type="xs:boolean" default="false"/>
+      </xs:all>
+  </xs:complexType>
+
+  <xs:complexType name="xsd2instOptionsType">
+      <xs:all>
+        <xs:element name="network-downloads" type="xs:boolean" default="false" minOccurs="0"/>
+        <xs:element name="no-pvr" type="xs:boolean" default="false" minOccurs="0"/>
+        <xs:element name="no-upa" type="xs:boolean" default="false" minOccurs="0"/>
+      </xs:all>
+  </xs:complexType>
+</xs:schema>
\ No newline at end of file

=== added file 'src/schema-tools.xq'
--- src/schema-tools.xq	1970-01-01 00:00:00 +0000
+++ src/schema-tools.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,219 @@
+xquery version "3.0";
+
+(:
+ : Copyright 2006-2009 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+ :)
+(:~
+ : This module provides funtionality to get sample XMLSchema from XML instances
+ : and sample XML instances from XMLSchema.
+ : <a href="http://xmlbeans.apache.org/";>Apache XMLBeans</a> library is used to implement
+ : inst2xsd and xsd2inst functions.
+ : <br />
+ : <br />
+ : <b>Note:</b> Since this module has a Java library dependency a JVM required
+ : to be installed on the system. For Windows: jvm.dll is required on the system
+ : path ( usually located in "C:\Program Files\Java\jre6\bin\client".
+ :
+ : @author Cezar Andrei
+ : @see http://xmlbeans.apache.org/
+ : @library <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html";>JDK - Java Development Kit</a>
+ : @library <a href="http://xmlbeans.apache.org/";>Apache XMLBeans</a>
+ : @see http://xmlbeans.apache.org
+ : @project Zorba/Data Processing/Schema Tools
+ :)
+module namespace schema-tools = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+
+import schema namespace st-options = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+(:~
+ : Import module for checking if options element is validated.
+ :)
+import module namespace schema-options = "http://www.zorba-xquery.com/modules/schema";;
+
+
+declare namespace err = "http://www.w3.org/2005/xqt-errors";;
+
+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";;
+declare option ver:module-version "1.0";
+
+
+(:~
+ : The inst2xsd function takes a set of sample XML instance elements as input and
+ : generates a set of sample XMLSchema documents that define
+ : the content of the given input.
+ : <br />
+ : Please consult the 
+ : <a href="http://xmlbeans.apache.org/";>official documentation for further
+ : information</a>.
+ : <br />
+ : Example:<pre class="ace-static" ace-mode="xquery"><![CDATA[
+ :  import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+ :  declare namespace sto =
+ :      "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+ :  let $instances := (<a><b/><c/></a>, <b/>, <c>ccc</c>)
+ :  let $options  :=
+ :     <sto:inst2xsd-options xmlns:sto=
+ :       "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";>
+ :       <sto:design>vbd</sto:design>
+ :       <sto:simple-content-types>smart</sto:simple-content-types>
+ :       <sto:use-enumeration>10</sto:use-enumeration>
+ :     </sto:inst2xsd-options>
+ :  return
+ :      st:inst2xsd($instances, $options)
+ :
+ : ]]></pre>
+ : <br />
+ : @param $instances The input XML instance elements
+ : @param $options Options:<br />
+ :    <ul>
+ :      <li>design: Choose the generated schema design<br />
+ :         - rdd: Russian Doll Design - local elements and local types<br />
+ :         - ssd: Salami Slice Design - global elements and local types<br />
+ :         - vbd (default): Venetian Blind Design - local elements and global
+ :                          complex types</li>
+ :      <li>simple-content-types: type of leaf nodes<br />
+ :         - smart (default): try to find the right simple XMLSchema type<br />
+ :         - always-string: use xsd:string for all simple types</li>
+ :      <li>use-enumeration: - when there are multiple valid values in a list<br />
+ :         - 1: never use enumeration<br />
+ :         - 2 or more (default 10): use enumeration if less than this number of occurrences - number option</li>
+ :      <li>verbose: - stdout verbose info<br />
+ :         - true: - output type holder information<br />
+ :         - false (default): no output</li></ul>
+ :
+ :
+ : @return The generated XMLSchema documents.
+ : @error schema-tools:VM001 If Zorba was unable to start the JVM.
+ : @error schema-tools:JAVA-EXCEPTION If Apache XMLBeans throws an exception.
+ : @example test/Queries/schema-tools/inst2xsd-opt1.xq
+ : @example test/Queries/schema-tools/inst2xsd-opt2.xq
+ : @example test/Queries/schema-tools/inst2xsd-opt3.xq
+ : @example test/Queries/schema-tools/inst2xsd-simple.xq
+ : @example test/Queries/schema-tools/inst2xsd-tns-default.xq
+ : @example test/Queries/schema-tools/inst2xsd-tns.xq
+ : @example test/Queries/schema-tools/inst2xsd-multiTns.xq
+ : @example test/Queries/schema-tools/inst2xsd-err1-badOpt.xq
+ :)
+declare function
+schema-tools:inst2xsd ($instances as element()+,
+    $options as element(st-options:inst2xsd-options)?)
+  as document-node()*
+{
+  let $validated-options :=
+    if(empty($options))
+    then
+      $options
+    else if(schema-options:is-validated($options))
+    then
+      $options
+    else
+      validate{$options}
+  return
+    schema-tools:inst2xsd-internal($instances, $validated-options)
+};
+
+
+declare %private function
+schema-tools:inst2xsd-internal( $instances as element()+,
+    $options as element(st-options:inst2xsd-options, st-options:inst2xsdOptionsType)? )
+  as document-node()* external;
+
+
+
+(:~
+ : The xsd2inst function takes a set of XML Schema elements as input and the
+ : local name of the root element and
+ : generates a document that represents one sample XML instance of the given
+ : input schemas. The local name is searched in schema global element definitions
+ : in the order of schemas parameter.
+ : <br />
+ : Please consult the
+ : <a href="http://xmlbeans.apache.org/";>official documentation for further
+ :   information</a>.
+ : <br />
+ : Example: <pre class="ace-static" ace-static="xquery"><![CDATA[
+ :  import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+ :  declare namespace sto =
+ :      "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+ :  let $xsds  :=
+ :     ( <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+ :           attributeFormDefault="unqualified"
+ :           elementFormDefault="qualified">
+ :         <xs:element name="a" type="aType"/>
+ :         <xs:complexType name="aType">
+ :           <xs:sequence>
+ :             <xs:element type="xs:string" name="b"/>
+ :             <xs:element type="xs:string" name="c"/>
+ :           </xs:sequence>
+ :         </xs:complexType>
+ :       </xs:schema> )
+ :  let $options :=
+ :    <sto:xsd2inst-options xmlns:sto=
+ :      "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";>
+ :      <sto:network-downloads>false</sto:network-downloads>
+ :      <sto:no-pvr>false</sto:no-pvr>
+ :      <sto:no-upa>false</sto:no-upa>
+ :    </sto:xsd2inst-options>
+ :  return
+ :      st:xsd2inst($xsds, "a", $options)
+ : ]]></pre><br />
+ : @param $schemas elements representing XMLSchema definitions
+ : @param $rootElementName The local name of the instance root element.
+ :        If multiple target namespaces are used, first one found - using the
+ :        sequence order - will be used.
+ : @param $options Options:<br /><ul>
+ :       <li>network-downloads: boolean (default false)<br />
+ :             - true allows XMLBeans to use network when resolving schema
+ :               imports and includes</li>
+ :       <li>no-pvr: boolean (default false)<br />
+ :             - true to disable particle valid (restriction) rule,
+ :               false otherwise</li>
+ :       <li>no-upa: boolean (default false)<br />
+ :             - true to disable unique particle attribution rule,
+ :               false otherwise</li></ul>
+ :
+ : @return The generated output document, representing a sample XML instance.
+ : @error schema-tools:VM001 If Zorba was unable to start the JVM.
+ : @error schema-tools:JAVA-EXCEPTION If Apache XMLBeans throws an exception.
+ : @example test/Queries/schema-tools/xsd2inst-opt1.xq
+ : @example test/Queries/schema-tools/xsd2inst-simple.xq
+ : @example test/Queries/schema-tools/xsd2inst-tns.xq
+ : @example test/Queries/schema-tools/xsd2inst-err1-badOpt.xq
+ :)
+declare function
+schema-tools:xsd2inst ($schemas as element()+, $rootElementName as xs:string,
+    $options as element(st-options:xsd2inst-options)?)
+  as document-node()
+{
+  let $validated-options :=
+    if(empty($options))
+    then
+        $options
+    else if(schema-options:is-validated($options))
+    then
+        $options
+    else
+        validate{$options}
+  return
+    schema-tools:xsd2inst-internal($schemas, $rootElementName, $validated-options)
+};
+
+
+declare %private function
+schema-tools:xsd2inst-internal ($schemas as element()+,
+    $rootElementName as xs:string,
+    $options as element(st-options:xsd2inst-options, st-options:xsd2instOptionsType)?)
+  as document-node() external;

=== added directory 'src/schema-tools.xq.src'
=== added file 'src/schema-tools.xq.src/schema-tools.cpp'
--- src/schema-tools.xq.src/schema-tools.cpp	1970-01-01 00:00:00 +0000
+++ src/schema-tools.xq.src/schema-tools.cpp	2013-06-04 17:22:40 +0000
@@ -0,0 +1,777 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <sstream>
+#include <iostream>
+#include <cstdlib>
+#include <list>
+
+#include <zorba/base64.h>
+#include <zorba/empty_sequence.h>
+#include <zorba/diagnostic_list.h>
+#include <zorba/function.h>
+#include <zorba/external_module.h>
+#include <zorba/user_exception.h>
+#include <zorba/item_factory.h>
+#include <zorba/serializer.h>
+#include <zorba/singleton_item_sequence.h>
+#include <zorba/vector_item_sequence.h>
+#include <zorba/zorba.h>
+
+#include "JavaVMSingleton.h"
+
+#define SCHEMATOOLS_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/schema-tools";
+#define SCHEMATOOLS_OPTIONS_NAMESPACE "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";
+
+class JavaException {
+};
+
+#define CHECK_EXCEPTION(env)  if ((lException = env->ExceptionOccurred())) throw JavaException()
+
+namespace zorba
+{
+namespace schematools
+{
+
+class SchemaToolsModule;
+class Inst2xsdFunction;
+class Xsd2instFunction;
+class STOptions;
+
+
+class Inst2xsdFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    Inst2xsdFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~Inst2xsdFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "inst2xsd-internal"; }
+
+    virtual ItemSequence_t 
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+class Xsd2instFunction : public ContextualExternalFunction
+{
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
+    XmlDataManager* theDataManager;
+
+  public:
+    Xsd2instFunction(const ExternalModule* aModule) :
+      theModule(aModule),
+      theFactory(Zorba::getInstance(0)->getItemFactory()),
+      theDataManager(Zorba::getInstance(0)->getXmlDataManager())
+    {}
+
+    ~Xsd2instFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
+    { return "xsd2inst-internal"; }
+
+    virtual ItemSequence_t
+      evaluate(const ExternalFunction::Arguments_t& args,
+               const zorba::StaticContext*,
+               const zorba::DynamicContext*) const;
+};
+
+
+class SchemaToolsModule : public ExternalModule {
+  private:
+    ExternalFunction* inst2xsd;
+    ExternalFunction* xsd2inst;
+
+  public:
+    SchemaToolsModule() :
+      inst2xsd(new Inst2xsdFunction(this)),
+      xsd2inst(new Xsd2instFunction(this))
+    {}
+
+    ~SchemaToolsModule()
+    {
+      delete inst2xsd;
+      delete xsd2inst;
+    }
+
+    virtual String getURI() const
+    { return SCHEMATOOLS_MODULE_NAMESPACE; }
+
+    virtual ExternalFunction* getExternalFunction(const String& localName);
+
+    virtual void destroy()
+    {
+      delete this;
+    }
+};
+
+
+class STOptions
+{
+public:
+  typedef enum
+  {
+    RUSSIAN_DOLL_DESIGN = 1,
+    SALAMI_SLICE_DESIGN = 2,
+    VENETIAN_BLIND_DESIGN = 3,
+  } design_t;
+
+  typedef enum
+  {
+    SMART_TYPES = 1,
+    ALWAYS_STRING_TYPES = 2,
+  } simple_content_types_t;
+
+
+private:
+  int theDesign;
+  int theSimpleContentType;
+  // useEnumeration NEVER = 1
+  int theUseEnumeration;
+  bool theVerbose;
+
+  bool theNetworkDownloads;
+  bool theNoPVR;
+  bool theNoUPA;
+
+public:
+  STOptions() : theDesign(STOptions::VENETIAN_BLIND_DESIGN),
+    theSimpleContentType(STOptions::SMART_TYPES),
+    theUseEnumeration(10), theVerbose(false),
+    theNetworkDownloads(false), theNoPVR(false), theNoUPA(false)
+  {}
+
+  void parseI(Item optionsNode, ItemFactory *itemFactory);
+  void parseX(Item optionsNode, ItemFactory *itemFactory);
+
+  int getDesign()
+  {
+    return theDesign;
+  }
+
+  int getSimpleContentType()
+  {
+    return theSimpleContentType;
+  }
+
+  int getUseEnumeration()
+  {
+    return theUseEnumeration;
+  }
+
+  bool isVerbose()
+  {
+    return theVerbose;
+  }
+
+  bool isNetworkDownloads()
+  {
+    return theNetworkDownloads;
+  }
+
+  bool isNoPVR()
+  {
+    return theNoPVR;
+  }
+
+  bool isNoUPA()
+  {
+    return theNoUPA;
+  }
+};
+
+
+ExternalFunction* SchemaToolsModule::getExternalFunction(const String& localName)
+{
+  if (localName == "inst2xsd-internal")
+  {
+    return inst2xsd;
+  }
+  else if (localName == "xsd2inst-internal")
+  {
+    return xsd2inst;
+  }
+
+  return 0;
+}
+
+
+ItemSequence_t
+Inst2xsdFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamincContext) const
+{
+  jthrowable lException = 0;
+  static JNIEnv* env;
+
+  try
+  {
+    env = zorba::jvm::JavaVMSingleton::getInstance(aStaticContext)->getEnv();
+
+    // Local variables
+    Zorba_SerializerOptions_t lOptions;
+    lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
+    Serializer_t lSerializer = Serializer::createSerializer(lOptions);
+    jclass myClass;
+    jmethodID myMethod;
+
+    // read input param 0
+    Iterator_t lIter = args[0]->getIterator();
+    lIter->open();
+
+    Item item;
+    std::vector<jstring> xmlUtfVec;
+
+    while( lIter->next(item) )
+    {
+      // Searialize Item
+      std::ostringstream os;
+      SingletonItemSequence lSequence(item);
+      lSerializer->serialize(&lSequence, os);
+      std::string xmlString = os.str();
+      const char* xml = xmlString.c_str();
+      //std::cout << "  xmlString: '" << xml << "'" << std::endl; std::cout.flush();
+      xmlUtfVec.push_back( env->NewStringUTF(xml) );
+      CHECK_EXCEPTION(env);
+    }
+
+    lIter->close();
+
+    // read input parm 1: $options
+    Item optionsItem;
+    Iterator_t arg1Iter = args[1]->getIterator();
+    arg1Iter->open();
+    bool hasOptions = arg1Iter->next(optionsItem);
+    arg1Iter->close();
+
+    STOptions options;
+    if (hasOptions)
+      options.parseI(optionsItem, theFactory);
+
+
+    // make options object
+    jclass optClass = env->FindClass("org/apache/xmlbeans/impl/inst2xsd/Inst2XsdOptions");
+    CHECK_EXCEPTION(env);
+    jmethodID optConstrId = env->GetMethodID(optClass, "<init>", "()V" );
+    CHECK_EXCEPTION(env);
+    jobject optObj = env->NewObject(optClass, optConstrId);
+    CHECK_EXCEPTION(env);
+    jmethodID optSetDegignId = env->GetMethodID(optClass, "setDesign", "(I)V" );
+    CHECK_EXCEPTION(env);
+    env->CallVoidMethod(optObj, optSetDegignId, options.getDesign());
+    CHECK_EXCEPTION(env);
+    jmethodID optSetEnumId = env->GetMethodID(optClass, "setUseEnumerations", "(I)V" );
+    CHECK_EXCEPTION(env);
+    env->CallVoidMethod(optObj, optSetEnumId, options.getUseEnumeration());
+    CHECK_EXCEPTION(env);
+    jmethodID optSetSCId = env->GetMethodID(optClass, "setSimpleContentTypes", "(I)V" );
+    CHECK_EXCEPTION(env);
+    env->CallVoidMethod(optObj, optSetSCId, options.getSimpleContentType());
+    CHECK_EXCEPTION(env);
+    jmethodID optSetVerboseId = env->GetMethodID(optClass, "setVerbose", "(Z)V" );
+    CHECK_EXCEPTION(env);
+    env->CallVoidMethod(optObj, optSetVerboseId, options.isVerbose());
+    CHECK_EXCEPTION(env);
+
+    // Create String[]
+    jclass strCls = env->FindClass("Ljava/lang/String;");
+    CHECK_EXCEPTION(env);
+    jobjectArray jXmlStrArray = env->NewObjectArray(xmlUtfVec.size(), strCls, NULL);
+    //std::cout << "  NewObjectArray: '" << jXmlStrArray << "'" << std::endl; std::cout.flush();
+    CHECK_EXCEPTION(env);
+
+    for ( jsize i = 0; i<(jsize)xmlUtfVec.size(); i++)
+    {
+      env->SetObjectArrayElement(jXmlStrArray, i, xmlUtfVec[i]);
+      CHECK_EXCEPTION(env);
+      env->DeleteLocalRef((jstring)xmlUtfVec[i]);
+      CHECK_EXCEPTION(env);
+    }
+
+    // Create a Inst2XsdHelper class
+    myClass = env->FindClass("org/zorbaxquery/modules/schemaTools/Inst2XsdHelper");
+    CHECK_EXCEPTION(env);
+    myMethod = env->GetStaticMethodID(myClass, "inst2xsd",
+        "([Ljava/lang/String;Lorg/apache/xmlbeans/impl/inst2xsd/Inst2XsdOptions;)[Ljava/lang/String;");
+    CHECK_EXCEPTION(env);
+    jobjectArray resStrArray = (jobjectArray) env->CallStaticObjectMethod(myClass,
+        myMethod, jXmlStrArray, optObj);
+    CHECK_EXCEPTION(env);
+    //std::cout << "  CallStaticObjectMethod: '" << jXmlStrArray << "'" << std::endl; std::cout.flush();
+
+    jsize resStrArraySize = env->GetArrayLength(resStrArray);
+    CHECK_EXCEPTION(env);
+    //std::cout << "  GetArrayLength: '" << resStrArraySize << "'" << std::endl; std::cout.flush();
+    std::vector<Item> vec;
+
+
+    for( jsize i=0; i<resStrArraySize; i++)
+    {
+      jobject resStr = env->GetObjectArrayElement(resStrArray, i);
+
+      const char *str;
+      str = env->GetStringUTFChars( (jstring)resStr, NULL);
+      if ( str == NULL ) return NULL;
+
+      std::string lBinaryString(str);
+
+      env->ReleaseStringUTFChars( (jstring)resStr, str);
+      //std::cout << "  lBinaryString '" << lBinaryString << "'" << std::endl; std::cout.flush();
+
+      std::stringstream lStream(lBinaryString);
+      Item lRes = theDataManager->parseXML(lStream);
+
+      vec.push_back(lRes);
+    }
+
+    return ItemSequence_t(new VectorItemSequence(vec));
+  }
+  catch (zorba::jvm::VMOpenException&)
+  {
+    Item lQName = theFactory->createQName(SCHEMATOOLS_MODULE_NAMESPACE,
+        "VM001");
+    throw USER_EXCEPTION(lQName, "Could not start the Java VM (is the classpath set?)");
+  }
+  catch (JavaException&)
+  {
+    jclass stringWriterClass = env->FindClass("java/io/StringWriter");
+    jclass printWriterClass = env->FindClass("java/io/PrintWriter");
+    jclass throwableClass = env->FindClass("java/lang/Throwable");
+    jobject stringWriter = env->NewObject(
+        stringWriterClass,
+        env->GetMethodID(stringWriterClass, "<init>", "()V"));
+
+    jobject printWriter = env->NewObject(
+        printWriterClass,
+        env->GetMethodID(printWriterClass, "<init>", "(Ljava/io/Writer;)V"),
+        stringWriter);
+
+    env->CallObjectMethod(lException,
+        env->GetMethodID(throwableClass, "printStackTrace",
+            "(Ljava/io/PrintWriter;)V"),
+        printWriter);
+
+    //env->CallObjectMethod(printWriter, env->GetMethodID(printWriterClass, "flush", "()V"));
+    jmethodID toStringMethod =
+      env->GetMethodID(stringWriterClass, "toString", "()Ljava/lang/String;");
+    jobject errorMessageObj = env->CallObjectMethod(
+        stringWriter, toStringMethod);
+    jstring errorMessage = (jstring) errorMessageObj;
+    const char *errMsg = env->GetStringUTFChars(errorMessage, 0);
+    std::stringstream s;
+    s << "A Java Exception was thrown:" << std::endl << errMsg;
+    env->ReleaseStringUTFChars(errorMessage, errMsg);
+    std::string err("");
+    err += s.str();
+    env->ExceptionClear();
+    Item lQName = theFactory->createQName(SCHEMATOOLS_MODULE_NAMESPACE,
+        "JAVA-EXCEPTION");
+    throw USER_EXCEPTION(lQName, err);
+  }
+
+  return ItemSequence_t(new EmptySequence());
+}
+
+
+
+ItemSequence_t
+Xsd2instFunction::evaluate(const ExternalFunction::Arguments_t& args,
+                           const zorba::StaticContext* aStaticContext,
+                           const zorba::DynamicContext* aDynamicContext) const
+{
+  Iterator_t lIter;
+
+  jthrowable lException = 0;
+  static JNIEnv* env;
+
+  try
+  {
+    env = zorba::jvm::JavaVMSingleton::getInstance(aStaticContext)->getEnv();
+
+    // Local variables
+    std::ostringstream os;
+    Zorba_SerializerOptions_t lOptions;
+    lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
+    Serializer_t lSerializer = Serializer::createSerializer(lOptions);
+
+    const char* xml;
+    std::string xmlString;
+
+    // read input param 0: schemas
+    lIter = args[0]->getIterator();
+    lIter->open();
+
+    Item item;
+    std::vector<jstring> xmlUtfVec;
+
+    while( lIter->next(item) )
+    {
+      // Searialize Item
+      std::ostringstream os;
+      SingletonItemSequence lSequence(item);
+      lSerializer->serialize(&lSequence, os);
+      std::string xmlString = os.str();
+      const char* xml = xmlString.c_str();
+      //std::cout << "  xmlString: '" << xml << "'" << std::endl; std::cout.flush();
+      xmlUtfVec.push_back( env->NewStringUTF(xml) );
+      CHECK_EXCEPTION(env);
+    }
+
+    lIter->close();
+
+
+    // Create String[]
+    jclass strCls = env->FindClass("Ljava/lang/String;");
+    CHECK_EXCEPTION(env);
+    jobjectArray jXmlStrArray = env->NewObjectArray(xmlUtfVec.size(), strCls, NULL);
+    //std::cout << "  NewObjectArray: '" << jXmlStrArray << "'" << std::endl; std::cout.flush();
+    CHECK_EXCEPTION(env);
+
+    for ( jsize i = 0; i<(jsize)xmlUtfVec.size(); i++)
+    {
+      env->SetObjectArrayElement(jXmlStrArray, i, xmlUtfVec[i]);
+      CHECK_EXCEPTION(env);
+      env->DeleteLocalRef((jstring)xmlUtfVec[i]);
+      CHECK_EXCEPTION(env);
+    }
+
+    // Get and create param 1: rootName string in jStrParam2
+    lIter = args[1]->getIterator();
+    lIter->open();
+    lIter->next(item);
+    lIter->close();
+    //   Searialize Item
+    SingletonItemSequence lSequence(item);
+    lSerializer->serialize(&lSequence, os);
+    xmlString = os.str();
+    xml = xmlString.c_str();
+    jstring jStrParam2 = env->NewStringUTF(xml);
+
+    // read input param 2: $options
+    Item optionsItem;
+    STOptions options;
+    lIter = args[2]->getIterator();
+    lIter->open();
+    bool isOpen = lIter->isOpen();
+    if ( isOpen )
+    {
+      bool hasOptions = lIter->next(optionsItem);
+      lIter->close();
+
+      if (hasOptions)
+        options.parseX(optionsItem, theFactory);
+    }
+
+    // make options object
+    jclass optClass = env->FindClass("org/zorbaxquery/modules/schemaTools/Xsd2InstHelper$Xsd2InstOptions");
+    CHECK_EXCEPTION(env);
+    jmethodID optConstrId = env->GetMethodID(optClass, "<init>", "()V" );
+    CHECK_EXCEPTION(env);
+    jobject optObj = env->NewObject(optClass, optConstrId);
+    CHECK_EXCEPTION(env);
+    jmethodID optSetNetId = env->GetMethodID(optClass, "setNetworkDownloads", "(Z)V" );
+    CHECK_EXCEPTION(env);
+    env->CallVoidMethod(optObj, optSetNetId, options.isNetworkDownloads());
+    CHECK_EXCEPTION(env);
+    jmethodID optSetNoPVRId = env->GetMethodID(optClass, "setNopvr", "(Z)V" );
+    CHECK_EXCEPTION(env);
+    env->CallVoidMethod(optObj, optSetNoPVRId, options.isNoPVR());
+    CHECK_EXCEPTION(env);
+    jmethodID optSetNoUPAId = env->GetMethodID(optClass, "setNoupa", "(Z)V" );
+    CHECK_EXCEPTION(env);
+    env->CallVoidMethod(optObj, optSetNoUPAId, options.isNoUPA());
+    CHECK_EXCEPTION(env);
+
+    // Create a Inst2XsdHelper class
+    jclass myClass = env->FindClass("org/zorbaxquery/modules/schemaTools/Xsd2InstHelper");
+    CHECK_EXCEPTION(env);
+    jmethodID myMethod = env->GetStaticMethodID(myClass, "xsd2inst",
+        "([Ljava/lang/String;Ljava/lang/String;Lorg/zorbaxquery/modules/schemaTools/Xsd2InstHelper$Xsd2InstOptions;)Ljava/lang/String;");
+    CHECK_EXCEPTION(env);
+    jobject resStr = (jobjectArray) env->CallStaticObjectMethod(myClass, myMethod, jXmlStrArray, jStrParam2, optObj);
+    CHECK_EXCEPTION(env);
+    //std::cout << "  CallStaticObjectMethod: '" << resStr << "'" << std::endl; std::cout.flush();
+
+    const char *str;
+    str = env->GetStringUTFChars( (jstring)resStr, NULL);
+    CHECK_EXCEPTION(env);
+
+    std::string lBinaryString(str);
+
+    env->ReleaseStringUTFChars( (jstring)resStr, str);
+    //std::cout << "  lBinaryString '" << lBinaryString << "'" << std::endl; std::cout.flush();
+
+    std::stringstream lStream(lBinaryString);
+    Item lRes = theDataManager->parseXML(lStream);
+
+    return ItemSequence_t(new SingletonItemSequence(lRes));
+  }
+  catch (zorba::jvm::VMOpenException&)
+  {
+    Item lQName = theFactory->createQName(SCHEMATOOLS_MODULE_NAMESPACE,
+                                          "VM001");
+    throw USER_EXCEPTION(lQName, "Could not start the Java VM (is the classpath set?)");
+  }
+  catch (JavaException&)
+  {
+    jclass stringWriterClass = env->FindClass("java/io/StringWriter");
+    jclass printWriterClass = env->FindClass("java/io/PrintWriter");
+    jclass throwableClass = env->FindClass("java/lang/Throwable");
+    jobject stringWriter = env->NewObject(
+          stringWriterClass,
+          env->GetMethodID(stringWriterClass, "<init>", "()V"));
+
+    jobject printWriter = env->NewObject(
+          printWriterClass,
+          env->GetMethodID(printWriterClass, "<init>", "(Ljava/io/Writer;)V"),
+          stringWriter);
+
+    env->CallObjectMethod(lException,
+                          env->GetMethodID(throwableClass, "printStackTrace",
+                                           "(Ljava/io/PrintWriter;)V"),
+                          printWriter);
+
+    //env->CallObjectMethod(printWriter, env->GetMethodID(printWriterClass, "flush", "()V"));
+    jmethodID toStringMethod =
+        env->GetMethodID(stringWriterClass, "toString", "()Ljava/lang/String;");
+    jobject errorMessageObj = env->CallObjectMethod(
+        stringWriter, toStringMethod);
+    jstring errorMessage = (jstring) errorMessageObj;
+    const char *errMsg = env->GetStringUTFChars(errorMessage, 0);
+    std::stringstream s;
+    s << "A Java Exception was thrown:" << std::endl << errMsg;
+    env->ReleaseStringUTFChars(errorMessage, errMsg);
+    std::string err("");
+    err += s.str();
+    env->ExceptionClear();
+    Item lQName = theFactory->createQName(SCHEMATOOLS_MODULE_NAMESPACE,
+                                          "JAVA-EXCEPTION");
+    throw USER_EXCEPTION(lQName, err);
+  }
+
+  return ItemSequence_t(new EmptySequence());
+}
+
+
+
+bool compareItemQName(Item item, const char *localname, const char *ns)
+{
+  int node_kind = item.getNodeKind();
+  if(node_kind != store::StoreConsts::elementNode)
+    return false;
+  Item node_name;
+  item.getNodeName(node_name);
+  String  item_namespace = node_name.getNamespace();
+  if(ns && ns[0] && item_namespace != ns )
+  {
+    return false;
+  }
+  String  item_name = node_name.getLocalName();
+  if(item_name != localname)
+  {
+    return false;
+  }
+  return true;
+}
+
+
+bool getChild(zorba::Iterator_t children, const char *localname, const char *ns,
+                           zorba::Item &child_item);
+bool getChild(zorba::Item &lItem, const char *localname, const char *ns,
+                           zorba::Item &child_item)
+{
+  Iterator_t    children;
+  children = lItem.getChildren();
+  children->open();
+  bool retval = getChild(children, localname, ns, child_item);
+  children->close();
+  return retval;
+}
+
+
+bool getChild(zorba::Iterator_t children, const char *localname, const char *ns,
+              zorba::Item &child_item)
+{
+  while(children->next(child_item))
+  {
+    if(child_item.getNodeKind() != store::StoreConsts::elementNode)
+      continue;
+    Item    child_name;
+    child_item.getNodeName(child_name);
+    String  item_namespace = child_name.getNamespace();
+    if(item_namespace != ns)
+    {
+      continue;//next child
+    }
+    String  item_name = child_name.getLocalName();
+    if(item_name != localname)
+    {
+      continue;//next child
+    }
+    return true;
+  }
+  return false;
+}
+
+void STOptions::parseI(Item optionsNode, ItemFactory *itemFactory)
+{
+  if(optionsNode.isNull())
+    return;
+
+  if(!compareItemQName(optionsNode, "inst2xsd-options", SCHEMATOOLS_OPTIONS_NAMESPACE) )
+  {
+    std::stringstream lErrorMessage;
+    Item options_qname;
+    optionsNode.getNodeName(options_qname);
+    lErrorMessage << "Options field must be of element 'inst2xsd-options' " <<
+                     "instead of '" <<
+                     options_qname.getStringValue() << "'. ";
+    Item errWrongParamQName;
+    String errName("WrongParam");
+    errWrongParamQName = itemFactory->createQName(SCHEMATOOLS_OPTIONS_NAMESPACE, errName);
+    String errDescription(lErrorMessage.str());
+    throw USER_EXCEPTION(errWrongParamQName, errDescription);
+  }
+
+  zorba::Item child_item;
+
+  if(getChild(optionsNode, "design", SCHEMATOOLS_OPTIONS_NAMESPACE, child_item))
+  {
+    String design_text = child_item.getStringValue();
+    if ( design_text == "rdd" )
+      theDesign = RUSSIAN_DOLL_DESIGN;
+    else if ( design_text == "ssd" )
+      theDesign = SALAMI_SLICE_DESIGN;
+    else if ( design_text == "vbd" )
+      theDesign = VENETIAN_BLIND_DESIGN;
+  }
+
+  if(getChild(optionsNode, "simple-content-types", SCHEMATOOLS_OPTIONS_NAMESPACE, child_item))
+  {
+    String sct_text = child_item.getStringValue();
+    if ( sct_text == "always-string" )
+      theSimpleContentType = ALWAYS_STRING_TYPES;
+    else if ( sct_text == "smart" )
+      theSimpleContentType = SMART_TYPES;
+  }
+
+  if(getChild(optionsNode, "verbose", SCHEMATOOLS_OPTIONS_NAMESPACE, child_item))
+  {
+    String sct_text = child_item.getStringValue();
+    if ( sct_text == "true" || sct_text == "1" )
+      theVerbose = true;
+    else
+      theVerbose = false;
+  }
+
+  if(getChild(optionsNode, "use-enumeration", SCHEMATOOLS_OPTIONS_NAMESPACE, child_item))
+  {
+    String sct_text = child_item.getStringValue();
+    int ival = atoi(sct_text.c_str());
+    if (ival>1)
+      theUseEnumeration = ival;
+    else
+      theUseEnumeration = 1;
+  }
+}
+
+void STOptions::parseX(Item optionsNode, ItemFactory *itemFactory)
+{
+  if(optionsNode.isNull())
+    return;
+
+  if(!compareItemQName(optionsNode, "xsd2inst-options", SCHEMATOOLS_OPTIONS_NAMESPACE))
+  {
+    std::stringstream lErrorMessage;
+    Item options_qname;
+    optionsNode.getNodeName(options_qname);
+    lErrorMessage << "Options field must be of element 'xsd2inst-options' instead of '" <<
+                     options_qname.getStringValue() << "'";
+    Item errWrongParamQName;
+    String errName("WrongParam");
+    errWrongParamQName = itemFactory->createQName(SCHEMATOOLS_OPTIONS_NAMESPACE, errName);
+    String errDescription(lErrorMessage.str());
+    throw USER_EXCEPTION(errWrongParamQName, errDescription);
+  }
+
+  zorba::Item child_item;
+
+  if(getChild(optionsNode, "network-downloads", SCHEMATOOLS_OPTIONS_NAMESPACE, child_item))
+  {
+    //theNetworkDownloads = child_item.getBooleanValue();
+    String sct_text = child_item.getStringValue();
+    if ( sct_text == "true" || sct_text == "1" )
+      theNetworkDownloads = true;
+    else
+      theNetworkDownloads = false;
+  }
+
+  if(getChild(optionsNode, "no-pvr", SCHEMATOOLS_OPTIONS_NAMESPACE, child_item))
+  {
+    //theNoPVR = child_item.getBooleanValue();
+    String sct_text = child_item.getStringValue();
+    if ( sct_text == "true" || sct_text == "1" )
+      theNetworkDownloads = true;
+    else
+      theNetworkDownloads = false;
+  }
+
+  if(getChild(optionsNode, "no-pvr", SCHEMATOOLS_OPTIONS_NAMESPACE, child_item))
+  {
+    //theNoUPA = child_item.getBooleanValue();
+    String sct_text = child_item.getStringValue();
+    if ( sct_text == "true" || sct_text == "1" )
+      theNetworkDownloads = true;
+    else
+      theNetworkDownloads = false;
+  }
+}
+
+}}; // namespace zorba, schematools
+
+#ifdef WIN32
+#  define DLL_EXPORT __declspec(dllexport)
+#else
+#  define DLL_EXPORT __attribute__ ((visibility("default")))
+#endif
+
+extern "C" DLL_EXPORT zorba::ExternalModule* createModule()
+{
+  return new zorba::schematools::SchemaToolsModule();
+}
+/* vim:set et sw=2 ts=2: */

=== added directory 'srcJava'
=== added file 'srcJava/CMakeLists.txt'
--- srcJava/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ srcJava/CMakeLists.txt	2013-06-04 17:22:40 +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.
+
+# all external module libraries are generated in the directory
+# of the corresponding .xq file
+MESSAGE(STATUS "Add srcJava")
+
+# Java
+
+find_package( Java)
+set( NON_NATIVE_TARGET TRUE)
+
+
+# Verbose makefile
+set( CMAKE_VERBOSE_MAKEFILE TRUE)
+
+
+set( JAR_NAME ${PROJECT_NAME}-${SCHEMA_TOOLS_VERSION}.jar )
+set( CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+# find all java source files
+file(GLOB_RECURSE JAVA_SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
+    "${CMAKE_CURRENT_SOURCE_DIR}/*.java")
+
+IF (WIN32)
+  set( JAVA_CLASS_PATH
+    ${JAVA_CLASS_PATH};${XMLBEANS_JAR}
+    )
+ELSE (WIN32)
+  set( JAVA_CLASS_PATH
+    ${JAVA_CLASS_PATH}:${XMLBEANS_JAR}
+    )
+ENDIF (WIN32)
+
+# Compile all java files
+add_custom_target( ${PROJECT_NAME}.jar.classes
+   COMMAND ${JAVA_COMPILE} -d ${CMAKE_CURRENT_BINARY_DIR}
+           -cp ${JAVA_CLASS_PATH}
+           ${JAVA_SOURCE_FILES}
+   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+   SOURCES ${JAVA_SOURCE_FILES})
+add_dependencies(${PROJECT_NAME}.jar.classes  ${JAVA_SOURCE_FILES})
+
+
+
+# jar all class files into a big jar
+add_custom_command(
+  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${JAR_NAME}
+  COMMAND ${JAVA_ARCHIVE} cvf ${JAR_NAME} org
+  DEPENDS ${PROJECT_NAME}.jar.classes
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
+
+add_custom_target( ${JAR_NAME} ALL
+  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${JAR_NAME} )
+
+# add Jar dependencies
+DECLARE_ZORBA_JAR(FILE ${CMAKE_CURRENT_BINARY_DIR}/${JAR_NAME}
+  TARGET ${JAR_NAME})
+DECLARE_ZORBA_JAR(FILE ${XMLBEANS_JAR} EXTERNAL)
+
+MESSAGE(STATUS "End srcJava")
\ No newline at end of file

=== added directory 'srcJava/org'
=== added directory 'srcJava/org/zorbaxquery'
=== added directory 'srcJava/org/zorbaxquery/modules'
=== added directory 'srcJava/org/zorbaxquery/modules/schemaTools'
=== added file 'srcJava/org/zorbaxquery/modules/schemaTools/CppInputStream.java'
--- srcJava/org/zorbaxquery/modules/schemaTools/CppInputStream.java	1970-01-01 00:00:00 +0000
+++ srcJava/org/zorbaxquery/modules/schemaTools/CppInputStream.java	2013-06-04 17:22:40 +0000
@@ -0,0 +1,59 @@
+package org.zorbaxquery.modules.schemaTools;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InterruptedIOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class CppInputStream
+    extends InputStream
+{
+    List<Byte> data = new ArrayList<Byte>();
+    int off = 0;
+    private boolean endflag = false;
+
+    public void push(byte[] d)
+    {
+        synchronized(data)
+        {
+            if(d == null)
+            {
+                this.endflag = true;
+            }
+            else
+            {
+                for(int i = 0; i < d.length;++i)
+                {
+                    data.add(d[i]);
+                }
+            }
+        }
+    }
+
+    @Override
+    public int read() throws IOException
+    {
+        synchronized(data)
+        {
+            while(data.isEmpty()&&!endflag)
+            {
+                try
+                {
+                    data.wait();
+                }
+                catch (InterruptedException e)
+                {
+                    throw new InterruptedIOException();
+                }
+            }
+        }
+        if(endflag)
+            return -1;
+        else
+            return data.remove(0);
+    }
+}

=== added file 'srcJava/org/zorbaxquery/modules/schemaTools/Inst2XsdHelper.java'
--- srcJava/org/zorbaxquery/modules/schemaTools/Inst2XsdHelper.java	1970-01-01 00:00:00 +0000
+++ srcJava/org/zorbaxquery/modules/schemaTools/Inst2XsdHelper.java	2013-06-04 17:22:40 +0000
@@ -0,0 +1,46 @@
+package org.zorbaxquery.modules.schemaTools;
+
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.inst2xsd.Inst2Xsd;
+import org.apache.xmlbeans.impl.inst2xsd.Inst2XsdOptions;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
+public class Inst2XsdHelper
+{
+    public static String[] inst2xsd(String[] insts, Inst2XsdOptions opt)
+        throws XmlException, IOException
+    {
+        //System.out.println("inst2Xsd inst: '" + insts + "'"); System.out.flush();
+
+        Reader[] instReaders = new Reader[insts.length];
+        for (int i=0; i< insts.length; i++)
+        {
+            instReaders[i] = new StringReader(insts[i]);
+        }
+
+        SchemaDocument[] xsds = Inst2Xsd.inst2xsd(instReaders, opt);
+
+        //System.out.println("inst2Xsd end result '" + xsds[0].toString() + "'");
+
+        String[] res = new String[xsds.length];
+
+        XmlOptions options = new XmlOptions();
+        options.put( XmlOptions.SAVE_INNER );
+        options.put( XmlOptions.SAVE_PRETTY_PRINT );
+        options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
+        //options.put( XmlOptions.SAVE_USE_DEFAULT_NAMESPACE ); don't use this can generate buggy schema
+        options.setSaveNamespacesFirst();
+
+        for (int i = 0; i < xsds.length; i++)
+        {
+            res[i] = xsds[i].xmlText(options);
+        }
+
+        return res;
+    }
+}

=== added file 'srcJava/org/zorbaxquery/modules/schemaTools/Xsd2InstHelper.java'
--- srcJava/org/zorbaxquery/modules/schemaTools/Xsd2InstHelper.java	1970-01-01 00:00:00 +0000
+++ srcJava/org/zorbaxquery/modules/schemaTools/Xsd2InstHelper.java	2013-06-04 17:22:40 +0000
@@ -0,0 +1,170 @@
+package org.zorbaxquery.modules.schemaTools;
+
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+public class Xsd2InstHelper
+{
+    public static class Xsd2InstOptions
+    {
+        private boolean _downloads = false;
+        private boolean _nopvr = false;
+        private boolean _noupa = false;
+
+        /**
+         * @return true if network downloads are allowed, false othervise
+         * Default is false.
+         */
+        public boolean isNetworkDownloads()
+        {
+            return _downloads;
+        }
+
+        /**
+         * set true to allow network downloads, false othervise
+         */
+        public void setNetworkDownloads(boolean downloads)
+        {
+            this._downloads = downloads;
+        }
+
+        /**
+         * @return true to disable particle valid (restriction) rule, false othervise
+         * Default is false.
+         */
+        public boolean isNopvr()
+        {
+            return _nopvr;
+        }
+
+        /**
+         * set true to disable particle valid (restriction) rule, false othervise
+         */
+        public void setNopvr(boolean nopvr)
+        {
+            this._nopvr = nopvr;
+        }
+
+        /**
+         * @return true to disable unique particle attribution rule, false othervise
+         * Default is false.
+         */
+        public boolean isNoupa()
+        {
+            return _noupa;
+        }
+
+        /**
+         * set true to disable unique particle attribution rule, false othervise
+         */
+        public void setNoupa(boolean noupa)
+        {
+            this._noupa = noupa;
+        }
+    }
+
+    public static String xsd2inst(String[] xsds, String rootName, Xsd2InstOptions options)
+        throws XmlException, IOException
+    {
+        //System.out.println("xsd2inst xsd: '" + xsds + "'\n"); System.out.flush();
+        //System.out.println( xsds[0] ); System.out.flush();
+
+        Reader[] instReaders = new Reader[xsds.length];
+        for (int i=0; i< xsds.length; i++)
+        {
+            instReaders[i] = new StringReader(xsds[i]);
+        }
+
+        String res = x2iImpl(instReaders, rootName, options);
+        //System.out.println("inst2Xsd end result '" + res + "'");
+
+        return res;
+    }
+
+
+    private static String x2iImpl(Reader[] schemaReaders, String rootName, Xsd2InstOptions options)
+    {
+        // Process Schema files
+        List sdocs = new ArrayList();
+        for (int i = 0; i < schemaReaders.length; i++)
+        {
+            try
+            {
+                sdocs.add(XmlObject.Factory.parse(schemaReaders[i],
+                        (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest()));
+            }
+            catch (Exception e)
+            {
+                System.err.println("Can not load schema reader: " + i + "  " + schemaReaders[i] + ": ");
+                e.printStackTrace();
+            }
+        }
+
+        XmlObject[] schemas = (XmlObject[]) sdocs.toArray(new XmlObject[sdocs.size()]);
+
+        SchemaTypeSystem sts = null;
+        if (schemas.length > 0)
+        {
+            Collection errors = new ArrayList();
+            XmlOptions compileOptions = new XmlOptions();
+            if (options.isNetworkDownloads())
+                compileOptions.setCompileDownloadUrls();
+            if (options.isNopvr())
+                compileOptions.setCompileNoPvrRule();
+            if (options.isNoupa())
+                compileOptions.setCompileNoUpaRule();
+
+            try
+            {
+                sts = XmlBeans.compileXsd(schemas, XmlBeans.getBuiltinTypeSystem(), compileOptions);
+            }
+            catch (Exception e)
+            {
+                if (errors.isEmpty() || !(e instanceof XmlException))
+                    e.printStackTrace();
+
+                System.out.println("Schema compilation errors: ");
+                for (Iterator i = errors.iterator(); i.hasNext(); )
+                    System.out.println(i.next());
+            }
+        }
+
+        if (sts == null)
+        {
+            throw new RuntimeException("No Schemas to process.");
+        }
+        SchemaType[] globalElems = sts.documentTypes();
+        SchemaType elem = null;
+        for (int i = 0; i < globalElems.length; i++)
+        {
+            if (rootName.equals(globalElems[i].getDocumentElementName().getLocalPart()))
+            {
+                elem = globalElems[i];
+                break;
+            }
+        }
+
+        if (elem == null)
+        {
+            throw new RuntimeException("Could not find a global element with name \"" + rootName + "\"");
+        }
+
+        // Now generate it
+        String result = SampleXmlUtil.createSampleForType(elem);
+
+        return result;
+    }
+}

=== added directory 'test'
=== renamed directory 'test' => 'test.moved'
=== added directory 'test/ExpQueryResults'
=== added directory 'test/ExpQueryResults/schema-tools'
=== added file 'test/ExpQueryResults/schema-tools/inst2xsd-multiTns.xml.res'
--- test/ExpQueryResults/schema-tools/inst2xsd-multiTns.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/inst2xsd-multiTns.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<res><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="zorba-xquery.com/test/modules/schema-tools.2">
+  <xs:element name="b" type="xs:byte"/>
+</xs:schema><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="zorba-xquery.com/test/modules/schema-tools.3">
+  <xs:element name="c" type="xs:string"/>
+</xs:schema><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="zorba-xquery.com/test/modules/schema-tools.1">
+  <xs:element xmlns:sch="zorba-xquery.com/test/modules/schema-tools.1" name="a" type="sch:aType"/>
+  <xs:complexType name="aType">
+    <xs:sequence>
+      <xs:element xmlns:sch="zorba-xquery.com/test/modules/schema-tools.2" ref="sch:b"/>
+      <xs:element xmlns:sch="zorba-xquery.com/test/modules/schema-tools.3" ref="sch:c" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema></res>
+

=== added file 'test/ExpQueryResults/schema-tools/inst2xsd-opt1.xml.res'
--- test/ExpQueryResults/schema-tools/inst2xsd-opt1.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/inst2xsd-opt1.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified">
+  <xs:element name="a" type="aType"/>
+  <xs:element name="b" type="xs:byte"/>
+  <xs:element name="c" type="xs:string"/>
+  <xs:complexType name="aType">
+    <xs:sequence>
+      <xs:element type="xs:byte" name="b"/>
+      <xs:element type="xs:string" name="c" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
+
+

=== added file 'test/ExpQueryResults/schema-tools/inst2xsd-opt2.xml.res'
--- test/ExpQueryResults/schema-tools/inst2xsd-opt2.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/inst2xsd-opt2.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified">
+  <xs:element name="a">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element type="xs:string" name="b"/>
+        <xs:element type="xs:string" name="c" maxOccurs="unbounded" minOccurs="0"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="b" type="xs:string"/>
+  <xs:element name="c" type="xs:string"/>
+</xs:schema>
+
+
+

=== added file 'test/ExpQueryResults/schema-tools/inst2xsd-opt3.xml.res'
--- test/ExpQueryResults/schema-tools/inst2xsd-opt3.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/inst2xsd-opt3.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified">
+  <xs:element name="b" type="xs:byte"/>
+  <xs:element name="c" type="xs:string"/>
+  <xs:element name="a">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element ref="b"/>
+        <xs:element ref="c" maxOccurs="unbounded" minOccurs="0"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+</xs:schema>
+
+

=== added file 'test/ExpQueryResults/schema-tools/inst2xsd-simple.xml.res'
--- test/ExpQueryResults/schema-tools/inst2xsd-simple.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/inst2xsd-simple.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified">
+  <xs:element name="a" type="aType"/>
+  <xs:element name="b" type="xs:byte"/>
+  <xs:element name="c" type="xs:string"/>
+  <xs:complexType name="aType">
+    <xs:sequence>
+      <xs:element type="xs:byte" name="b"/>
+      <xs:element type="xs:string" name="c" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

=== added file 'test/ExpQueryResults/schema-tools/inst2xsd-tns-default.xml.res'
--- test/ExpQueryResults/schema-tools/inst2xsd-tns-default.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/inst2xsd-tns-default.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="my.own.simple/tns">
+  <xs:element xmlns:tns="my.own.simple/tns" name="a" type="tns:aType"/>
+  <xs:element name="b" type="xs:byte"/>
+  <xs:element name="c" type="xs:string"/>
+  <xs:complexType name="aType">
+    <xs:sequence>
+      <xs:element type="xs:byte" name="b"/>
+      <xs:element type="xs:string" name="c" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
+

=== added file 'test/ExpQueryResults/schema-tools/inst2xsd-tns.xml.res'
--- test/ExpQueryResults/schema-tools/inst2xsd-tns.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/inst2xsd-tns.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="zorba-xquery.com/test/modules/schema-tools">
+  <xs:element xmlns:sch="zorba-xquery.com/test/modules/schema-tools" name="a" type="sch:aType"/>
+  <xs:element name="b" type="xs:byte"/>
+  <xs:element name="c" type="xs:string"/>
+  <xs:complexType name="aType">
+    <xs:sequence>
+      <xs:element type="xs:byte" name="b"/>
+      <xs:element type="xs:string" name="c" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>

=== added file 'test/ExpQueryResults/schema-tools/xsd2inst-opt1.xml.res'
--- test/ExpQueryResults/schema-tools/xsd2inst-opt1.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/xsd2inst-opt1.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<a>
+  <b>string</b>
+  <c>string</c>
+</a>

=== added file 'test/ExpQueryResults/schema-tools/xsd2inst-simple.xml.res'
--- test/ExpQueryResults/schema-tools/xsd2inst-simple.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/xsd2inst-simple.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<a>
+  <b>string</b>
+  <c>string</c>
+</a>

=== added file 'test/ExpQueryResults/schema-tools/xsd2inst-tns.xml.res'
--- test/ExpQueryResults/schema-tools/xsd2inst-tns.xml.res	1970-01-01 00:00:00 +0000
+++ test/ExpQueryResults/schema-tools/xsd2inst-tns.xml.res	2013-06-04 17:22:40 +0000
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sch:a xmlns:sch="zorba-xquery.com/test/modules/schema-tools">
+  <sch:b>2</sch:b>
+  <!--Zero or more repetitions:-->
+  <sch:c>string</sch:c>
+</sch:a>
+

=== added directory 'test/Queries'
=== added directory 'test/Queries/schema-tools'
=== added file 'test/Queries/schema-tools/inst2xsd-err1-badOpt.spec'
--- test/Queries/schema-tools/inst2xsd-err1-badOpt.spec	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-err1-badOpt.spec	2013-06-04 17:22:40 +0000
@@ -0,0 +1,2 @@
+Error: http://www.w3.org/2005/xqt-errors:XQDY0027
+Error: http://www.w3.org/2005/xqt-errors:FORG0001

=== added file 'test/Queries/schema-tools/inst2xsd-err1-badOpt.xq'
--- test/Queries/schema-tools/inst2xsd-err1-badOpt.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-err1-badOpt.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,11 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+let $inst := (<a><b>1</b><c>c</c><c>cc</c></a>, <b>2</b>, <c>ccc</c>)
+let $opt  := <sto:inst2xsd-options>
+                <sto:design>A bad option</sto:design>
+             </sto:inst2xsd-options>
+return
+    st:inst2xsd($inst, $opt)

=== added file 'test/Queries/schema-tools/inst2xsd-multiTns.xq'
--- test/Queries/schema-tools/inst2xsd-multiTns.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-multiTns.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,16 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+declare namespace myNS1 = "zorba-xquery.com/test/modules/schema-tools.1";
+declare namespace myNS2 = "zorba-xquery.com/test/modules/schema-tools.2";
+declare namespace myNS3 = "zorba-xquery.com/test/modules/schema-tools.3";
+
+let $inst := (<myNS1:a><myNS2:b>1</myNS2:b><myNS3:c>c</myNS3:c><myNS3:c>cc</myNS3:c></myNS1:a>, 
+              <myNS2:b>2</myNS2:b>, 
+              <myNS3:c>ccc</myNS3:c>)
+let $opt  := <sto:inst2xsd-options>
+				<sto:use-enumeration>1</sto:use-enumeration>
+			 </sto:inst2xsd-options>              
+return
+    <res>{st:inst2xsd($inst, $opt)}</res>
+

=== added file 'test/Queries/schema-tools/inst2xsd-opt1.xq'
--- test/Queries/schema-tools/inst2xsd-opt1.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-opt1.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,14 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+let $inst := (<a><b>1</b><c>c</c><c>cc</c></a>, <b>2</b>, <c>ccc</c>)
+let $opt  := <sto:inst2xsd-options>
+                <sto:verbose>true</sto:verbose>
+                <sto:design>vbd</sto:design>
+                <sto:simple-content-types>smart</sto:simple-content-types>
+                <sto:use-enumeration>1</sto:use-enumeration>
+             </sto:inst2xsd-options>
+return
+    st:inst2xsd($inst, $opt)

=== added file 'test/Queries/schema-tools/inst2xsd-opt2.xq'
--- test/Queries/schema-tools/inst2xsd-opt2.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-opt2.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,13 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+let $inst := (<a><b>1</b><c>c</c><c>cc</c></a>, <b>2</b>, <c>ccc</c>)
+let $opt  := <sto:inst2xsd-options>
+                <sto:design>rdd</sto:design>
+                <sto:simple-content-types>always-string</sto:simple-content-types>
+                <sto:use-enumeration>1</sto:use-enumeration>
+             </sto:inst2xsd-options>
+return
+    st:inst2xsd($inst, $opt)

=== added file 'test/Queries/schema-tools/inst2xsd-opt3.xq'
--- test/Queries/schema-tools/inst2xsd-opt3.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-opt3.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,12 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+let $inst := (<a><b>1</b><c>c</c><c>cc</c></a>, <b>2</b>, <c>ccc</c>)
+let $opt  := <sto:inst2xsd-options>
+                <sto:design>ssd</sto:design>
+                <sto:use-enumeration>1</sto:use-enumeration>
+             </sto:inst2xsd-options>
+return
+    st:inst2xsd($inst, $opt)

=== added file 'test/Queries/schema-tools/inst2xsd-simple.xq'
--- test/Queries/schema-tools/inst2xsd-simple.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-simple.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,12 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+let $inst := (<a><b>1</b><c>c</c><c>cc</c></a>, <b>2</b>, <c>ccc</c>)
+let $opt  := <sto:inst2xsd-options>
+				<sto:use-enumeration>1</sto:use-enumeration>
+			 </sto:inst2xsd-options>
+return
+    st:inst2xsd($inst, $opt)
+

=== added file 'test/Queries/schema-tools/inst2xsd-tns-default.xq'
--- test/Queries/schema-tools/inst2xsd-tns-default.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-tns-default.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,14 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+declare default element namespace "my.own.simple/tns";
+
+let $inst := (<a><b>1</b><c>c</c><c>cc</c></a>, 
+              <b>2</b>, 
+              <c>ccc</c>)
+let $opt  := <sto:inst2xsd-options>
+               <sto:use-enumeration>1</sto:use-enumeration>
+             </sto:inst2xsd-options>              
+return
+    st:inst2xsd($inst, $opt)
+

=== added file 'test/Queries/schema-tools/inst2xsd-tns.xq'
--- test/Queries/schema-tools/inst2xsd-tns.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/inst2xsd-tns.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,14 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+declare namespace myNS = "zorba-xquery.com/test/modules/schema-tools";
+
+let $inst := (<myNS:a><myNS:b>1</myNS:b><myNS:c>c</myNS:c><myNS:c>cc</myNS:c></myNS:a>, 
+              <myNS:b>2</myNS:b>, 
+              <myNS:c>ccc</myNS:c>)
+let $opt  := <sto:inst2xsd-options>
+               <sto:use-enumeration>1</sto:use-enumeration>
+             </sto:inst2xsd-options>              
+return
+    st:inst2xsd($inst, $opt)
+

=== added file 'test/Queries/schema-tools/xsd2inst-err1-badOpt.spec'
--- test/Queries/schema-tools/xsd2inst-err1-badOpt.spec	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/xsd2inst-err1-badOpt.spec	2013-06-04 17:22:40 +0000
@@ -0,0 +1,1 @@
+Error: http://www.w3.org/2005/xqt-errors:XQDY0027

=== added file 'test/Queries/schema-tools/xsd2inst-err1-badOpt.xq'
--- test/Queries/schema-tools/xsd2inst-err1-badOpt.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/xsd2inst-err1-badOpt.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,24 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+
+let $xsd  :=
+  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+      attributeFormDefault="unqualified"
+      elementFormDefault="qualified">
+    <xs:element name="a" type="aType"/>
+    <xs:complexType name="aType">
+      <xs:sequence>
+        <xs:element type="xs:string" name="b"/>
+        <xs:element type="xs:string" name="c"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:schema>
+let $opt  := <sto:xsd2inst-options>
+                 <sto:badOption/>
+             </sto:xsd2inst-options>
+return
+    st:xsd2inst(($xsd), "a", $opt)
+

=== added file 'test/Queries/schema-tools/xsd2inst-opt1.xq'
--- test/Queries/schema-tools/xsd2inst-opt1.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/xsd2inst-opt1.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,26 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+
+let $xsd  :=
+  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+      attributeFormDefault="unqualified"
+      elementFormDefault="qualified">
+    <xs:element name="a" type="aType"/>
+    <xs:complexType name="aType">
+      <xs:sequence>
+        <xs:element type="xs:string" name="b"/>
+        <xs:element type="xs:string" name="c"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:schema>
+let $opt  := <sto:xsd2inst-options>
+                 <sto:network-downloads>true</sto:network-downloads>
+                 <sto:no-pvr>false</sto:no-pvr>
+                 <sto:no-upa>true</sto:no-upa>
+             </sto:xsd2inst-options>
+return
+    st:xsd2inst(($xsd), "a", $opt)
+

=== added file 'test/Queries/schema-tools/xsd2inst-simple.xq'
--- test/Queries/schema-tools/xsd2inst-simple.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/xsd2inst-simple.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,22 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+
+let $xsd  :=
+  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
+      attributeFormDefault="unqualified"
+      elementFormDefault="qualified">
+    <xs:element name="a" type="aType"/>
+    <xs:complexType name="aType">
+      <xs:sequence>
+        <xs:element type="xs:string" name="b"/>
+        <xs:element type="xs:string" name="c"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:schema>
+let $opt  := <sto:xsd2inst-options/>
+return
+    st:xsd2inst(($xsd), "a", $opt)
+

=== added file 'test/Queries/schema-tools/xsd2inst-tns.xq'
--- test/Queries/schema-tools/xsd2inst-tns.xq	1970-01-01 00:00:00 +0000
+++ test/Queries/schema-tools/xsd2inst-tns.xq	2013-06-04 17:22:40 +0000
@@ -0,0 +1,26 @@
+import module namespace st = "http://www.zorba-xquery.com/modules/schema-tools";;
+
+declare namespace sto = "http://www.zorba-xquery.com/modules/schema-tools/schema-tools-options";;
+
+
+
+let $xsd  :=
+  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
+      attributeFormDefault="unqualified" 
+      elementFormDefault="qualified" 
+      targetNamespace="zorba-xquery.com/test/modules/schema-tools"
+      xmlns:sch="zorba-xquery.com/test/modules/schema-tools">
+    <xs:element xmlns:sch="zorba-xquery.com/test/modules/schema-tools" name="a" type="sch:aType"/>
+    <xs:element name="b" type="xs:byte"/>
+    <xs:element name="c" type="xs:string"/>
+    <xs:complexType name="aType">
+      <xs:sequence>
+        <xs:element type="xs:byte" name="b"/>
+        <xs:element type="xs:string" name="c" maxOccurs="unbounded" minOccurs="0"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:schema>
+let $opt  := <sto:xsd2inst-options/>
+return
+    st:xsd2inst(($xsd), "a", $opt)
+