Markos Zaharioudakis has proposed merging 
lp:~zorba-coders/zorba/mz-schema-tools-module into 
lp:~zorba-coders/zorba/schema-tools-module.

Commit message:
XmlDataManager  is not a singleton anymore

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/mz-schema-tools-module/+merge/178618

XmlDataManager  is not a singleton anymore
-- 
https://code.launchpad.net/~zorba-coders/zorba/mz-schema-tools-module/+merge/178618
Your team Zorba Coders is subscribed to branch 
lp:~zorba-coders/zorba/schema-tools-module.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2012-06-14 12:39:26 +0000
+++ CMakeLists.txt	2013-08-05 18:21:28 +0000
@@ -17,12 +17,15 @@
 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)
-  ZORBA_FIND_JNI()
-  FIND_PACKAGE(Java)
   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})

=== added file 'cmake_modules/FindJNI.cmake'
--- cmake_modules/FindJNI.cmake	1970-01-01 00:00:00 +0000
+++ cmake_modules/FindJNI.cmake	2013-08-05 18:21:28 +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)

=== modified file 'src/schema-tools.xq.src/schema-tools.cpp'
--- src/schema-tools.xq.src/schema-tools.cpp	2012-04-05 11:51:23 +0000
+++ src/schema-tools.xq.src/schema-tools.cpp	2013-08-05 18:21:28 +0000
@@ -13,21 +13,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include <sstream>
+
+#include <cstdlib>
 #include <iostream>
-#include <cstdlib>
 #include <list>
+#include <sstream>
 
-#include <zorba/base64.h>
+#include <zorba/diagnostic_list.h>
 #include <zorba/empty_sequence.h>
-#include <zorba/diagnostic_list.h>
+#include <zorba/external_module.h>
 #include <zorba/function.h>
-#include <zorba/external_module.h>
-#include <zorba/user_exception.h>
-#include <zorba/file.h>
 #include <zorba/item_factory.h>
 #include <zorba/serializer.h>
 #include <zorba/singleton_item_sequence.h>
+#include <zorba/user_exception.h>
+#include <zorba/util/base64_util.h>
 #include <zorba/vector_item_sequence.h>
 #include <zorba/zorba.h>
 
@@ -57,56 +57,53 @@
   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())
+      theFactory(Zorba::getInstance(0)->getItemFactory())
     {}
 
-		~Inst2xsdFunction()
+    ~Inst2xsdFunction()
     {}
 
   public:
-		virtual String getURI() const
-		{ return theModule->getURI(); }
+    virtual String getURI() const
+    { return theModule->getURI(); }
 
-		virtual String getLocalName() const
+    virtual String getLocalName() const
     { return "inst2xsd-internal"; }
 
     virtual ItemSequence_t 
-      evaluate(const ExternalFunction::Arguments_t& args,
-               const zorba::StaticContext*,
-               const zorba::DynamicContext*) const;
+    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;
+  private:
+    const ExternalModule* theModule;
+    ItemFactory* theFactory;
 
-	public:
-		Xsd2instFunction(const ExternalModule* aModule) :
+  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
+      theFactory(Zorba::getInstance(0)->getItemFactory())
+    {}
+
+    ~Xsd2instFunction()
+    {}
+
+  public:
+    virtual String getURI() const
+    { return theModule->getURI(); }
+
+    virtual String getLocalName() const
     { return "xsd2inst-internal"; }
 
-		virtual ItemSequence_t
+    virtual ItemSequence_t
       evaluate(const ExternalFunction::Arguments_t& args,
                const zorba::StaticContext*,
                const zorba::DynamicContext*) const;
@@ -115,28 +112,28 @@
 
 class SchemaToolsModule : public ExternalModule {
   private:
-		ExternalFunction* inst2xsd;
-		ExternalFunction* xsd2inst;
+    ExternalFunction* inst2xsd;
+    ExternalFunction* xsd2inst;
 
-	public:
+  public:
     SchemaToolsModule() :
-			inst2xsd(new Inst2xsdFunction(this)),
+      inst2xsd(new Inst2xsdFunction(this)),
       xsd2inst(new Xsd2instFunction(this))
-		{}
+    {}
 
-		~SchemaToolsModule()
-		{
-			delete inst2xsd;
-			delete xsd2inst;
+    ~SchemaToolsModule()
+    {
+      delete inst2xsd;
+      delete xsd2inst;
     }
 
-		virtual String getURI() const
-		{ return SCHEMATOOLS_MODULE_NAMESPACE; }
+    virtual String getURI() const
+    { return SCHEMATOOLS_MODULE_NAMESPACE; }
 
     virtual ExternalFunction* getExternalFunction(const String& localName);
 
-		virtual void destroy()
-		{
+    virtual void destroy()
+    {
       delete this;
     }
 };
@@ -220,15 +217,15 @@
 ExternalFunction* SchemaToolsModule::getExternalFunction(const String& localName)
 {
   if (localName == "inst2xsd-internal")
-	{
-		return inst2xsd;
-	}
+  {
+    return inst2xsd;
+  }
   else if (localName == "xsd2inst-internal")
-	{
-		return xsd2inst;
-	}
+  {
+    return xsd2inst;
+  }
 
-	return 0;
+  return 0;
 }
 
 
@@ -237,41 +234,41 @@
                            const zorba::StaticContext* aStaticContext,
                            const zorba::DynamicContext* aDynamincContext) const
 {
-	jthrowable lException = 0;
-	static JNIEnv* env;
+  jthrowable lException = 0;
+  static JNIEnv* env;
 
-	try
+  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;
+    // 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
+    // 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();
+    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;
@@ -309,103 +306,103 @@
     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
+    // 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);
+    CHECK_EXCEPTION(env);
     myMethod = env->GetStaticMethodID(myClass, "inst2xsd",
         "([Ljava/lang/String;Lorg/apache/xmlbeans/impl/inst2xsd/Inst2XsdOptions;)[Ljava/lang/String;");
-		CHECK_EXCEPTION(env);
+    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));
-	}
+    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 = Zorba::getInstance(0)->getXmlDataManager()->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());
+  {
+    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());
 }
 
 
@@ -538,7 +535,7 @@
     //std::cout << "  lBinaryString '" << lBinaryString << "'" << std::endl; std::cout.flush();
 
     std::stringstream lStream(lBinaryString);
-    Item lRes = theDataManager->parseXML(lStream);
+    Item lRes = Zorba::getInstance(0)->getXmlDataManager()->parseXML(lStream);
 
     return ItemSequence_t(new SingletonItemSequence(lRes));
   }
@@ -775,3 +772,4 @@
 {
   return new zorba::schematools::SchemaToolsModule();
 }
+/* vim:set et sw=2 ts=2: */

=== modified file 'test/Queries/schema-tools/inst2xsd-err1-badOpt.spec'
--- test/Queries/schema-tools/inst2xsd-err1-badOpt.spec	2013-05-17 00:22:13 +0000
+++ test/Queries/schema-tools/inst2xsd-err1-badOpt.spec	2013-08-05 18:21:28 +0000
@@ -1,2 +1,2 @@
+Error: http://www.w3.org/2005/xqt-errors:XQDY0027
 Error: http://www.w3.org/2005/xqt-errors:FORG0001
-Error: http://www.w3.org/2005/xqt-errors:XQDY0027

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

Reply via email to