← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug928987 into lp:zorba

 

Rodolfo Ochoa has proposed merging lp:~zorba-coders/zorba/bug928987 into lp:zorba.

Requested reviews:
  Cezar Andrei (cezar-andrei)
  Matthias Brantner (matthias-brantner)
Related bugs:
  Bug #918159 in Zorba: "Add XQJ to validation queue"
  https://bugs.launchpad.net/zorba/+bug/918159
  Bug #928987 in Zorba: "XQJ integration with JavaAPI"
  https://bugs.launchpad.net/zorba/+bug/928987

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug928987/+merge/99445

Added XQJ support.
New clean branch.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug928987/+merge/99445
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-03-26 21:43:30 +0000
+++ ChangeLog	2012-03-26 23:10:25 +0000
@@ -3,6 +3,7 @@
 version 2.5
 
 New Features:
+  * Added XQJ support.
   * Extended API for Python, Java, PHP and Ruby.
 
 Bug Fixes/Other Changes:

=== modified file 'doc/CMakeLists.txt'
--- doc/CMakeLists.txt	2012-03-26 01:31:32 +0000
+++ doc/CMakeLists.txt	2012-03-26 23:10:25 +0000
@@ -40,6 +40,7 @@
 
 IF (SWIG_FOUND)
   ADD_SUBDIRECTORY(java)
+  ADD_SUBDIRECTORY(xqj)
   ADD_SUBDIRECTORY(python)
   ADD_SUBDIRECTORY(ruby)
   ADD_SUBDIRECTORY(php)

=== added directory 'doc/xqj'
=== added file 'doc/xqj/CMakeLists.txt'
--- doc/xqj/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ doc/xqj/CMakeLists.txt	2012-03-26 23:10:25 +0000
@@ -0,0 +1,35 @@
+# 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.
+
+ZORBA_DOXYGEN ("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" "xqjdocs")
+
+IF (DOXYGEN_FOUND)
+  ADD_DEPENDENCIES (doc "xqjdocs")
+
+  CONFIGURE_FILE (
+    ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_b.gif
+    ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_b.gif
+    COPYONLY
+  )
+  CONFIGURE_FILE (
+    ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_r.gif
+    ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_r.gif
+    COPYONLY
+  )
+  CONFIGURE_FILE (
+    ${CMAKE_CURRENT_SOURCE_DIR}/../style/rtab_l.gif
+    ${CMAKE_CURRENT_BINARY_DIR}/html/rtab_l.gif
+    COPYONLY
+  )
+ENDIF (DOXYGEN_FOUND)

=== added file 'doc/xqj/doxy.config.in'
--- doc/xqj/doxy.config.in	1970-01-01 00:00:00 +0000
+++ doc/xqj/doxy.config.in	2012-03-26 23:10:25 +0000
@@ -0,0 +1,1207 @@
+# Doxyfile 1.4.5
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = Zorba XQJ-API
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = @ZORBA_MAJOR_NUMBER@.@ZORBA_MINOR_NUMBER@.@ZORBA_PATCH_NUMBER@
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = @CMAKE_CURRENT_BINARY_DIR@
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, 
+# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, 
+# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, 
+# Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = @CMAKE_SOURCE_DIR@/src @CMAKE_BINARY_DIR@/src
+
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = @CMAKE_SOURCE_DIR@/include @CMAKE_BINARY_DIR@/include
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like the Qt-style comments (thus requiring an 
+# explicit @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF      = YES
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+
+DETAILS_AT_TOP         = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 2
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for Java. 
+# For instance, namespaces will be presented as packages, qualified scopes 
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to 
+# include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also make the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+# BUILTIN_STL_SUPPORT    = NO
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = YES
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = YES
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = YES
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is YES.
+
+SHOW_DIRECTORIES       = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from the 
+# version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = @DOXY_WARN_FORMAT@
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = Doc/doxy.log
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  =  @CMAKE_CURRENT_SOURCE_DIR@/manual
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
+
+FILE_PATTERNS          = *.java *.dox
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
+# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = */.svn \
+                         */.svn/*
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = @CMAKE_CURRENT_BINARY_DIR@/examples
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = *.java
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = YES
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = @CMAKE_CURRENT_SOURCE_DIR@
+
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = NO
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default) 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 2
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+HTML_HEADER            = @CMAKE_CURRENT_SOURCE_DIR@/../style/header.html
+
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = @CMAKE_CURRENT_SOURCE_DIR@/../style/footer.html
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = @CMAKE_CURRENT_SOURCE_DIR@/../style/stylesheet.css
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+#LATEX_CMD_NAME         = latex
+LATEX_CMD_NAME          = @LATEX_COMPILER@
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+#MAKEINDEX_CMD_NAME     = makeindex
+MAKEINDEX_CMD_NAME     = @MAKEINDEX_COMPILER@
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = YES
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = YES
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse 
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = html/@PROJECT_NAME@.TAGFILE
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = YES
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option is superseded by the HAVE_DOT option below. This is only a 
+# fallback. It is recommended to install and use dot, since it yields more 
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = @DOXYGEN_DOT_FOUND@
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+# UML_LOOK               = YES
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
+# generate a call dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable call graphs for selected 
+# functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = @DOXYGEN_DOT_EXECUTABLE_PATH@
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, which results in a white background. 
+# Warning: Depending on the platform used, enabling this option may lead to 
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to 
+# read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+# JW
+# DOT_MULTI_TARGETS      = NO
+DOT_MULTI_TARGETS      = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+# JW SEARCHENGINE           = NO
+SEARCHENGINE           = YES

=== added directory 'doc/xqj/manual'
=== added file 'doc/xqj/manual/indexpage.dox'
--- doc/xqj/manual/indexpage.dox	1970-01-01 00:00:00 +0000
+++ doc/xqj/manual/indexpage.dox	2012-03-26 23:10:25 +0000
@@ -0,0 +1,18 @@
+/*! \mainpage XQJ API Documentation
+
+  Zorba ships with a XQJ binding that provides basic features in order to prepare and execute queries
+  with Zorba.
+
+  For the moment, we provide a <a class="en" href="examples.html">TCK set</a> that show how this language binding can be used.
+  
+  \section note Note for garbage collected languages
+  Zorba requires that objects must be deleted in a certain order, which Garbage Collectors are not aware of. For that reason, 
+  the Iterators created with XQuery.iterator() must be explicitly deleted with iterator.delete() before the XQuery 
+  object is deleted.
+  
+
+  \example Test_Zorba.java
+   This is a simple example that demonstrate how to use the Zorba XQuery Engine to
+   create, compile, and execute queries.
+ */
+

=== modified file 'swig/CMakeLists.txt'
--- swig/CMakeLists.txt	2012-03-26 01:31:32 +0000
+++ swig/CMakeLists.txt	2012-03-26 23:10:25 +0000
@@ -36,6 +36,7 @@
   ADD_SUBDIRECTORY (python)
   ADD_SUBDIRECTORY (php)
   ADD_SUBDIRECTORY (java)
+  ADD_SUBDIRECTORY (xqj)
   
   IF (APPLE AND UNIVERSAL)
     MESSAGE (STATUS "Ruby module can't be built Universal")

=== added directory 'swig/xqj'
=== added file 'swig/xqj/CMakeLists.txt'
--- swig/xqj/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ swig/xqj/CMakeLists.txt	2012-03-26 23:10:25 +0000
@@ -0,0 +1,76 @@
+# Copyright 2006-2008 The FLWOR Foundation.n
+# 
+# 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.
+
+FIND_PACKAGE ( Java )
+INCLUDE ( ${CMAKE_SOURCE_DIR}/cmake_modules/FindJNI.cmake )
+
+STRING ( COMPARE NOTEQUAL ${JAVA_INCLUDE_PATH} "JAVA_INCLUDE_PATH-NOTFOUND" JNI_FOUND )
+
+IF (JAVA_INCLUDE_PATH)
+  INCLUDE (CMakeJavaInformation )
+  MESSAGE(STATUS "SWIG Java: Generating XQJ API")
+
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQConnection.java" "${CMAKE_CURRENT_BINARY_DIR}/XQConnection.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQDataSource.java" "${CMAKE_CURRENT_BINARY_DIR}/XQDataSource.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQExpression.java" "${CMAKE_CURRENT_BINARY_DIR}/XQExpression.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQItem.java" "${CMAKE_CURRENT_BINARY_DIR}/XQItem.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQItemType.java" "${CMAKE_CURRENT_BINARY_DIR}/XQItemType.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQMetaData.java" "${CMAKE_CURRENT_BINARY_DIR}/XQMetaData.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQPreparedExpression.java" "${CMAKE_CURRENT_BINARY_DIR}/XQPreparedExpression.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQResultItem.java" "${CMAKE_CURRENT_BINARY_DIR}/XQResultItem.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQResultSequence.java" "${CMAKE_CURRENT_BINARY_DIR}/XQResultSequence.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQResultSequenceScrollable.java" "${CMAKE_CURRENT_BINARY_DIR}/XQResultSequenceScrollable.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQSequence.java" "${CMAKE_CURRENT_BINARY_DIR}/XQSequence.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQSequenceType.java" "${CMAKE_CURRENT_BINARY_DIR}/XQSequenceType.java")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/XQStaticContext.java" "${CMAKE_CURRENT_BINARY_DIR}/XQStaticContext.java")
+
+  MESSAGE(STATUS "SWIG Java: Generating XQJ TCK Tests")
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/junit-4.9.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/junit-4.9.jar" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/xqjapi.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjapi.jar" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/xqjtck.jar" "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjtck.jar" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tck/zorba.properties" "${CMAKE_CURRENT_BINARY_DIR}/tck/zorba.properties" COPYONLY)
+
+  SET (XQJ_LOAD_PATH "${CMAKE_BINARY_DIR}/swig/xqj")
+  SET (JAVA_LOAD_PATH "${CMAKE_BINARY_DIR}/swig/java")
+
+  MESSAGE (STATUS "Path for XQJ tests ${XQJ_LOAD_PATH}/tck")
+  IF(WIN32)
+    #Convert to backslashes for windows
+    STRING(REGEX REPLACE "/" "\\\\" XQJ_LOAD_PATH ${XQJ_LOAD_PATH}) 
+    STRING(REGEX REPLACE "/" "\\\\" JAVA_LOAD_PATH ${JAVA_LOAD_PATH}) 
+    MESSAGE (STATUS "Copying tck batch...")
+    CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/tck/xqj_test.bat.in ${CMAKE_CURRENT_BINARY_DIR}/xqj_test.bat)
+    ADD_TEST ("swig_xqj" xqj_test.bat)
+    SET_TESTS_PROPERTIES("swig_xqj" PROPERTIES PASS_REGULAR_EXPRESSION "254 tests")
+  ELSE(WIN32)
+    MESSAGE (STATUS "Copying tck batch...")
+    IF (NOT DEFINED Java_JAVA_EXECUTABLE)
+      SET(Java_JAVA_EXECUTABLE ${JAVA_RUNTIME})
+      SET(Java_JAR_EXECUTABLE ${JAVA_ARCHIVE})
+      SET(Java_JAVAC_EXECUTABLE ${JAVA_COMPILE})
+    ENDIF (NOT DEFINED Java_JAVA_EXECUTABLE)
+    CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/tck/xqj_test.sh.in ${CMAKE_CURRENT_BINARY_DIR}/xqj_test.sh)  
+    EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/xqj_test.sh")
+    EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/junit-4.9.jar")
+    EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjapi.jar")
+    EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/xqjtck.jar")
+    EXECUTE_PROCESS(COMMAND chmod +x "${CMAKE_CURRENT_BINARY_DIR}/tck/zorba.properties")
+    ADD_TEST ("swig_xqj" xqj_test.sh)
+    SET_TESTS_PROPERTIES("swig_xqj" PROPERTIES PASS_REGULAR_EXPRESSION "254 tests")
+  ENDIF(WIN32)
+
+
+ELSE (JAVA_INCLUDE_PATH)
+  MESSAGE ( STATUS "SWIG Java: Not generating XQJ API because JNI headers not found.")
+ENDIF (JAVA_INCLUDE_PATH)
\ No newline at end of file

=== added file 'swig/xqj/XQConnection.java'
--- swig/xqj/XQConnection.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQConnection.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,1446 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Iterator;
+import java.nio.CharBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXResult;
+import javax.xml.transform.stax.StAXSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQExpression;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQMetaData;
+import javax.xml.xquery.XQPreparedExpression;
+import javax.xml.xquery.XQSequence;
+import javax.xml.xquery.XQSequenceType;
+import javax.xml.xquery.XQStaticContext;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+import org.zorbaxquery.api.InMemoryStore;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.ItemFactory;
+import org.zorbaxquery.api.StringVector;
+import org.zorbaxquery.api.XmlDataManager;
+import org.zorbaxquery.api.Zorba;
+
+public class XQConnection implements javax.xml.xquery.XQConnection {
+    private InMemoryStore store;
+    private Zorba zorba;
+    private boolean autocommit;
+    private boolean closed;
+    private Collection<XQExpression> cExpression;
+    private Collection<XQPreparedExpression> cPreparedExpression;
+    private Collection<XQMetaData> cMetadata;
+    private XQStaticContext lStaticContext;
+    private Properties properties;
+    private StringVector uriPaths;
+    private StringVector libPaths;
+    private StringVector modulePaths;
+    
+    //TODO: Rodolfo ALL CASES should return an exception("Not implemented yet")
+    protected Zorba getZorbaInstance() throws XQException {
+        if (zorba!=null) {
+            return zorba;
+        } else {
+            throw new XQException("Error returning Zorba Instance");
+        }
+    }
+    public XQConnection() {
+        cExpression = new ArrayList<XQExpression>();
+        cPreparedExpression = new ArrayList<XQPreparedExpression>();
+        store = InMemoryStore.getInstance();
+        zorba = Zorba.getInstance ( store );
+        autocommit = true;
+        closed = false;
+    }
+    public XQConnection(Properties aProperties) {
+        cExpression = new ArrayList<XQExpression>();
+        cPreparedExpression = new ArrayList<XQPreparedExpression>();
+        store = InMemoryStore.getInstance();
+        zorba = Zorba.getInstance ( store );
+        autocommit = true;
+        closed = false;
+        properties = aProperties;
+        for (String prop :properties.stringPropertyNames()) {
+            if (prop.equalsIgnoreCase(XQDataSource.ZORBA_PROPERTIES_URI_PATHS)) {
+                String[] paths = properties.getProperty(prop).split("[;,]");
+                uriPaths = new StringVector();
+                for (String path: paths) {
+                    uriPaths.add(path);
+                }
+            }
+            if (prop.equalsIgnoreCase(XQDataSource.ZORBA_PROPERTIES_LIB_PATHS)) {
+                String[] paths = properties.getProperty(prop).split("[;,]");
+                libPaths = new StringVector();
+                for (String path: paths) {
+                    libPaths.add(path);
+                }
+            }
+            if (prop.equalsIgnoreCase(XQDataSource.ZORBA_PROPERTIES_MODULE_PATHS)) {
+                String[] paths = properties.getProperty(prop).split("[;,]");
+                modulePaths = new StringVector();
+                for (String path: paths) {
+                    modulePaths.add(path);
+                }
+            }
+        }
+        lStaticContext = new org.zorbaxquery.api.xqj.XQStaticContext(zorba);
+        if (uriPaths!=null) {
+            ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setURIPaths(uriPaths);
+        }
+        if (libPaths!=null) {
+            ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setLIBPaths(libPaths);
+        }
+        if (modulePaths!=null) {
+            ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setMODPaths(modulePaths);
+        }
+        
+    }
+    
+    
+    @Override
+    public void close() throws XQException {
+        if (closed) return; // already closed
+        try {
+            for (XQExpression exp : cExpression ){
+                exp.close();  // Notify the dependents objects to close
+            }
+            for (XQPreparedExpression exp : cPreparedExpression ){
+                exp.close();  // Notify the dependents objects to close
+            }
+        } catch (XQException e) {
+            throw new XQException("Error closing connection: " + e.getLocalizedMessage());
+        }
+
+        if (lStaticContext != null ) {
+            ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).getZorbaStaticContext().destroy();
+        }
+        zorba.shutdown();
+        InMemoryStore.shutdown ( store );
+        closed = true;
+    }
+
+    @Override
+    public void setAutoCommit(boolean bln) throws XQException {
+        isClosedXQException();
+        autocommit = bln;
+    }
+
+    @Override
+    public boolean getAutoCommit() throws XQException {
+        isClosedXQException();
+        return autocommit;
+    }
+
+    @Override
+    public void commit() throws XQException {
+        isClosedXQException();
+        throw new UnsupportedOperationException("Zorba does not support transactions... yet...");
+        /*
+        if (!autocommit) {
+            try {
+                query.execute();
+            } catch (Exception e) {
+                throw new XQException("Error executing query");
+            }
+        } else {
+            throw new XQException("Autocommit was specified");
+        }
+         
+         */
+    }
+
+    @Override
+    public XQExpression createExpression() throws XQException {
+        isClosedXQException();
+        XQExpression expression;
+        if (lStaticContext == null) {
+            expression = new org.zorbaxquery.api.xqj.XQExpression(this);
+        } else {
+            expression = new org.zorbaxquery.api.xqj.XQExpression(this, lStaticContext);
+        }
+        cExpression.add(expression);
+        return expression;
+    }
+
+    @Override
+    public XQExpression createExpression(XQStaticContext value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        XQExpression expression = new org.zorbaxquery.api.xqj.XQExpression(this, value);
+        cExpression.add(expression);
+        return expression;
+    }
+
+    @Override
+    public XQMetaData getMetaData() throws XQException {
+        isClosedXQException();
+        return new org.zorbaxquery.api.xqj.XQMetaData(this);
+    }
+
+    @Override
+    public boolean isClosed() {
+        return closed;
+    }
+
+    @Override
+    public XQPreparedExpression prepareExpression(String value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        XQPreparedExpression expression;
+        try {
+            if (lStaticContext == null) {
+                expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, value);
+            } else {
+                expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, value, lStaticContext);
+            }
+            cPreparedExpression.add(expression);
+        } catch (Exception e) {
+          throw new XQException("Error preparing expression: "+e.getLocalizedMessage());
+        }
+        return expression;
+    }
+
+    @Override
+    public XQPreparedExpression prepareExpression(String string, XQStaticContext xqsc) throws XQException {
+        isClosedXQException();
+        isNullXQException(string);
+        isNullXQException(xqsc);
+        XQPreparedExpression expression = null;
+        try {
+            expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, string, xqsc);
+            cPreparedExpression.add(expression);
+        } catch (Exception e) {
+          throw new XQException("Error preparing expression");
+        }
+        return expression;
+    }
+
+    @Override
+    public XQPreparedExpression prepareExpression(Reader reader) throws XQException {
+        isClosedXQException();
+        isNullXQException(reader);
+        
+        StringBuffer string = new StringBuffer();
+        CharBuffer buffer = CharBuffer.allocate(1024);
+        Writer writer = new StringWriter();
+        
+        try {
+            while( reader.read(buffer) >= 0 ) {
+                buffer.flip();
+                writer.append(buffer);
+                buffer.clear();
+            }
+            reader.close();
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        
+        XQPreparedExpression expression;
+        if (lStaticContext == null) {
+            expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, writer.toString());
+        } else {
+            expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, writer.toString(), lStaticContext);
+        }
+        cPreparedExpression.add(expression);
+        return expression;
+    }
+
+    @Override
+    public XQPreparedExpression prepareExpression(Reader reader, XQStaticContext xqsc) throws XQException {
+        isClosedXQException();
+        isNullXQException(reader);
+        isNullXQException(xqsc);
+        StringBuffer string = new StringBuffer();
+        CharBuffer buffer = CharBuffer.allocate(1024);
+        Writer writer = new StringWriter();
+        try {
+            while( reader.read(buffer) >= 0 ) {
+                buffer.flip();
+                writer.append(buffer);
+                buffer.clear();
+            }
+            reader.close();
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        
+        XQPreparedExpression expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, writer.toString(), xqsc);
+        
+        cPreparedExpression.add(expression);
+        return expression;
+    }
+
+    @Override
+    public XQPreparedExpression prepareExpression(InputStream in) throws XQException {
+        isClosedXQException();
+        isNullXQException(in);
+        StringBuffer  out = new StringBuffer ();
+        try {
+            byte[] b = new byte[4096];
+            for (int n; (n = in.read(b)) != -1;) {
+                out.append(new String(b, 0, n));
+            }
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        
+        XQPreparedExpression expression;
+        if (lStaticContext == null) {
+            expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, out.toString());
+        } else {
+            expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, out.toString(), lStaticContext);
+        }
+        try {
+            cPreparedExpression.add(expression);
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+            
+        return expression;
+    }
+
+    @Override
+    public XQPreparedExpression prepareExpression(InputStream in, XQStaticContext xqsc) throws XQException {
+        isClosedXQException();
+        isNullXQException(in);
+        isNullXQException(xqsc);
+        StringBuffer  out = new StringBuffer ();
+        try {
+            byte[] b = new byte[4096];
+            for (int n; (n = in.read(b)) != -1;) {
+                out.append(new String(b, 0, n));
+            }
+        } catch (IOException ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        
+        XQPreparedExpression expression = null;
+        try {
+            expression = new org.zorbaxquery.api.xqj.XQPreparedExpression(this, out.toString(), xqsc);
+            cPreparedExpression.add(expression);
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        return expression;
+    }
+
+    @Override
+    public void rollback() throws XQException {
+        throw new UnsupportedOperationException("Zorba does not support transactions... yet...");
+    }
+
+    @Override
+    public XQStaticContext getStaticContext() throws XQException {
+        isClosedXQException();
+        lStaticContext = new org.zorbaxquery.api.xqj.XQStaticContext(zorba);
+        if (uriPaths!=null) {
+            ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setURIPaths(uriPaths);
+        }
+        if (libPaths!=null) {
+            ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setLIBPaths(libPaths);
+        }
+        if (modulePaths!=null) {
+            ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).setMODPaths(modulePaths);
+        }
+        return lStaticContext;
+    }
+
+    @Override
+    public void setStaticContext(XQStaticContext xqsc) throws XQException {
+        isClosedXQException();
+        isNullXQException(xqsc);
+        if ((lStaticContext!=null) && (lStaticContext!=xqsc)) {  // delete previous static context
+            ((org.zorbaxquery.api.xqj.XQStaticContext)lStaticContext).getZorbaStaticContext().delete();
+        }
+        lStaticContext = xqsc;
+    }
+
+    @Override
+    public XQItem createItemFromAtomicValue(String value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        isNullXQException(type);
+        if (type.getItemKind()!=XQItemType.XQITEMKIND_ATOMIC) {
+            throw new XQException("ItemType is not Atomic");
+        }
+        XQItem item = null;
+        try {
+            item = this.createItemFromString(value, type);
+        } catch (Exception e) {
+            throw new XQException("Error creating item of this type " + e.getLocalizedMessage());
+        }
+        return item;
+    }
+
+    @Override
+    public XQItem createItemFromString(String value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        if (type==null) {
+            type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_STRING);
+        }
+        ItemFactory itemFactory = zorba.getItemFactory();
+        XQItem item = null;
+        try {
+            switch (type.getBaseType()) {
+            case XQItemType.XQBASETYPE_BOOLEAN:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBoolean(Boolean.parseBoolean(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_ANYURI:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createAnyURI(value), type);
+                break;
+            case XQItemType.XQBASETYPE_BASE64BINARY:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBase64Binary(value, value.length()), type);
+                break;
+            case XQItemType.XQBASETYPE_BYTE:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createByte(value.charAt(0)), type);
+                break;
+            case XQItemType.XQBASETYPE_DATE:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDate(value), type);
+                break;
+            case XQItemType.XQBASETYPE_DATETIME:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDateTime(value), type);
+                break;
+            case XQItemType.XQBASETYPE_DAYTIMEDURATION:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value), type);
+                break;
+            case XQItemType.XQBASETYPE_DECIMAL:
+                BigDecimal dec = new BigDecimal(value);
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDecimal(value), type);
+                break;
+            case XQItemType.XQBASETYPE_DOUBLE:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDouble(Double.parseDouble(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_DURATION:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value), type);
+                break;
+            case XQItemType.XQBASETYPE_FLOAT:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createFloat(value), type);
+                break;
+            case XQItemType.XQBASETYPE_GDAY:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGDay(value), type);
+                break;
+            case XQItemType.XQBASETYPE_GMONTH:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGMonth(value), type);
+                break;
+            case XQItemType.XQBASETYPE_GMONTHDAY:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGMonthDay(value), type);
+                break;
+            case XQItemType.XQBASETYPE_GYEAR:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGYear(value), type);
+                break;
+            case XQItemType.XQBASETYPE_GYEARMONTH:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGYearMonth(value), type);
+                break;
+            case XQItemType.XQBASETYPE_HEXBINARY:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createHexBinary(value, value.length()), type);
+                break;
+            case XQItemType.XQBASETYPE_INT:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInt(Integer.parseInt(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_INTEGER:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInteger(Integer.parseInt(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_LONG:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createLong(Long.parseLong(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_NCNAME:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNCName(value), type);
+                break;
+            case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNegativeInteger(Long.parseLong(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonNegativeInteger(new BigInteger(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonPositiveInteger(Long.parseLong(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createPositiveInteger(new BigInteger(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_QNAME:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createQName(value), type);
+                break;
+            case XQItemType.XQBASETYPE_SHORT:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createShort(Short.parseShort(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_STRING:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createString(value), type);
+                break;
+            case XQItemType.XQBASETYPE_TIME:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createTime(value), type);
+                break;
+            case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedByte(Short.parseShort(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_UNSIGNED_INT:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedInt(Long.parseLong(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedLong(new BigInteger(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedShort(Integer.parseInt(value)), type);
+                break;
+            case XQItemType.XQBASETYPE_YEARMONTHDURATION:
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value), type);
+                break;
+            // TODO: revisit this posibilities
+            case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+            case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
+            case XQItemType.XQBASETYPE_ENTITY:
+            case XQItemType.XQBASETYPE_ENTITIES:
+            case XQItemType.XQBASETYPE_ANYTYPE:
+            case XQItemType.XQBASETYPE_LANGUAGE:
+            case XQItemType.XQBASETYPE_ID:
+            case XQItemType.XQBASETYPE_IDREF:
+            case XQItemType.XQBASETYPE_IDREFS:
+            case XQItemType.XQBASETYPE_NAME:
+            case XQItemType.XQBASETYPE_NMTOKEN:
+            case XQItemType.XQBASETYPE_NMTOKENS:
+            case XQItemType.XQBASETYPE_NORMALIZED_STRING:
+            case XQItemType.XQBASETYPE_NOTATION:
+            case XQItemType.XQBASETYPE_TOKEN:
+            case XQItemType.XQBASETYPE_UNTYPED:
+            case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
+                throw new UnsupportedOperationException("Not supported yet.");
+            default:
+                
+                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createString(value), type);
+                break;
+            }
+        } catch (Exception e) {
+            throw new XQException ("Error parsing value" + e.getLocalizedMessage());
+        }
+        return item;
+    }
+
+    @Override
+    public XQItem createItemFromDocument(String value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        if (type!=null) {
+            if ( ! ((type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_ELEMENT)||(type.getItemKind()== XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT)) ) {
+                throw new XQException("Invalid type");
+            }
+        } else {
+            type =  this.createElementType(null, XQItemType.XQBASETYPE_UNTYPED);
+        }
+        
+        XmlDataManager dm = null;
+        Item doc = null;
+        XQItem item = null;
+        try {
+            dm = zorba.getXmlDataManager();
+            doc = new Item();
+            org.zorbaxquery.api.Iterator iterator =  dm.parseXML(value);
+            iterator.open();
+            iterator.next(doc);
+            iterator.close();
+            iterator.delete();
+            item = new org.zorbaxquery.api.xqj.XQItem(doc);
+        } catch (Exception e) {
+            throw new XQException("Error creating Item" + e.getLocalizedMessage());
+        }
+        return item;
+    }
+
+    @Override
+    public XQItem createItemFromDocument(Reader value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        
+        StringBuffer string = new StringBuffer();
+        CharBuffer buffer = CharBuffer.allocate(1024);
+        Writer writer = new StringWriter();
+        
+        try {
+            while( value.read(buffer) >= 0 ) {
+                buffer.flip();
+                writer.append(buffer);
+                buffer.clear();
+            }
+            value.close();
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        
+        XQItem item = createItemFromDocument(writer.toString(), baseURI, type);
+        return item;
+    }
+
+    @Override
+    public XQItem createItemFromDocument(InputStream value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        // TODO: Rodolfo: optimize this, not good to have a string
+        StringBuffer out = new StringBuffer ();
+        try {
+            byte[] b = new byte[4096];
+            for (int n; (n = value.read(b)) != -1;) {
+                out.append(new String(b, 0, n));
+            }
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        XQItem item = createItemFromDocument(out.toString(), baseURI, type);
+        return item;
+    }
+
+    @Override
+    public XQItem createItemFromDocument(XMLStreamReader value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer t;
+        StAXSource source;
+        StAXResult result;
+        XMLOutputFactory xof = XMLOutputFactory.newInstance();
+        Writer writer = new StringWriter();
+        try {
+            XMLStreamWriter xmlStreamWriter =  xof.createXMLStreamWriter(writer);
+            t = tf.newTransformer();
+            source = new StAXSource(value);
+            result = new StAXResult(xmlStreamWriter);
+            t.transform(source, result);        
+        } catch (Exception ex) {
+            throw new XQException("Error transforming xml expression" + ex.getLocalizedMessage());
+        }
+        XQItem item = createItemFromDocument(writer.toString(), "", type);
+        return item;
+    }
+    
+    private String nodeToString(Node node) {
+     StringWriter sw = new StringWriter();
+     try {
+       Transformer t = TransformerFactory.newInstance().newTransformer();
+       t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+       t.transform(new DOMSource(node), new StreamResult(sw));
+     } catch (TransformerException te) {
+       System.out.println("nodeToString Transformer Exception" + te.getLocalizedMessage());
+     }
+     return sw.toString();
+    }
+    
+    @Override
+    public XQItem createItemFromDocument(Source value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        XQItem item = null;
+        if (value instanceof StreamSource) {
+            item = createItemFromDocument(((StreamSource)value).getReader(), "", type);
+        } else if (value instanceof SAXSource) {
+            item = createItemFromDocument(((SAXSource)value).getInputSource().getByteStream(), "", type);
+        } else if (value instanceof DOMSource) {
+            item = createItemFromDocument( nodeToString(((DOMSource)value).getNode()), "", type);
+        } else {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+        return item;
+        
+    }
+
+    @Override
+    public XQItem createItemFromObject(Object value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        if (value instanceof XQItem) {
+            return (XQItem)value;
+        }
+        
+        ItemFactory itemFactory = zorba.getItemFactory();
+        XQItem item = null;
+        if (type==null) {
+            
+            if (value instanceof Boolean) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BOOLEAN);
+            } else if (value instanceof Byte) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BYTE);
+            } else if (value instanceof Float) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_FLOAT);
+            } else if (value instanceof Double) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DOUBLE);
+            } else if (value instanceof Integer) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INT);
+            } else if (value instanceof Long) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_LONG);
+            } else if (value instanceof Short) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_SHORT);
+            } else if (value instanceof String) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_STRING);
+            } else if (value instanceof BigDecimal) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DECIMAL);
+            } else if (value instanceof BigInteger) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INTEGER);
+            } else if (value instanceof Duration) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DURATION);
+            } else if (value instanceof XMLGregorianCalendar) {
+                QName schType = ((XMLGregorianCalendar)value).getXMLSchemaType();
+                if (schType.equals(DatatypeConstants.GDAY)) {
+                    type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GDAY);
+                } else if (schType.equals(DatatypeConstants.GMONTHDAY)) {
+                    type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GMONTHDAY);
+                } else if (schType.equals(DatatypeConstants.GMONTH)) {
+                    type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GMONTH);
+                } else if (schType.equals(DatatypeConstants.GYEAR)) {
+                    type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GYEAR);
+                } else if (schType.equals(DatatypeConstants.GYEARMONTH)) {
+                    type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_GYEARMONTH);
+                } else if (schType.equals(DatatypeConstants.DATETIME)) {
+                    type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DATETIME);
+                } else if (schType.equals(DatatypeConstants.DATE)) {
+                    type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DATE);
+                } else if (schType.equals(DatatypeConstants.TIME)) {
+                    type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_TIME);
+                }
+            } else if (value instanceof QName) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_QNAME);
+            } else if (value instanceof Document) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT);
+            } else if (value instanceof DocumentFragment) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT);
+            } else if (value instanceof Element){
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ELEMENT);
+            } else if (value instanceof Attr) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATTRIBUTE);
+            } else if (value instanceof Comment) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_COMMENT);
+            } else if (value instanceof ProcessingInstruction) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_PI);
+            } else if (value instanceof Text) {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_TEXT);
+            } else {
+                type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC);
+            }
+        }
+        try {
+            switch (type.getItemKind()) {
+                case XQItemType.XQITEMKIND_ATOMIC:
+                    switch (type.getBaseType()) {
+                    case XQItemType.XQBASETYPE_BOOLEAN:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBoolean((Boolean)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_ANYURI:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createAnyURI(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_BASE64BINARY:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBase64Binary(value.toString(), (value.toString()).length()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_BYTE:
+                        if (value instanceof Byte) {
+                            byte tmpByte = ((Byte)value).byteValue();
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createByte((char)tmpByte), type);
+                        } else {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createByte((value.toString()).charAt(0)), type);
+                        }
+                        break;
+                    case XQItemType.XQBASETYPE_DATE:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDate(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_DATETIME:
+                        if (value.toString().contains(":")) {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDateTime(value.toString()), type);
+                        } else {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDate(value.toString()), type);
+                        }
+                        break;
+                    case XQItemType.XQBASETYPE_DAYTIMEDURATION:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_DECIMAL:
+                        if (value instanceof BigDecimal) {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDecimal(((BigDecimal)value).toPlainString()), type);
+                        } else {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDecimal(value.toString()), type);
+                        }
+                        break;
+                    case XQItemType.XQBASETYPE_DOUBLE:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDouble(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_DURATION:
+                        if (value instanceof Duration) {
+                            Duration duration = (Duration)value;
+                            Boolean daytime = duration.isSet(DatatypeConstants.DAYS) || duration.isSet(DatatypeConstants.HOURS) || 
+                                              duration.isSet(DatatypeConstants.MINUTES) || duration.isSet(DatatypeConstants.SECONDS);
+                            Boolean yearmonth = duration.isSet(DatatypeConstants.YEARS) || duration.isSet(DatatypeConstants.MONTHS);
+                            if (daytime && yearmonth){
+                                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value.toString()), type);
+                            } else if (yearmonth) {
+                                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createYearMonthDuration(value.toString()), type);
+                            } else if (daytime) {
+                                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDayTimeDuration(value.toString()), type);
+                            }
+                        } else {
+                            boolean yearMonth = value.toString().contains("Y") || value.toString().contains("M");
+                            boolean dayTime = value.toString().contains("D") || value.toString().contains("T");
+                            if (yearMonth && dayTime) {
+                                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value.toString()), type);
+                            } else if (yearMonth) {
+                                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createYearMonthDuration(value.toString()), type);
+                            } else if (dayTime) {
+                                item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDayTimeDuration(value.toString()), type);
+                            }
+                        }
+                        break;
+                    case XQItemType.XQBASETYPE_FLOAT:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createFloat((Float)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_GDAY:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGDay(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_GMONTH:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGMonth(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_GMONTHDAY:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGMonthDay(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_GYEAR:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGYear(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_GYEARMONTH:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createGYearMonth(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_HEXBINARY:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createHexBinary(value.toString(), (value.toString()).length()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_INT:
+                    case XQItemType.XQBASETYPE_INTEGER:
+                        if (value instanceof BigInteger) {
+                            BigInteger val = (BigInteger)value;
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInteger(val.longValue()), type);
+                        } else if (value instanceof Integer) {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInt((Integer)value), type);
+                        } else if (value instanceof String) {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInteger(value.toString()), type);
+                        } else {
+                            throw new XQException ("Error parsing integer: " + value.toString());
+                        }
+                        break;
+                    case XQItemType.XQBASETYPE_LONG:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createLong((Long)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_NCNAME:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNCName(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNegativeInteger((Long)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonNegativeInteger(new BigInteger(value.toString())), type);
+                        break;
+                    case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonPositiveInteger((Long)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createPositiveInteger(new BigInteger(value.toString())), type);
+                        break;
+                    case XQItemType.XQBASETYPE_QNAME:
+                        if (value instanceof QName) {
+                            QName qname =  (QName) value;
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createQName(qname.getNamespaceURI(), qname.getPrefix(), qname.getLocalPart()), type);
+                        } else if (value.toString().contains("{")) {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createQName(value.toString()), type);
+                        } else {
+                            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createQName("", value.toString()), type);
+                        }
+                        break;
+                    case XQItemType.XQBASETYPE_SHORT:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createShort((Short)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_STRING:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createString(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_TIME:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createTime(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_TOKEN:
+                        break;
+                    case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedByte((Short)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_UNSIGNED_INT:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedInt((Long)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedLong(new BigInteger(value.toString())), type);
+                        break;
+                    case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedShort((Integer)value), type);
+                        break;
+                    case XQItemType.XQBASETYPE_YEARMONTHDURATION:
+                        item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDuration(value.toString()), type);
+                        break;
+                    case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+                    case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
+                    case XQItemType.XQBASETYPE_ANYTYPE:
+                    case XQItemType.XQBASETYPE_ENTITIES:
+                    case XQItemType.XQBASETYPE_ENTITY:
+                    case XQItemType.XQBASETYPE_ID:
+                    case XQItemType.XQBASETYPE_IDREF:
+                    case XQItemType.XQBASETYPE_IDREFS:
+                    case XQItemType.XQBASETYPE_LANGUAGE:
+                    case XQItemType.XQBASETYPE_NAME:
+                    case XQItemType.XQBASETYPE_NMTOKEN:
+                    case XQItemType.XQBASETYPE_NMTOKENS:
+                    case XQItemType.XQBASETYPE_NORMALIZED_STRING:
+                    case XQItemType.XQBASETYPE_NOTATION:
+                    case XQItemType.XQBASETYPE_UNTYPED:
+                    case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
+                        throw new XQException ("Base type not supported yet.");
+                    default:
+                        throw new XQException ("Unable to determine XQBASETYPE.");
+                    }
+                    break;
+                case XQItemType.XQITEMKIND_ATTRIBUTE:
+                    if (value instanceof Attr){
+                        Attr attribute = (Attr) value;
+                        Item iEmpty = new Item();
+                        Item nodeName = itemFactory.createQName(attribute.getNamespaceURI()==null?"":attribute.getNamespaceURI(), 
+                                                                attribute.getPrefix()==null?"":attribute.getPrefix(), 
+                                                                attribute.getName()==null?"":attribute.getName());
+                        Item nodeValue = null;
+                        if (!attribute.getValue().isEmpty()) {
+                            nodeValue = itemFactory.createQName(attribute.getNamespaceURI()==null?"":attribute.getNamespaceURI(), 
+                                                                attribute.getPrefix()==null?"":attribute.getPrefix(), 
+                                                                attribute.getValue()==null?"":attribute.getValue());
+                        } else {
+                            nodeValue = new Item();
+                        }
+                        //TODO: Rodolfo: use centralized constants instead of strings
+                        Item iUntyped = itemFactory.createQName("http://www.w3.org/2001/XMLSchema";, "xs", "untyped");
+                        Item attributeNode = itemFactory.createAttributeNode(iEmpty, nodeName, iUntyped, nodeValue);
+                        item = new org.zorbaxquery.api.xqj.XQItem(attributeNode, type);
+                    }
+                    break;
+                case XQItemType.XQITEMKIND_COMMENT:
+                    if (value instanceof Comment){
+                        Comment comment = (Comment) value;
+                        Item iEmpty = new Item();
+                        Item elementNode = itemFactory.createCommentNode(iEmpty, comment.getTextContent());
+                        item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
+                    } else {
+                        Item iEmpty = new Item();
+                        Item elementNode = itemFactory.createCommentNode(iEmpty, value.toString());
+                        item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
+                    }
+                    break;
+                case XQItemType.XQITEMKIND_DOCUMENT:
+                    if ((value instanceof Document) || (value instanceof DocumentFragment)){
+                        DOMSource source = null;
+                        if (value instanceof Document) {
+                            source = new DOMSource((Document)value);
+                        } else {
+                            source = new DOMSource((DocumentFragment)value);
+                        }
+
+                        Transformer transformer = TransformerFactory.newInstance().newTransformer();
+                        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+                        StreamResult result = new StreamResult(new StringWriter());
+                        
+                        transformer.transform(source, result);
+                        String xmlString = result.getWriter().toString();
+                        Item tmpItem = new Item();
+                        if (xmlString.length()>0) {
+                            XmlDataManager dataManager = zorba.getXmlDataManager();
+                            org.zorbaxquery.api.Iterator iter = dataManager.parseXML(xmlString);
+                            iter.open();
+                            iter.next(tmpItem);
+                            iter.close();
+                            iter.delete();
+                        } else {
+                            tmpItem = itemFactory.createDocumentNode("", "");
+                        }
+                        
+                        item = new org.zorbaxquery.api.xqj.XQItem(tmpItem, type);
+                    }
+                      
+                    break;
+                case XQItemType.XQITEMKIND_ELEMENT:
+                    if (value instanceof Element){
+                        Element element = (Element) value;
+                        Item iEmpty = new Item();
+                        Item nodeName = itemFactory.createQName(element.getNamespaceURI()==null?"":element.getNamespaceURI(), 
+                                                                element.getPrefix()==null?"":element.getPrefix(), 
+                                                                element.getNodeName()==null?"":element.getNodeName());
+                        Item iUntyped = itemFactory.createQName("http://www.w3.org/2001/XMLSchema";, "xs", "untyped");
+                        Item elementNode = itemFactory.createElementNode(iEmpty, nodeName, iUntyped, false, false);
+                        item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
+                    }
+                    break;
+                case XQItemType.XQITEMKIND_PI:
+                    if (value instanceof ProcessingInstruction){
+                        ProcessingInstruction pi = (ProcessingInstruction) value;
+                        Item iEmpty = new Item();
+                        Item elementNode = itemFactory.createPiNode(iEmpty, 
+                                pi.getTarget(), 
+                                pi.getTextContent(), 
+                                pi.getBaseURI()==null?"":pi.getBaseURI());
+                        item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
+                    }
+                    break;
+                case XQItemType.XQITEMKIND_TEXT:
+                    if (value instanceof Text){
+                        Text text = (Text) value;
+                        Item iEmpty = new Item();
+                        Item elementNode = itemFactory.createTextNode(iEmpty, text.getWholeText());
+                        item = new org.zorbaxquery.api.xqj.XQItem(elementNode, type);
+                    }
+                    break;
+                case XQItemType.XQITEMKIND_DOCUMENT_ELEMENT:
+                case XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT:
+                case XQItemType.XQITEMKIND_ITEM:
+                case XQItemType.XQITEMKIND_NODE:
+                case XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE:
+                case XQItemType.XQITEMKIND_SCHEMA_ELEMENT:
+                    throw new XQException ("This item kind is currently unsupported.");
+                default:
+                    throw new XQException ("Unable to determine XQITEMKIND.");
+            }
+        } catch (Exception e) {
+            throw new XQException ("Error parsing value" + e.getLocalizedMessage());
+        }
+        return item;
+    }
+
+    @Override
+    public XQItem createItemFromBoolean(boolean bln, XQItemType type) throws XQException {
+        isClosedXQException();
+        if (type == null) {
+            type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BOOLEAN);
+        }
+        if (type.getBaseType() != XQItemType.XQBASETYPE_BOOLEAN) {
+            throw new XQException("Type is not boolean, use proper method");
+        }
+        
+        XQItem item = null;
+        try {
+            ItemFactory itemFactory = zorba.getItemFactory();
+            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createBoolean(bln));
+        } catch (Exception e) {
+            throw new XQException("Error creating new item");
+        }
+        return item;
+    }
+
+    // This method works for Decimal and all subtypes,
+    // verifies that the type is correct and create the Item
+    private XQItem createDecimal(BigDecimal value, XQItemType type) throws XQException {
+        XQItem item = null;
+        try {
+            ItemFactory itemFactory = zorba.getItemFactory();
+            switch (type.getBaseType()) {
+                case XQItemType.XQBASETYPE_BYTE:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createByte((char)value.byteValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_INTEGER:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInteger(value.longValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_DECIMAL:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDecimalFromLong(value.longValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_INT:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createInt(value.intValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_LONG:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createLong(value.longValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNegativeInteger(value.longValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonNegativeInteger(value.toBigInteger()), type);
+                    break;
+                case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createNonPositiveInteger(value.longValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createPositiveInteger(value.toBigInteger()), type);
+                    break;
+                case XQItemType.XQBASETYPE_SHORT:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createShort(value.shortValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedByte(value.shortValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_UNSIGNED_INT:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedInt(value.longValue()), type);
+                    break;
+                case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createUnsignedLong(value.toBigInteger()), type);
+                    break;
+                case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+                    item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createShort(value.shortValue()), type);
+                    break;
+                default:
+                    throw new XQException("Type is not xs:decimal or a derivate.");
+            }
+        } catch (Exception e) {
+            throw new XQException("Error creating Item: " + e.getLocalizedMessage());
+        }
+        return item;
+    }
+    
+    @Override
+    public XQItem createItemFromByte(byte b, XQItemType type) throws XQException {
+        isClosedXQException();
+        if (type == null) {
+            type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_BYTE);
+        }
+        return createDecimal(new BigDecimal(b), type);
+    }
+
+    @Override
+    public XQItem createItemFromDouble(double value, XQItemType type) throws XQException {
+        isClosedXQException();
+        if (type == null) {
+            type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_DOUBLE);
+        }
+        if (type.getBaseType() != XQItemType.XQBASETYPE_DOUBLE) {
+            throw new XQException("Type is not double, use proper method");
+        }
+        XQItem item = null;
+        try {
+            ItemFactory itemFactory = zorba.getItemFactory();
+            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createDouble(value), type);
+        } catch (Exception e) {
+            throw new XQException("Error Creating Item From Double" + e.getLocalizedMessage());
+        }
+        return item;
+    }
+
+    @Override
+    public XQItem createItemFromFloat(float value, XQItemType type) throws XQException {
+        isClosedXQException();
+        if (type == null) {
+            type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_FLOAT);
+        }
+        if (type.getBaseType() != XQItemType.XQBASETYPE_FLOAT) {
+            throw new XQException("Type is not float, use proper method");
+        }
+        XQItem item = null;
+        try {
+            ItemFactory itemFactory = zorba.getItemFactory();
+            item = new org.zorbaxquery.api.xqj.XQItem(itemFactory.createFloat(value), type);
+        } catch (Exception e) {
+            throw new XQException("Error Creating Item From Float" + e.getLocalizedMessage());
+        }
+        return item;
+    }
+
+    @Override
+    public XQItem createItemFromInt(int value, XQItemType type) throws XQException {
+        isClosedXQException();
+        if (type == null) {
+            type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_INT);
+        }
+        switch (type.getBaseType()) {
+            case XQItemType.XQBASETYPE_BYTE:
+            case XQItemType.XQBASETYPE_SHORT:
+                throw new XQException("Can't downgrade the Base Type from an Int number");
+            default:
+                break;
+        }
+        return createDecimal(new BigDecimal(value), type);
+    }
+
+    @Override
+    public XQItem createItemFromLong(long value, XQItemType type) throws XQException {
+        isClosedXQException();
+        if (type == null) {
+            type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_LONG);
+        }
+        switch (type.getBaseType()) {
+            case XQItemType.XQBASETYPE_BYTE:
+            case XQItemType.XQBASETYPE_SHORT:
+            case XQItemType.XQBASETYPE_INT:
+                throw new XQException("Can't downgrade the Base Type from an Long number");
+            default:
+                break;
+        }
+        return createDecimal(new BigDecimal(value), type);
+    }
+
+    @Override
+    public XQItem createItemFromNode(Node value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        
+        XQItem result = null;
+        try {
+            result = createItemFromString(nodeToString(value), type);
+        } catch( Exception e ) {
+            throw new XQException("Error Creating Item From Node" + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public XQItem createItemFromShort(short value, XQItemType type) throws XQException {
+        isClosedXQException();
+        if (type == null) {
+            type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, XQItemType.XQBASETYPE_SHORT);
+        }
+        if (type.getBaseType()==XQItemType.XQBASETYPE_BYTE) {
+            throw new XQException("Can't create a Byte from a Short number");
+        }
+        return createDecimal(new BigDecimal(value), type);
+    }
+
+    @Override
+    public XQItem createItem(XQItem value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        if (value.isClosed()) {
+            throw new XQException("Item is closed.");
+        }
+        XQItem result = new org.zorbaxquery.api.xqj.XQItem(value);
+        return result;
+    }
+
+    @Override
+    public XQSequence createSequence(XQSequence value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        if (value.isClosed()) {
+            throw new XQException("Sequence is closed.");
+        }
+        XQSequence result = null;
+        try {
+            result = new org.zorbaxquery.api.xqj.XQSequence(value);
+        } catch (Exception ex) {
+            throw new XQException("Error creating sequence: " + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public XQSequence createSequence(Iterator value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        XQSequence result = null;
+        try {
+            result = new org.zorbaxquery.api.xqj.XQSequence(value);
+        } catch (Exception ex) {
+            throw new XQException("Error creating sequence: " + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public XQItemType createAtomicType(int basetype) throws XQException {
+        isClosedXQException();
+        if ((basetype==XQItemType.XQBASETYPE_UNTYPED) || 
+            (basetype==XQItemType.XQBASETYPE_ANYTYPE) || 
+            (basetype==XQItemType.XQBASETYPE_IDREFS) || 
+            (basetype==XQItemType.XQBASETYPE_NMTOKENS) || 
+            (basetype==XQItemType.XQBASETYPE_ENTITIES) || 
+            (basetype==XQItemType.XQBASETYPE_ANYSIMPLETYPE)) {
+            throw new XQException("Invalid base type.");
+        }
+        XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, basetype);
+        return type;
+    }
+
+    @Override
+    public XQItemType createAtomicType(int basetype, QName qname, URI uri) throws XQException {
+        if (closed) {
+            throw new XQException("Object closed");
+        }
+        if ((basetype==XQItemType.XQBASETYPE_UNTYPED) || 
+            (basetype==XQItemType.XQBASETYPE_ANYTYPE) || 
+            (basetype==XQItemType.XQBASETYPE_IDREFS) || 
+            (basetype==XQItemType.XQBASETYPE_NMTOKENS) || 
+            (basetype==XQItemType.XQBASETYPE_ENTITIES) || 
+            (basetype==XQItemType.XQBASETYPE_ANYSIMPLETYPE)) {
+            throw new XQException("Invalid base type.");
+        }
+        XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATOMIC, qname, basetype, uri);
+        return type;
+    }
+
+    @Override
+    public XQItemType createAttributeType(QName nodename, int basetype) throws XQException {
+        isClosedXQException();
+        if ((basetype==XQItemType.XQBASETYPE_UNTYPED)||(basetype==XQItemType.XQBASETYPE_ANYTYPE)) {
+            throw new XQException("Base Type can't be XQItemType.XQBASETYPE_UNTYPED or XQItemType.XQBASETYPE_ANYTYPE");
+        }
+        return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATTRIBUTE, nodename, basetype);
+    }
+
+    @Override
+    public XQItemType createAttributeType(QName nodename, int basetype, QName typename, URI schemaURI) throws XQException {
+        isClosedXQException();
+        if ((basetype==XQItemType.XQBASETYPE_UNTYPED)||(basetype==XQItemType.XQBASETYPE_ANYTYPE)) {
+            throw new XQException("Base Type can't be XQItemType.XQBASETYPE_UNTYPED or XQItemType.XQBASETYPE_ANYTYPE");
+        }
+        if ((schemaURI!=null) && (typename==null)) {
+            throw new XQException("If Schema URI is specified, Base Type must be also specified");
+        }
+        return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ATTRIBUTE, nodename, basetype, typename, schemaURI, true);
+    }
+
+    @Override
+    public XQItemType createSchemaAttributeType(QName nodename, int basetype, URI uri) throws XQException {
+        isClosedXQException();
+        return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE, nodename, basetype, uri);
+    }
+
+    @Override
+    public XQItemType createCommentType() throws XQException {
+        isClosedXQException();
+        return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_COMMENT);
+    }
+
+    @Override
+    public XQItemType createDocumentElementType(XQItemType elementType) throws XQException {
+        isClosedXQException();
+        isNullXQException(elementType);
+        if (elementType.getItemKind()!=XQItemType.XQITEMKIND_ELEMENT) {
+            throw new XQException("Item Kind must be XQItemType.XQITEMKIND_ELEMENT");
+        }
+        return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT_ELEMENT, elementType.getNodeName(), elementType.getBaseType(), elementType.getSchemaURI());
+    }
+
+    @Override
+    public XQItemType createDocumentSchemaElementType(XQItemType elementType) throws XQException {
+        isClosedXQException();
+        if (elementType.getItemKind()!=XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) {
+            throw new XQException("Item Kind must be XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT");
+        }
+        return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT_ELEMENT, elementType.getNodeName(), elementType.getBaseType(), elementType.getSchemaURI());
+    }
+
+    @Override
+    public XQItemType createDocumentType() throws XQException {
+        isClosedXQException();
+        return new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_DOCUMENT);
+    }
+
+    @Override
+    public XQItemType createElementType(QName nodename, int baseType) throws XQException {
+        isClosedXQException();
+        XQItemType item = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ELEMENT, nodename, baseType);
+        return item;
+    }
+
+    @Override
+    public XQItemType createElementType(QName nodename, int baseType, QName typename, URI schemaURI, boolean allowNill) throws XQException {
+        isClosedXQException();
+        XQItemType item = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ELEMENT, nodename, baseType, typename, schemaURI, allowNill);
+        return item;
+    }
+
+    @Override
+    public XQItemType createSchemaElementType(QName nodename, int baseType, URI schemaURI) throws XQException {
+        isClosedXQException();
+        XQItemType item = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_SCHEMA_ELEMENT, nodename, baseType, schemaURI);
+        return item;
+    }
+
+    @Override
+    public XQItemType createItemType() throws XQException {
+        isClosedXQException();
+        XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ITEM);
+        return type;
+    }
+
+    @Override
+    public XQItemType createNodeType() throws XQException {
+        isClosedXQException();
+        XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_NODE);
+        return type;
+    }
+
+    @Override
+    public XQItemType createProcessingInstructionType(String piTarget) throws XQException {
+        isClosedXQException();
+        XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_PI, piTarget);
+        return type;
+    }
+
+    @Override
+    public XQSequenceType createSequenceType(XQItemType item, int occurence) throws XQException {
+        isClosedXQException();
+        if ( ((item==null) && (occurence != XQSequenceType.OCC_EMPTY)) || ((item!=null) && (occurence == XQSequenceType.OCC_EMPTY))) {
+            throw new XQException("Item is null");
+        }
+        if (!((occurence ==  XQSequenceType.OCC_ZERO_OR_ONE) ||
+            (occurence == XQSequenceType.OCC_EXACTLY_ONE) ||
+            (occurence == XQSequenceType.OCC_ZERO_OR_MORE) ||
+            (occurence == XQSequenceType.OCC_ONE_OR_MORE) ||
+            (occurence == XQSequenceType.OCC_EMPTY))) {
+            throw new XQException("Occurence must be from: OCC_ZERO_OR_ONE, OCC_EXACTLY_ONE, OCC_ZERO_OR_MORE, OCC_ONE_OR_MORE, OCC_EMPTY ");
+        }
+        
+        XQSequenceType result = new org.zorbaxquery.api.xqj.XQSequenceType(item, occurence);
+        return result;
+    }
+
+    @Override
+    public XQItemType createTextType() throws XQException {
+        isClosedXQException();
+        XQItemType type = new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_TEXT);
+        return type;
+    }
+    
+    private void isClosedXQException() throws XQException {
+        if (closed) {
+            throw new XQException("This connection is closed");
+        }
+    }
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+   
+}

=== added file 'swig/xqj/XQDataSource.java'
--- swig/xqj/XQDataSource.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQDataSource.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.util.Enumeration;
+import java.util.Properties;
+import javax.xml.xquery.*;
+
+public class XQDataSource implements javax.xml.xquery.XQDataSource {
+    
+   static {
+      System.loadLibrary ( "zorba_api" );
+   }
+    public static final String ZORBA_PROPERTIES_URI_PATHS = "URI-PATHS";
+    public static final String ZORBA_PROPERTIES_LIB_PATHS = "LIB-PATHS";
+    public static final String ZORBA_PROPERTIES_MODULE_PATHS = "MODULE-PATHS";
+    
+    private int loginTimeout;
+    protected PrintWriter logWriter;
+    private Properties properties = new Properties();
+    private String[] propertiesAllowed = {ZORBA_PROPERTIES_URI_PATHS, ZORBA_PROPERTIES_LIB_PATHS, ZORBA_PROPERTIES_MODULE_PATHS};
+    public XQDataSource() {
+    }
+
+    
+    @Override
+    public XQConnection getConnection() throws XQException {
+        XQConnection conn;
+        try {
+            if (!properties.isEmpty()) {
+                conn = new XQConnection(properties);
+            } else {
+                conn = new XQConnection();
+            }
+        } catch ( Exception e ) {
+            throw new XQException("Error creating new Zorba Connection Instance");
+        }
+        return conn;
+    }
+
+    @Override
+    public XQConnection getConnection(Connection cnctn) throws XQException {
+        /* Attempts to create a connection to an XML datasource using an 
+         * existing JDBC connection. An XQJ implementation is not required 
+         * to support this method. If it is not supported, then an 
+         * exception (XQException) is thrown. The XQJ and JDBC connections 
+         * will operate under the same transaction context.
+         * */
+        throw new XQException("Connection to an XML datasource using an existing JDBC connection is not supported.");
+    }
+
+    @Override
+    public XQConnection getConnection(String username, String passwd) throws XQException {
+        XQConnection conn;
+        try {
+          if (!properties.isEmpty()) {
+            conn = new XQConnection(properties);
+          } else {
+            conn = new XQConnection();
+          }
+        } catch ( Exception e ) {
+            throw new XQException("Error creating new Zorba Connection Instance");
+        }
+        return conn;
+    }
+
+    @Override
+    public int getLoginTimeout() throws XQException {
+        return loginTimeout;
+    }
+
+    @Override
+    public PrintWriter getLogWriter() throws XQException {
+        return logWriter;
+    }
+
+    @Override
+    public String[] getSupportedPropertyNames() {
+        return propertiesAllowed;
+    }
+
+    @Override
+    public void setProperty(String name, String value) throws XQException {
+        if (name==null) {
+            throw new XQException("Property name is null.");
+        }
+        boolean allowed = false;
+        for(int i=0; i<propertiesAllowed.length; i++) {
+            if (propertiesAllowed[i].equals(name)) {
+                allowed = true;
+            }
+        }
+        if (allowed) {
+            properties.setProperty(name, value);
+        } else {
+            throw new XQException("Property not allowed.");
+        }
+    }
+
+    @Override
+    public String getProperty(String name) throws XQException {
+        if (name==null) {
+            throw new XQException("Property name is null.");
+        }
+        boolean allowed = false;
+        for(int i=0; i<propertiesAllowed.length; i++) {
+            if (propertiesAllowed[i].equals(name)) {
+                allowed = true;
+            }
+        }
+        if (!allowed) {
+            throw new XQException("Property name not supported.");
+        }
+        return properties.getProperty(name);
+    }
+
+    @Override
+    public void setProperties(Properties prprts) throws XQException {
+        if (prprts==null) {
+            throw new XQException("Properties are null.");
+        }
+        boolean allowed = false;
+        String tmpstr = null;
+        Enumeration em = prprts.keys();
+        while (em.hasMoreElements()) {
+            allowed = false;
+            tmpstr = (String)em.nextElement();
+            for (int i=0; i<propertiesAllowed.length; i++) {
+                if (propertiesAllowed[i].equals(tmpstr)) {
+                    allowed = true;
+                }
+            }
+            if (!allowed) {
+                throw new XQException("Property [" + tmpstr + "] not allowed");
+            }
+        }
+        
+        em = prprts.keys();
+        while (em.hasMoreElements()) {
+            tmpstr = (String)em.nextElement();
+            properties.setProperty(tmpstr, prprts.getProperty(tmpstr));
+        }
+        
+    }
+
+    @Override
+    public void setLoginTimeout(int i) throws XQException {
+        loginTimeout = i;
+    }
+
+    @Override
+    public void setLogWriter(PrintWriter writer) throws XQException {
+        logWriter = writer;
+    }
+    
+}

=== added file 'swig/xqj/XQExpression.java'
--- swig/xqj/XQExpression.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQExpression.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,461 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.nio.CharBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQResultSequence;
+import javax.xml.xquery.XQSequence;
+import javax.xml.xquery.XQStaticContext;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQConstants;
+import org.w3c.dom.Node;
+import org.zorbaxquery.api.DynamicContext;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.XQuery;
+
+public class XQExpression implements javax.xml.xquery.XQExpression {
+
+    //private XQuery query;
+    private XQConnection connection;
+    private boolean closed = false;
+    private boolean cancel = false;
+    private Collection<XQResultSequence> resultSequences = new ArrayList<XQResultSequence>();
+    private XQStaticContext staticContext;
+    private Map<String, Item> itemsToBind = new HashMap<String, Item>();
+    private TimeZone implicitTimeZone;
+            
+    public XQExpression (XQConnection conn) throws XQException {
+        if (conn.isClosed()) {
+            throw new XQException ("Connection is closed");
+        }
+        connection = conn;
+    }
+
+    public XQExpression (XQConnection conn, XQStaticContext sc) throws XQException {
+        if (conn.isClosed()) {
+            throw new XQException ("Connection is closed");
+        }
+        connection = conn;
+        staticContext = sc;
+    }
+    
+    @Override
+    public void cancel() throws XQException {
+        isClosedXQException();
+        cancel = true;
+    }
+
+    @Override
+    public boolean isClosed() {
+        return closed;
+    }
+
+    @Override
+    public void close() throws XQException {
+        closed=true;
+//        if (query!=null) {
+//            query.destroy();
+//        }
+        for (XQResultSequence rs: resultSequences) {
+            rs.close();
+        }
+    }
+
+    @Override
+    public void executeCommand(String string) throws XQException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void executeCommand(Reader reader) throws XQException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public XQResultSequence executeQuery(String value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        org.zorbaxquery.api.xqj.XQConnection lConnection = (org.zorbaxquery.api.xqj.XQConnection)connection;
+        XQuery query =  lConnection.getZorbaInstance().createQuery();
+        XQResultSequence result = null;
+        try {
+            int scrollable = XQConstants.SCROLLTYPE_FORWARD_ONLY;
+            if (staticContext!=null) {
+              query.compile(value, ((org.zorbaxquery.api.xqj.XQStaticContext)staticContext).getZorbaStaticContext());
+              scrollable = staticContext.getScrollability();
+            } else {
+              query.compile(value);
+            }
+            DynamicContext dynamicContext = query.getDynamicContext();
+            if (implicitTimeZone!=null) {
+                dynamicContext.setImplicitTimezone((implicitTimeZone.getRawOffset()/60000));
+                implicitTimeZone=null;
+            }
+            for (String key: itemsToBind.keySet()){
+                dynamicContext.setVariable(key, itemsToBind.get(key) );
+                //itemsToBind.remove(key);
+            }
+            if (scrollable == XQConstants.SCROLLTYPE_FORWARD_ONLY) {
+                result = new org.zorbaxquery.api.xqj.XQResultSequence(connection, query, false);
+            } else {
+                result = new org.zorbaxquery.api.xqj.XQResultSequenceScrollable(connection, query, false);
+            }
+            resultSequences.add(result);
+        } catch (Exception e) {
+            throw new XQException ("Error executing query: " + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public XQResultSequence executeQuery(Reader value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        
+        StringBuffer string = new StringBuffer();
+        CharBuffer buffer = CharBuffer.allocate(1024);
+        Writer writer = new StringWriter();
+        
+        try {
+            while( value.read(buffer) >= 0 ) {
+                buffer.flip();
+                writer.append(buffer);
+                buffer.clear();
+            }
+            value.close();
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        
+        return executeQuery(writer.toString());
+    }
+
+    @Override
+    public XQResultSequence executeQuery(InputStream value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        StringBuffer  out = new StringBuffer ();
+        try {
+            byte[] b = new byte[4096];
+            for (int n; (n = value.read(b)) != -1;) {
+                out.append(new String(b, 0, n));
+            }
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        return executeQuery(out.toString());
+    }
+
+    @Override
+    public XQStaticContext getStaticContext() throws XQException {
+        isClosedXQException();
+        if (staticContext==null) {
+            return connection.getStaticContext();
+        } else {
+            return staticContext;
+        }
+    }
+
+    @Override
+    public TimeZone getImplicitTimeZone() throws XQException {
+        isClosedXQException();
+        if (implicitTimeZone!=null) {
+            return implicitTimeZone;
+        }
+        // dummy query
+//        boolean queryIsNull = (query==null);
+//        if (queryIsNull) {
+        XQuery query =  ((org.zorbaxquery.api.xqj.XQConnection)connection).getZorbaInstance().compileQuery("1");
+//        }
+        DynamicContext dc = query.getDynamicContext();
+        Integer timeZone = (dc.getImplicitTimezone()/60); // in minutes
+        TimeZone result = TimeZone.getTimeZone("GMT"+timeZone.toString());
+//        if (queryIsNull) {
+//            query = null;
+//        }
+        return result;
+    }
+
+    @Override
+    public void bindAtomicValue(QName varName, String value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = connection.createItemFromAtomicValue(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindString(QName varName, String value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = connection.createItemFromString(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindDocument(QName varName, String value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = connection.createItemFromDocument(value, baseURI, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindDocument(QName varName, Reader value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = connection.createItemFromDocument(value, baseURI, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindDocument(QName varName, InputStream value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = connection.createItemFromDocument(value, baseURI, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindDocument(QName varName, XMLStreamReader value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = connection.createItemFromDocument(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindDocument(QName varName, Source value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = connection.createItemFromDocument(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void setImplicitTimeZone(TimeZone value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        try {
+            implicitTimeZone = value;
+        } catch (Exception e) {
+            throw new XQException("Error setting implicit TimeZone: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindItem(QName varName, XQItem value) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)value).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindSequence(QName varName, XQSequence value) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            Item item = new Item(((org.zorbaxquery.api.xqj.XQItem)value.getItem()).getZorbaItem());
+            itemsToBind.put(varName.getLocalPart(), item);
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindObject(QName varName, Object value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = null;
+            if (value instanceof XQItem) {
+                item = (XQItem)value;
+            } else {
+                item = connection.createItemFromObject(value, type);
+            } 
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindBoolean(QName varName, boolean value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        try {
+            XQItem item = connection.createItemFromBoolean(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindByte(QName varName, byte value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        try {
+            XQItem item = connection.createItemFromByte(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindDouble(QName varName, double value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        try {
+            XQItem item = connection.createItemFromDouble(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindFloat(QName varName, float value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        try {
+            XQItem item = connection.createItemFromFloat(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindInt(QName varName, int value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        try {
+            XQItem item = connection.createItemFromInt(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindLong(QName varName, long value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        try {
+            XQItem item = connection.createItemFromLong(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindNode(QName varName, Node value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        try {
+            XQItem item = connection.createItemFromNode(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindShort(QName varName, short value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        try {
+            XQItem item = connection.createItemFromShort(value, type);
+            itemsToBind.put(varName.getLocalPart(),((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    private void isClosedXQException() throws XQException {
+        if (closed) {
+            throw new XQException("This expression is closed");
+        }
+    }
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+   
+    
+}

=== added file 'swig/xqj/XQItem.java'
--- swig/xqj/XQItem.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQItem.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,627 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Properties;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItemType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.helpers.AttributesImpl;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.Iterator;
+import org.zorbaxquery.api.SerializationOptions;
+
+class XQItem implements javax.xml.xquery.XQItem {
+
+    private Item item;
+    private boolean closed=false;
+    private XQItemType itemType;
+    
+    protected Item getZorbaItem() {
+        return item;
+    }
+    
+    public XQItem(XQItemType itemType) {
+        this.itemType = itemType;
+    }
+
+    public XQItem(Item item) {
+        this.item = new Item(item);
+        this.itemType = new org.zorbaxquery.api.xqj.XQItemType(this.item);
+    }
+
+    public XQItem(Item item, XQItemType itemType) {
+        this.item = new Item(item);
+        this.itemType = itemType;
+    }
+
+    public XQItem(javax.xml.xquery.XQItem item) throws XQException {
+        this.item = new Item(((XQItem)item).getZorbaItem());
+        this.itemType = item.getItemType();
+    }
+
+    @Override
+    public void close() throws XQException {
+        if (!closed) {
+            item.close();
+            item.delete();
+            closed = true;
+        }
+    }
+
+    @Override
+    public boolean isClosed() {
+        return closed;
+    }
+
+    @Override
+    public boolean getBoolean() throws XQException {
+        isClosedXQException();
+        if (itemType.getBaseType()!=XQItemType.XQBASETYPE_BOOLEAN) {
+            throw new XQException("Object is not boolean");
+        }
+        Boolean result;
+        try {
+            result = item.getBooleanValue();
+        } catch (Exception e) {
+            throw new XQException("Error getting boolean value" + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public byte getByte() throws XQException {
+        isClosedXQException();
+        isDecimalXQException();
+        byte result = 0;
+        try {
+            if (itemType.getBaseType() == XQItemType.XQBASETYPE_BYTE) {
+                result = (byte) item.getIntValue();
+            } else {
+                result = Byte.parseByte(item.getStringValue());
+            }
+        } catch (Exception e) {
+            throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public double getDouble() throws XQException {
+        isClosedXQException();
+        isFloatXQException();
+        double result = 0;
+        try {
+            if (itemType.getBaseType() == XQItemType.XQBASETYPE_DOUBLE) {
+                result = item.getDoubleValue();
+            } else {
+                result = Double.parseDouble(item.getStringValue());
+            }
+        } catch (Exception e) {
+            throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public float getFloat() throws XQException {
+        isClosedXQException();
+        isFloatXQException();
+        float result = 0;
+        try {
+            if (itemType.getBaseType() == XQItemType.XQBASETYPE_FLOAT) {
+                result = (float)item.getDoubleValue();
+            } else {
+                result = Float.parseFloat(item.getStringValue());
+            }
+        } catch (Exception e) {
+            throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public int getInt() throws XQException {
+        isClosedXQException();
+        isDecimalXQException();
+        int result = 0;
+        try {
+            if (itemType.getBaseType() == XQItemType.XQBASETYPE_INT) {
+                result = item.getIntValue();
+            } else {
+                result = Integer.parseInt(item.getStringValue());
+            }
+        } catch (Exception e) {
+            throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public XQItemType getItemType() throws XQException {
+        isClosedXQException();
+        return itemType;
+    }
+
+    @Override
+    public String getAtomicValue() throws XQException {
+        isClosedXQException();
+        if (!item.isAtomic()) {
+            throw new XQException("Object is not atomic");
+        }
+        org.zorbaxquery.api.Item lItem = null;
+        try {
+            org.zorbaxquery.api.Iterator iterator = item.getAtomizationValue();
+            lItem = new Item();  // creating a new item to be filled by iterator
+            iterator.open();
+            iterator.next(lItem); // item CAN'T BE NULL
+            iterator.close();
+        } catch (Exception e) {
+            throw new XQException("Error getting atomic value: " + e.getLocalizedMessage());
+        }
+        return lItem.getStringValue();
+    }
+
+    @Override
+    public long getLong() throws XQException {
+        isClosedXQException();
+        isDecimalXQException();
+        long result = 0;
+        try {
+            if (itemType.getBaseType() == XQItemType.XQBASETYPE_LONG) {
+                result = item.getLongValue();
+            } else {
+                result = Long.parseLong(item.getStringValue());
+            }
+        } catch (Exception e) {
+            throw new XQException("Error getting byte value" + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public Node getNode() throws XQException {
+        isClosedXQException();
+        if (!item.isNode()) {
+            throw new XQException("Object is not a node");
+        }
+        Node result = null;
+        InputStream inputStream = new ByteArrayInputStream(item.toString().getBytes());
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            Document doc = db.newDocument();
+            Item nodeName = new Item();
+            item.getNodeName(nodeName);
+            switch (itemType.getItemKind()) {
+                case XQItemType.XQITEMKIND_ATTRIBUTE:
+                    result = doc.createAttributeNS("", nodeName.getStringValue());
+                    break;
+                case XQItemType.XQITEMKIND_COMMENT:
+                    result = doc.createComment(item.getStringValue());
+                    break;
+                case XQItemType.XQITEMKIND_DOCUMENT:
+                    String tmpDoc = item.serialize();
+                    if (tmpDoc.length()>0) {
+                        result = db.parse(new InputSource(new StringReader(tmpDoc)));
+                    } else {
+                        result = doc;  // empty doc
+                    }
+                    break;
+                case XQItemType.XQITEMKIND_ELEMENT:
+                    Element e = doc.createElementNS("", nodeName.getStringValue());
+                    Node text = doc.createTextNode(item.getStringValue());
+                    e.appendChild(text);
+                    result = e;
+                    break;
+                case XQItemType.XQITEMKIND_PI:
+                    String tmpPI = item.serialize().substring(2).split(" ")[0];
+                    result = doc.createProcessingInstruction(tmpPI, item.getStringValue());
+                    break;
+                case XQItemType.XQITEMKIND_TEXT:
+                    result = doc.createTextNode(item.getStringValue());
+                    break;
+            }
+        } catch (Exception ex) {
+            throw new XQException("Error converting Item to Node" + ex.getLocalizedMessage());
+        }
+        
+        return result;
+    }
+
+    @Override
+    public URI getNodeUri() throws XQException {
+        isClosedXQException();
+        if (!item.isNode()) {
+            throw new XQException("Object is not a node");
+        }
+        URI result;
+        String namespace = "";
+        try {
+            namespace = item.getNamespace();
+        } catch (Exception ex) {
+            //throw new XQException("Error getting Node URI: " + ex.getLocalizedMessage());
+        }
+        try {
+            result = new URI(namespace);
+        } catch (Exception ex) {
+            throw new XQException("Error getting Node URI: " + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public Object getObject() throws XQException {
+        isClosedXQException();
+        Object result = null;
+        try {
+            if ((itemType.getItemKind()==XQItemType.XQITEMKIND_ATTRIBUTE) ||
+                (itemType.getItemKind()==XQItemType.XQITEMKIND_COMMENT) ||
+                (itemType.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT) ||
+                (itemType.getItemKind()==XQItemType.XQITEMKIND_ELEMENT) ||
+                (itemType.getItemKind()==XQItemType.XQITEMKIND_PI) ||
+                (itemType.getItemKind()==XQItemType.XQITEMKIND_TEXT) ) {
+                result = this.getNode();
+            } else if (itemType.getItemKind()==XQItemType.XQITEMKIND_ATOMIC) {
+                //result = this.getNode();
+                DatatypeFactory factory = DatatypeFactory.newInstance();
+                switch (itemType.getBaseType()) {
+                    /*
+                    case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+                        break;
+                    case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
+                        break;
+                    case XQItemType.XQBASETYPE_ANYTYPE:
+                        break;
+                     *
+                     */
+                    case XQItemType.XQBASETYPE_ANYURI:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_BASE64BINARY:
+                        result = item.serialize().getBytes();
+                        break;
+                    case XQItemType.XQBASETYPE_BOOLEAN:
+                        result = item.getBooleanValue();
+                        break;
+                    case XQItemType.XQBASETYPE_BYTE:
+                        result = new Byte(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_DATE:
+                    case XQItemType.XQBASETYPE_DATETIME:
+                    case XQItemType.XQBASETYPE_GDAY:
+                    case XQItemType.XQBASETYPE_GMONTH:
+                    case XQItemType.XQBASETYPE_GMONTHDAY:
+                    case XQItemType.XQBASETYPE_GYEAR:
+                    case XQItemType.XQBASETYPE_GYEARMONTH:
+                    case XQItemType.XQBASETYPE_TIME:
+                        result = factory.newXMLGregorianCalendar(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_DURATION:
+                        result = factory.newDuration(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_DAYTIMEDURATION:
+                        String tmpString = item.getStringValue();
+                        result = factory.newDurationDayTime(tmpString);
+                        break;
+                    case XQItemType.XQBASETYPE_YEARMONTHDURATION:
+                        result = factory.newDurationYearMonth(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_DECIMAL:
+                        result = new BigDecimal(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_DOUBLE:
+                        result = item.getDoubleValue();
+                        break;
+                    case XQItemType.XQBASETYPE_ENTITIES:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_ENTITY:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_FLOAT:
+                        result = (float)(item.getDoubleValue());
+                        break;
+                    case XQItemType.XQBASETYPE_HEXBINARY:
+                        result = item.getStringValue().getBytes();
+                        break;
+                    case XQItemType.XQBASETYPE_ID:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_IDREF:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_IDREFS:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_INT:
+                        result = item.getIntValue();
+                        break;
+                    case XQItemType.XQBASETYPE_LANGUAGE:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_LONG:
+                        result = item.getLongValue();
+                        break;
+                    case XQItemType.XQBASETYPE_NAME:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_NCNAME:
+                        result = item.serialize();
+                        break;
+                    case XQItemType.XQBASETYPE_NMTOKEN:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_NMTOKENS:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_INTEGER:
+                    case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+                    case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+                    case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+                    case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+                    case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+                        result = new BigInteger(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_NORMALIZED_STRING:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_NOTATION:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_QNAME:
+                        result = new QName(item.getNamespace(), item.getLocalName(), item.getPrefix()) ;
+                        break;
+                    case XQItemType.XQBASETYPE_STRING:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_TOKEN:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_SHORT:
+                    case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+                        result = new Short(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_UNSIGNED_INT:
+                        result = new Long(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+                        result = new Integer(item.getStringValue());
+                        break;
+                    case XQItemType.XQBASETYPE_UNTYPED:
+                        result = item.getStringValue();
+                        break;
+                    case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
+                        result = item.getStringValue();
+                        break;
+                }
+
+            }
+        } catch (Exception e) {
+            throw new XQException("Error getting byte value: " + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public XMLStreamReader getItemAsStream() throws XQException {
+        isClosedXQException();
+        XMLInputFactory factory = XMLInputFactory.newInstance();
+        XMLStreamReader result = null;
+        try {
+            result = factory.createXMLStreamReader(new StringReader(item.serialize()));
+        } catch (Exception ex) {
+            throw new XQException("Error creating XMLStreamReader: " + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public String getItemAsString(Properties prprts) throws XQException {
+        isClosedXQException();
+        String result = null;
+        try {
+            SerializationOptions opts = new SerializationOptions();
+            if ((prprts!=null) && prprts.size()>0) {
+                for(String key : prprts.stringPropertyNames()) {
+                    String value = prprts.getProperty(key);
+                    opts.setSerializerOption(key, value);
+                }
+            }
+            result = item.serialize(opts).replace("&gt;", ">").replace("&lt;", "<");
+        } catch (Exception ex) {
+            throw new XQException("Error serializing item" + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public short getShort() throws XQException {
+        isClosedXQException();
+        isDecimalXQException();
+        short result;
+        try {
+            if (itemType.getBaseType() == XQItemType.XQBASETYPE_SHORT) {
+                result = (short) item.getIntValue();
+            } else {
+                result = Short.parseShort(item.getStringValue());
+            }
+        } catch (Exception ex) {
+            throw new XQException("Error getting short value: " + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public boolean instanceOf(XQItemType xqit) throws XQException {
+        isClosedXQException();
+        return itemType.equals(xqit);
+    }
+
+    @Override
+    public void writeItem(OutputStream out, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(out);
+        isNullXQException(prprts);
+        try {
+            SerializationOptions opts = new SerializationOptions();
+            if ((prprts!=null) && prprts.size()>0) {
+                for(String key : prprts.stringPropertyNames()) {
+                    String value = prprts.getProperty(key);
+                    opts.setSerializerOption(key, value);
+                }
+            }
+            out.write(item.serialize(opts).getBytes());
+        } catch (Exception ex) {
+            throw new XQException("Error writing on stream: " + ex.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void writeItem(Writer writer, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(writer);
+        isNullXQException(prprts);
+        try {
+            SerializationOptions opts = new SerializationOptions();
+            if ((prprts!=null) && prprts.size()>0) {
+                for(String key : prprts.stringPropertyNames()) {
+                    String value = prprts.getProperty(key);
+                    opts.setSerializerOption(key, value);
+                }
+            }
+            writer.write(item.serialize(opts));
+        } catch (Exception ex) {
+            throw new XQException("Error sending to writer: " + ex.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void writeItemToSAX(ContentHandler ch) throws XQException {
+        isClosedXQException();
+        isNullXQException(ch);
+        try {
+            AttributesImpl attributes = new AttributesImpl();
+            Iterator attr = item.getAttributes();
+            attr.open();
+            Item attribute = new Item();
+            while (attr.next(attribute)) {
+                attributes.addAttribute(attribute.getNamespace(), attribute.getLocalName(), "", attribute.getType().getStringValue(), attribute.getStringValue());
+            }
+            attribute.close();
+            attr.close();
+            attr.delete();
+            //attribute.delete();
+            String namespace = "";
+            if (itemType.getBaseType() != XQItemType.XQBASETYPE_ANYTYPE){
+                namespace = item.getNamespace();
+            }
+            Item name = new Item();
+            item.getNodeName(name);
+            String nodeName = name.getStringValue();
+            name.close();
+            //name.delete();
+            char [] content = item.getStringValue().toCharArray();
+            
+            ch.startElement(namespace, nodeName , "", attributes);
+            ch.characters(content, 0, content.length);
+            ch.endElement(namespace, nodeName, "");
+        } catch (Exception ex) {
+            throw new XQException("Error writing item to SAX: " + ex.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void writeItemToResult(Result result) throws XQException {
+        isClosedXQException();
+        isNullXQException(result);
+        try {
+            Source xmlSource = new DOMSource(getNode());
+            TransformerFactory transformerFactory = TransformerFactory.newInstance();
+            Transformer transformer;
+            transformer = transformerFactory.newTransformer();
+            transformer.setOutputProperty("indent", "yes");
+            transformer.transform(xmlSource, result);
+        } catch (Exception ex) {
+            throw new XQException ("Error serializing to javax.xml.transform.Result");
+        }
+    }
+
+    private void isClosedXQException() throws XQException {
+        if (closed) {
+            throw new XQException("This connection is closed");
+        }
+    }
+    
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+    
+    private void isDecimalXQException() throws XQException {
+        switch (itemType.getBaseType()) {
+            case XQItemType.XQBASETYPE_DECIMAL:
+            case XQItemType.XQBASETYPE_BYTE:
+            case XQItemType.XQBASETYPE_INT:
+            case XQItemType.XQBASETYPE_INTEGER:
+            case XQItemType.XQBASETYPE_LONG:
+            case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+            case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+            case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+            case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+            case XQItemType.XQBASETYPE_SHORT:
+            case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+            case XQItemType.XQBASETYPE_UNSIGNED_INT:
+            case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+            case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+                break;
+            default:
+                throw new XQException("Object is not xs:decimal or a derivate");
+        }
+    }
+    
+    private void isFloatXQException() throws XQException {
+        if (! ((itemType.getBaseType()==XQItemType.XQBASETYPE_FLOAT) ||
+            (itemType.getBaseType()==XQItemType.XQBASETYPE_DOUBLE)) )
+            {
+                throw new XQException("Object is not xs:decimal or a derivate");
+            }
+    }
+}

=== added file 'swig/xqj/XQItemType.java'
--- swig/xqj/XQItemType.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQItemType.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,738 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.net.URI;
+import javax.xml.namespace.QName;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQSequenceType;
+import org.zorbaxquery.api.IdentTypes.Kind;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.TypeIdentifier;
+
+public class XQItemType implements javax.xml.xquery.XQItemType {
+    public static final int ZORBA_XQITEMKIND_ANY = 0;
+    public static final int ZORBA_XQITEMKIND_DOCUMENT = 1;
+    public static final int ZORBA_XQITEMKIND_ELEMENT = 2;
+    public static final int ZORBA_XQITEMKIND_ATTRIBUTE = 3;
+    public static final int ZORBA_XQITEMKIND_TEXT = 4;
+    public static final int ZORBA_XQITEMKIND_PI = 5;
+    public static final int ZORBA_XQITEMKIND_COMMENT = 6;
+
+    private int itemKind = 0;
+    private int baseType = 0;
+    private QName nodeName = null;
+    private QName typeName = null;
+    private URI schemaURI = null;
+    private boolean allowNill = false;
+    private String piTarget = null;
+
+    protected TypeIdentifier getTypeIdentifier() throws XQException {
+        TypeIdentifier result = null;
+        switch (itemKind) {
+            case XQITEMKIND_ATOMIC:
+                result = TypeIdentifier.createEmptyType();
+                break;
+            case XQITEMKIND_ATTRIBUTE:
+                // TODO: fix uriWildcard, localNameWildcard
+                result = TypeIdentifier.createAttributeType(schemaURI.toString(), true, nodeName.getLocalPart(), true, TypeIdentifier.createAnyNodeType());
+                break;
+            case XQITEMKIND_COMMENT:
+                result = TypeIdentifier.createCommentType();
+                break;
+            case XQITEMKIND_DOCUMENT:
+            case XQITEMKIND_DOCUMENT_ELEMENT:
+            case XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT:
+                result = TypeIdentifier.createDocumentType(TypeIdentifier.createAnyNodeType());
+                break;
+            case XQITEMKIND_ELEMENT:
+                // TODO: fix uriWildcard, localNameWildcard
+                result = TypeIdentifier.createElementType(schemaURI.toString(), true, nodeName.getLocalPart(), true, TypeIdentifier.createAnyNodeType());
+                break;
+            case XQITEMKIND_ITEM:
+                result = TypeIdentifier.createItemType();
+                break;
+            case XQITEMKIND_NODE:
+                result = TypeIdentifier.createAnyNodeType();
+                break;
+            case XQITEMKIND_PI:
+                result = TypeIdentifier.createPIType();
+                break;
+            case XQITEMKIND_TEXT:
+                result = TypeIdentifier.createTextType();
+                break;
+            case XQITEMKIND_SCHEMA_ATTRIBUTE:
+            case XQITEMKIND_SCHEMA_ELEMENT:
+            default:
+                throw new XQException("Item kind is not valid.");
+              
+        }
+        return result;
+    }
+    
+    public XQItemType(TypeIdentifier typeIdentifier) {
+        switch (typeIdentifier.getKind()) {
+            case Kind.ANY_NODE_TYPE:
+                itemKind = XQITEMKIND_NODE;
+                break;
+            case Kind.ATTRIBUTE_TYPE:
+                itemKind = XQITEMKIND_ATTRIBUTE;
+                break;
+            case Kind.COMMENT_TYPE:
+                itemKind = XQITEMKIND_COMMENT;
+                break;
+            case Kind.DOCUMENT_TYPE:
+                itemKind = XQITEMKIND_DOCUMENT;
+                break;
+            case Kind.ELEMENT_TYPE:
+                itemKind = XQITEMKIND_ELEMENT;
+                break;
+            case Kind.EMPTY_TYPE:
+            case Kind.INVALID_TYPE:
+            case Kind.ITEM_TYPE:
+            case Kind.NAMED_TYPE:
+                itemKind = XQITEMKIND_ITEM;
+                break;
+            case Kind.PI_TYPE:
+                itemKind = XQITEMKIND_PI;
+                break;
+            case Kind.TEXT_TYPE:
+                itemKind = XQITEMKIND_TEXT;
+                break;
+        }
+        
+        String type = typeIdentifier.getLocalName();
+        baseType = XQItemType.XQBASETYPE_ANYTYPE;
+        if (type.indexOf("anyAtomicType")>=0){
+            baseType = XQItemType.XQBASETYPE_ANYATOMICTYPE;
+        } else if (type.indexOf("anySimpleType")>=0){
+            baseType = XQItemType.XQBASETYPE_ANYTYPE;
+        } else if (type.indexOf("anyType")>=0){
+            baseType = XQItemType.XQBASETYPE_ANYTYPE;
+        } else if (type.indexOf("anyURI")>=0){
+            baseType = XQItemType.XQBASETYPE_ANYURI;
+        } else if (type.indexOf("base64Binary")>=0){
+            baseType = XQItemType.XQBASETYPE_BASE64BINARY;
+        } else if (type.indexOf("boolean")>=0){
+            baseType = XQItemType.XQBASETYPE_BOOLEAN;
+        } else if (type.indexOf("byte")>=0){
+            baseType = XQItemType.XQBASETYPE_BYTE;
+        } else if (type.indexOf("dateTime")>=0){
+            baseType = XQItemType.XQBASETYPE_DATETIME;
+        } else if (type.indexOf("date")>=0){
+            baseType = XQItemType.XQBASETYPE_DATE;
+        } else if (type.indexOf("dayTimeDuration")>=0){
+            baseType = XQItemType.XQBASETYPE_DAYTIMEDURATION;
+        } else if (type.indexOf("decimal")>=0){
+            baseType = XQItemType.XQBASETYPE_DECIMAL;
+        } else if (type.indexOf("double")>=0){
+            baseType = XQItemType.XQBASETYPE_DOUBLE;
+        } else if (type.indexOf("duration")>=0){
+            baseType = XQItemType.XQBASETYPE_DURATION;
+        } else if (type.indexOf("ENTITIES")>=0){
+            baseType = XQItemType.XQBASETYPE_ENTITIES;
+        } else if (type.indexOf("ENTITY")>=0){
+            baseType = XQItemType.XQBASETYPE_ENTITY;
+        } else if (type.indexOf("float")>=0){
+            baseType = XQItemType.XQBASETYPE_FLOAT;
+        } else if (type.indexOf("gDay")>=0){
+            baseType = XQItemType.XQBASETYPE_GDAY;
+        } else if (type.indexOf("gMonthDay")>=0){
+            baseType = XQItemType.XQBASETYPE_GMONTHDAY;
+        } else if (type.indexOf("gMonth")>=0){
+            baseType = XQItemType.XQBASETYPE_GMONTH;
+        } else if (type.indexOf("gYear")>=0){
+            baseType = XQItemType.XQBASETYPE_GYEAR;
+        } else if (type.indexOf("hexBinary")>=0){
+            baseType = XQItemType.XQBASETYPE_HEXBINARY;
+        } else if (type.indexOf("IDREFS")>=0){
+            baseType = XQItemType.XQBASETYPE_IDREFS;
+        } else if (type.indexOf("IDREF")>=0){
+            baseType = XQItemType.XQBASETYPE_IDREF;
+        } else if (type.indexOf("ID")>=0){
+            baseType = XQItemType.XQBASETYPE_ID;
+        } else if (type.indexOf("integer")>=0){
+            baseType = XQItemType.XQBASETYPE_INTEGER;
+        } else if (type.indexOf("int")>=0){
+            baseType = XQItemType.XQBASETYPE_INT;
+        } else if (type.indexOf("language")>=0){
+            baseType = XQItemType.XQBASETYPE_LANGUAGE;
+        } else if (type.indexOf("long")>=0){
+            baseType = XQItemType.XQBASETYPE_LONG;
+        } else if (type.indexOf("QName")>=0){
+            baseType = XQItemType.XQBASETYPE_QNAME;
+        } else if (type.indexOf("NCName")>=0){
+            baseType = XQItemType.XQBASETYPE_NCNAME;
+        } else if (type.indexOf("Name")>=0){
+            baseType = XQItemType.XQBASETYPE_NAME;
+        } else if (type.indexOf("negativeInteger")>=0){
+            baseType = XQItemType.XQBASETYPE_NEGATIVE_INTEGER;
+        } else if (type.indexOf("NMTOKENS")>=0){
+            baseType = XQItemType.XQBASETYPE_NMTOKENS;
+        } else if (type.indexOf("NMTOKEN")>=0){
+            baseType = XQItemType.XQBASETYPE_NMTOKEN;
+        } else if (type.indexOf("nonNegativeInteger")>=0){
+            baseType = XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER;
+        } else if (type.indexOf("nonPositiveInteger")>=0){
+            baseType = XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER;
+        } else if (type.indexOf("normalizedString")>=0){
+            baseType = XQItemType.XQBASETYPE_NORMALIZED_STRING;
+        } else if (type.indexOf("NOTATION")>=0){
+            baseType = XQItemType.XQBASETYPE_NOTATION;
+        } else if (type.indexOf("positiveInteger")>=0){
+            baseType = XQItemType.XQBASETYPE_POSITIVE_INTEGER;
+        } else if (type.indexOf("short")>=0){
+            baseType = XQItemType.XQBASETYPE_SHORT;
+        } else if (type.indexOf("string")>=0){
+            baseType = XQItemType.XQBASETYPE_STRING;
+        } else if (type.indexOf("time")>=0){
+            baseType = XQItemType.XQBASETYPE_TIME;
+        } else if (type.indexOf("token")>=0){
+            baseType = XQItemType.XQBASETYPE_TOKEN;
+        } else if (type.indexOf("unsignedByte")>=0){
+            baseType = XQItemType.XQBASETYPE_UNSIGNED_BYTE;
+        } else if (type.indexOf("unsignedInt")>=0){
+            baseType = XQItemType.XQBASETYPE_UNSIGNED_INT;
+        } else if (type.indexOf("unsignedLong")>=0){
+            baseType = XQItemType.XQBASETYPE_UNSIGNED_LONG;
+        } else if (type.indexOf("unsignedShort")>=0){
+            baseType = XQItemType.XQBASETYPE_UNSIGNED_SHORT;
+        } else if (type.indexOf("untypedAtomic")>=0){
+            baseType = XQItemType.XQBASETYPE_UNTYPEDATOMIC;
+        } else if (type.indexOf("untyped")>=0){
+            baseType = XQItemType.XQBASETYPE_UNTYPED;
+        } else if (type.indexOf("yearMonthDuration")>=0){
+            baseType = XQItemType.XQBASETYPE_YEARMONTHDURATION;
+        }
+        generateTypeName();
+    }
+    public XQItemType(Item zorbaItem) {
+        
+        String type = "";
+        if (zorbaItem.isNode()) {
+            switch (zorbaItem.getNodeKind()) {
+                case ZORBA_XQITEMKIND_ANY:
+                    itemKind = XQITEMKIND_ELEMENT;
+                    break;
+                case ZORBA_XQITEMKIND_ATTRIBUTE:
+                    itemKind = XQITEMKIND_ATTRIBUTE;
+                    break;
+                case ZORBA_XQITEMKIND_COMMENT:
+                    itemKind = XQITEMKIND_COMMENT;
+                    break;
+                case ZORBA_XQITEMKIND_DOCUMENT:
+                    itemKind = XQITEMKIND_DOCUMENT;
+                    break;
+                case ZORBA_XQITEMKIND_ELEMENT:
+                    itemKind = XQITEMKIND_ELEMENT;
+                    break;
+                case ZORBA_XQITEMKIND_PI:
+                    itemKind = XQITEMKIND_PI;
+                    break;
+                case ZORBA_XQITEMKIND_TEXT:
+                    itemKind = XQITEMKIND_TEXT;
+                    break;
+            }
+        } else if (zorbaItem.isAtomic()) {
+            itemKind = XQITEMKIND_ATOMIC;
+            type = zorbaItem.getType().getStringValue();
+        }
+        baseType = XQItemType.XQBASETYPE_ANYTYPE;
+        if (type.indexOf("anyAtomicType")>=0){
+            baseType = XQItemType.XQBASETYPE_ANYATOMICTYPE;
+        } else if (type.indexOf("anySimpleType")>=0){
+            baseType = XQItemType.XQBASETYPE_ANYTYPE;
+        } else if (type.indexOf("anyType")>=0){
+            baseType = XQItemType.XQBASETYPE_ANYTYPE;
+        } else if (type.indexOf("anyURI")>=0){
+            baseType = XQItemType.XQBASETYPE_ANYURI;
+        } else if (type.indexOf("base64Binary")>=0){
+            baseType = XQItemType.XQBASETYPE_BASE64BINARY;
+        } else if (type.indexOf("boolean")>=0){
+            baseType = XQItemType.XQBASETYPE_BOOLEAN;
+        } else if (type.indexOf("byte")>=0){
+            baseType = XQItemType.XQBASETYPE_BYTE;
+        } else if (type.indexOf("dateTime")>=0){
+            baseType = XQItemType.XQBASETYPE_DATETIME;
+        } else if (type.indexOf("date")>=0){
+            baseType = XQItemType.XQBASETYPE_DATE;
+        } else if (type.indexOf("dayTimeDuration")>=0){
+            baseType = XQItemType.XQBASETYPE_DAYTIMEDURATION;
+        } else if (type.indexOf("decimal")>=0){
+            baseType = XQItemType.XQBASETYPE_DECIMAL;
+        } else if (type.indexOf("double")>=0){
+            baseType = XQItemType.XQBASETYPE_DOUBLE;
+        } else if (type.indexOf("duration")>=0){
+            baseType = XQItemType.XQBASETYPE_DURATION;
+        } else if (type.indexOf("ENTITIES")>=0){
+            baseType = XQItemType.XQBASETYPE_ENTITIES;
+        } else if (type.indexOf("ENTITY")>=0){
+            baseType = XQItemType.XQBASETYPE_ENTITY;
+        } else if (type.indexOf("float")>=0){
+            baseType = XQItemType.XQBASETYPE_FLOAT;
+        } else if (type.indexOf("gDay")>=0){
+            baseType = XQItemType.XQBASETYPE_GDAY;
+        } else if (type.indexOf("gMonthDay")>=0){
+            baseType = XQItemType.XQBASETYPE_GMONTHDAY;
+        } else if (type.indexOf("gMonth")>=0){
+            baseType = XQItemType.XQBASETYPE_GMONTH;
+        } else if (type.indexOf("gYear")>=0){
+            baseType = XQItemType.XQBASETYPE_GYEAR;
+        } else if (type.indexOf("hexBinary")>=0){
+            baseType = XQItemType.XQBASETYPE_HEXBINARY;
+        } else if (type.indexOf("IDREFS")>=0){
+            baseType = XQItemType.XQBASETYPE_IDREFS;
+        } else if (type.indexOf("IDREF")>=0){
+            baseType = XQItemType.XQBASETYPE_IDREF;
+        } else if (type.indexOf("ID")>=0){
+            baseType = XQItemType.XQBASETYPE_ID;
+        } else if (type.indexOf("integer")>=0){
+            baseType = XQItemType.XQBASETYPE_INTEGER;
+        } else if (type.indexOf("int")>=0){
+            baseType = XQItemType.XQBASETYPE_INT;
+        } else if (type.indexOf("language")>=0){
+            baseType = XQItemType.XQBASETYPE_LANGUAGE;
+        } else if (type.indexOf("long")>=0){
+            baseType = XQItemType.XQBASETYPE_LONG;
+        } else if (type.indexOf("QName")>=0){
+            baseType = XQItemType.XQBASETYPE_QNAME;
+        } else if (type.indexOf("NCName")>=0){
+            baseType = XQItemType.XQBASETYPE_NCNAME;
+        } else if (type.indexOf("Name")>=0){
+            baseType = XQItemType.XQBASETYPE_NAME;
+        } else if (type.indexOf("negativeInteger")>=0){
+            baseType = XQItemType.XQBASETYPE_NEGATIVE_INTEGER;
+        } else if (type.indexOf("NMTOKENS")>=0){
+            baseType = XQItemType.XQBASETYPE_NMTOKENS;
+        } else if (type.indexOf("NMTOKEN")>=0){
+            baseType = XQItemType.XQBASETYPE_NMTOKEN;
+        } else if (type.indexOf("nonNegativeInteger")>=0){
+            baseType = XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER;
+        } else if (type.indexOf("nonPositiveInteger")>=0){
+            baseType = XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER;
+        } else if (type.indexOf("normalizedString")>=0){
+            baseType = XQItemType.XQBASETYPE_NORMALIZED_STRING;
+        } else if (type.indexOf("NOTATION")>=0){
+            baseType = XQItemType.XQBASETYPE_NOTATION;
+        } else if (type.indexOf("positiveInteger")>=0){
+            baseType = XQItemType.XQBASETYPE_POSITIVE_INTEGER;
+        } else if (type.indexOf("short")>=0){
+            baseType = XQItemType.XQBASETYPE_SHORT;
+        } else if (type.indexOf("string")>=0){
+            baseType = XQItemType.XQBASETYPE_STRING;
+        } else if (type.indexOf("time")>=0){
+            baseType = XQItemType.XQBASETYPE_TIME;
+        } else if (type.indexOf("token")>=0){
+            baseType = XQItemType.XQBASETYPE_TOKEN;
+        } else if (type.indexOf("unsignedByte")>=0){
+            baseType = XQItemType.XQBASETYPE_UNSIGNED_BYTE;
+        } else if (type.indexOf("unsignedInt")>=0){
+            baseType = XQItemType.XQBASETYPE_UNSIGNED_INT;
+        } else if (type.indexOf("unsignedLong")>=0){
+            baseType = XQItemType.XQBASETYPE_UNSIGNED_LONG;
+        } else if (type.indexOf("unsignedShort")>=0){
+            baseType = XQItemType.XQBASETYPE_UNSIGNED_SHORT;
+        } else if (type.indexOf("untypedAtomic")>=0){
+            baseType = XQItemType.XQBASETYPE_UNTYPEDATOMIC;
+        } else if (type.indexOf("untyped")>=0){
+            baseType = XQItemType.XQBASETYPE_UNTYPED;
+        } else if (type.indexOf("yearMonthDuration")>=0){
+            baseType = XQItemType.XQBASETYPE_YEARMONTHDURATION;
+        }
+        generateTypeName();
+    }
+    
+    public XQItemType(int itemkind, String piTarget) {
+        this.itemKind = itemkind;
+        this.piTarget = piTarget;
+        generateTypeName();
+    }
+    public XQItemType(int itemkind) {
+        this.itemKind = itemkind;
+        generateTypeName();
+    }
+    public XQItemType(int itemkind, int basetype) {
+        this.itemKind = itemkind;
+        this.baseType = basetype;
+        generateTypeName();
+    }
+    public XQItemType(int itemkind, QName nodename, int basetype) {
+        this.itemKind = itemkind;
+        this.nodeName = nodename;
+        this.baseType = basetype;
+        generateTypeName();
+    }
+    public XQItemType(int itemkind, QName nodename, int basetype, QName typename, URI schemaURI, boolean allowNill) throws XQException {
+        this.itemKind = itemkind;
+        this.nodeName = nodename;
+        this.baseType = basetype;
+        this.typeName = typename;
+        this.schemaURI = schemaURI;
+        this.allowNill = allowNill;
+    }
+    public XQItemType(int itemkind, QName nodename, int basetype, URI schemaURI) throws XQException {
+        this.itemKind = itemkind;
+        this.nodeName = nodename;
+        this.baseType = basetype;
+        this.schemaURI = schemaURI;
+        generateTypeName();
+    }
+    
+    
+    private void generateTypeName() {
+        String namespaceURI = "http://www.w3.org/2001/XMLSchema";;
+        String localPart = "untyped";
+        String prefix = "";
+        
+        switch (baseType) {
+            case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+                localPart = "anyAtomicType";
+                break;
+            case XQItemType.XQBASETYPE_ANYSIMPLETYPE:
+                localPart = "anySimpleType";
+                break;
+            case XQItemType.XQBASETYPE_ANYTYPE:
+                localPart = "anyType";
+                break;
+            case XQItemType.XQBASETYPE_ANYURI:
+                localPart = "anyURI";
+                break;
+            case XQItemType.XQBASETYPE_BASE64BINARY:
+                localPart = "base64Binary";
+                break;
+            case XQItemType.XQBASETYPE_BOOLEAN:
+                localPart = "boolean";
+                break;
+            case XQItemType.XQBASETYPE_BYTE:
+                localPart = "byte";
+                break;
+            case XQItemType.XQBASETYPE_DATE:
+                localPart = "date";
+                break;
+            case XQItemType.XQBASETYPE_DATETIME:
+                localPart = "dateTime";
+                break;
+            case XQItemType.XQBASETYPE_DAYTIMEDURATION:
+                localPart = "dayTimeDuration";
+                break;
+            case XQItemType.XQBASETYPE_DECIMAL:
+                localPart = "decimal";
+                break;
+            case XQItemType.XQBASETYPE_DOUBLE:
+                localPart = "double";
+                break;
+            case XQItemType.XQBASETYPE_DURATION:
+                localPart = "duration";
+                break;
+            case XQItemType.XQBASETYPE_ENTITIES:
+                localPart = "ENTITIES";
+                break;
+            case XQItemType.XQBASETYPE_ENTITY:
+                localPart = "ENTITY";
+                break;
+            case XQItemType.XQBASETYPE_FLOAT:
+                localPart = "float";
+                break;
+            case XQItemType.XQBASETYPE_GDAY:
+                localPart = "gDay";
+                break;
+            case XQItemType.XQBASETYPE_GMONTH:
+                localPart = "gMonth";
+                break;
+            case XQItemType.XQBASETYPE_GMONTHDAY:
+                localPart = "gMonthDay";
+                break;
+            case XQItemType.XQBASETYPE_GYEAR:
+                localPart = "gYear";
+                break;
+            case XQItemType.XQBASETYPE_GYEARMONTH:
+                localPart = "gYearMonth";
+                break;
+            case XQItemType.XQBASETYPE_HEXBINARY:
+                localPart = "hexBinary";
+                break;
+            case XQItemType.XQBASETYPE_ID:
+                localPart = "ID";
+                break;
+            case XQItemType.XQBASETYPE_IDREF:
+                localPart = "IDREF";
+                break;
+            case XQItemType.XQBASETYPE_IDREFS:
+                localPart = "IDREFS";
+                break;
+            case XQItemType.XQBASETYPE_INT:
+                localPart = "int";
+                break;
+            case XQItemType.XQBASETYPE_INTEGER:
+                localPart = "integer";
+                break;
+            case XQItemType.XQBASETYPE_LANGUAGE:
+                localPart = "language";
+                break;
+            case XQItemType.XQBASETYPE_LONG:
+                localPart = "long";
+                break;
+            case XQItemType.XQBASETYPE_NAME:
+                localPart = "Name";
+                break;
+            case XQItemType.XQBASETYPE_NCNAME:
+                localPart = "NCName";
+                break;
+            case XQItemType.XQBASETYPE_NEGATIVE_INTEGER:
+                localPart = "negativeInteger";
+                break;
+            case XQItemType.XQBASETYPE_NMTOKEN:
+                localPart = "NMTOKEN";
+                break;
+            case XQItemType.XQBASETYPE_NMTOKENS:
+                localPart = "NMTOKENS";
+                break;
+            case XQItemType.XQBASETYPE_NONNEGATIVE_INTEGER:
+                localPart = "nonNegativeInteger";
+                break;
+            case XQItemType.XQBASETYPE_NONPOSITIVE_INTEGER:
+                localPart = "nonPositiveInteger";
+                break;
+            case XQItemType.XQBASETYPE_NORMALIZED_STRING:
+                localPart = "normalizedString";
+                break;
+            case XQItemType.XQBASETYPE_NOTATION:
+                localPart = "NOTATION";
+                break;
+            case XQItemType.XQBASETYPE_POSITIVE_INTEGER:
+                localPart = "positiveInteger";
+                break;
+            case XQItemType.XQBASETYPE_QNAME:
+                localPart = "QName";
+                break;
+            case XQItemType.XQBASETYPE_SHORT:
+                localPart = "short";
+                break;
+            case XQItemType.XQBASETYPE_STRING:
+                localPart = "string";
+                break;
+            case XQItemType.XQBASETYPE_TIME:
+                localPart = "time";
+                break;
+            case XQItemType.XQBASETYPE_TOKEN:
+                localPart = "token";
+                break;
+            case XQItemType.XQBASETYPE_UNSIGNED_BYTE:
+                localPart = "unsignedByte";
+                break;
+            case XQItemType.XQBASETYPE_UNSIGNED_INT:
+                localPart = "unsignedInt";
+                break;
+            case XQItemType.XQBASETYPE_UNSIGNED_LONG:
+                localPart = "unsignedLong";
+                break;
+            case XQItemType.XQBASETYPE_UNSIGNED_SHORT:
+                localPart = "unsignedShort";
+                break;
+            case XQItemType.XQBASETYPE_UNTYPED:
+                localPart = "untyped";
+                break;
+            case XQItemType.XQBASETYPE_UNTYPEDATOMIC:
+                localPart = "untypedAtomic";
+                break;
+            case XQItemType.XQBASETYPE_YEARMONTHDURATION:
+                localPart = "yearMonthDuration";
+                break;
+            default:
+                localPart = "untyped";
+                break;
+       }
+        typeName = new QName(namespaceURI, localPart, prefix);
+    }
+    
+    
+    
+    
+    @Override
+    public int getBaseType() throws XQException {
+        if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
+              (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE) ||
+              (itemKind==XQItemType.XQITEMKIND_ATOMIC))) {
+            throw new XQException("Item kind is not valid for a Base Type.");
+        }
+        return baseType;
+    }
+
+    @Override
+    public int getItemKind() {
+        return itemKind;
+    }
+
+    @Override
+    public int getItemOccurrence() {
+        return XQSequenceType.OCC_EXACTLY_ONE;
+    }
+
+    @Override
+    public QName getNodeName() throws XQException {
+        if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
+              (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE))) {
+            throw new XQException("Item kind is not valid for a Type Name.");
+        }
+        return nodeName;
+    }
+
+    @Override
+    public URI getSchemaURI() {
+        return schemaURI;
+    }
+
+    @Override
+    public QName getTypeName() throws XQException {
+        if (!((itemKind==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_ATOMIC) ||
+              (itemKind==XQItemType.XQITEMKIND_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_SCHEMA_ELEMENT) ||
+              (itemKind==XQItemType.XQITEMKIND_ATTRIBUTE) ||
+              (itemKind==XQItemType.XQITEMKIND_SCHEMA_ATTRIBUTE))) {
+            throw new XQException("Item kind is not valid for a Type Name.");
+        }
+        return typeName;
+    }
+
+    @Override
+    public boolean isAnonymousType() {
+        return (itemKind==0);
+    }
+
+    @Override
+    public boolean isElementNillable() {
+        return allowNill;
+    }
+
+    @Override
+    public String getPIName() throws XQException {
+        if (itemKind!=XQItemType.XQITEMKIND_PI) {
+            throw new XQException("Item kind is not a PI.");
+        }
+        return piTarget;
+    }
+
+    @Override
+    public XQItemType getItemType() {
+        return this;
+    }
+    
+    @Override
+    public boolean equals(Object o) {
+        boolean result = false;
+        boolean supportBaseType = false;
+        boolean supportNodeName = false;
+        boolean supportTypeName = false;
+        boolean supportPIName = false;
+        if (o instanceof XQItemType) {
+            if ( (getItemKind()==((XQItemType)o).getItemKind()) &&
+                 (getSchemaURI()==((XQItemType)o).getSchemaURI()) &&
+                 (isAnonymousType()==((XQItemType)o).isAnonymousType()) &&
+                 (isElementNillable()==((XQItemType)o).isElementNillable()) ) {
+                try {
+                    supportBaseType = getBaseType() == ((XQItemType)o).getBaseType();
+                } catch (Exception e) {
+                    supportBaseType = true;  // Not supported
+                }
+                try {
+                    supportNodeName = getNodeName() == ((XQItemType)o).getNodeName();
+                } catch (Exception e) {
+                    supportNodeName = true; // Not supported
+                }
+                try {
+                    supportTypeName = getTypeName().equals(((XQItemType)o).getTypeName());
+                } catch (Exception e) {
+                    supportTypeName = true; // Not supported
+                }
+                try {
+                    supportPIName = getPIName().equals(((XQItemType)o).getPIName());
+                } catch (Exception e) {
+                    supportPIName = true; // Not supported
+                }
+                
+                
+                result = supportBaseType && supportNodeName && supportTypeName && supportPIName;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public int hashCode() {
+        int hashCode = 0;
+        hashCode = this.getItemKind();
+        if (this.getSchemaURI() != null) {
+            hashCode = 31*hashCode + this.getSchemaURI().hashCode();
+        }
+        try {
+          int basetype = this.getBaseType();
+          hashCode = 31*hashCode + basetype;
+        } catch (Exception e) {}
+        try {
+          QName nodename = this.getNodeName();
+          if (nodename!=null) {
+              hashCode = 31*hashCode + nodename.hashCode();
+          }
+        } catch (Exception e) {}
+        try {
+            QName typename = this.getTypeName();
+            hashCode = 31*hashCode + typename.hashCode();
+        } catch(Exception e) {}
+        try {
+            String piname = this.getPIName();
+            if (piname != null) {
+                hashCode = 31*hashCode + piname.hashCode();
+            }
+        } catch (Exception e) {}
+        return hashCode;
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer result = new StringBuffer();
+
+        try {
+            for (java.lang.reflect.Field field: XQItemType.class.getFields()) {
+                if (field.getName().startsWith("XQITEMKIND_")) {
+                    if (field.getInt(this)==itemKind) {
+                        result.append("Item Kind: ").append(field.getName().substring(11));
+                    }
+                }
+                if (field.getName().startsWith("XQBASETYPE_")) {
+                    if (field.getInt(this)==baseType) {
+                        result.append("  Base Type: ").append(field.getName().substring(11));
+                    }
+                }
+            }
+        } catch (Exception e){
+            result.append("Item Kind or Base Type error: ").append(e.getLocalizedMessage());
+        }
+
+        return result.toString();
+    }
+    
+    
+}

=== added file 'swig/xqj/XQMetaData.java'
--- swig/xqj/XQMetaData.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQMetaData.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQException;
+import org.zorbaxquery.api.Zorba;
+
+public class XQMetaData implements javax.xml.xquery.XQMetaData {
+    
+    private int XQJ_MAJOR = 1;
+    private int XQJ_MINOR = 1;
+    
+    private XQConnection connection;
+    private Zorba zorba;
+    public XQMetaData(XQConnection conn) throws XQException {
+        if (conn.isClosed()) {
+            throw new XQException("This connection is closed");
+        }
+        connection = conn;
+        zorba = ((org.zorbaxquery.api.xqj.XQConnection)connection).getZorbaInstance();
+    }
+    
+    @Override
+    public int getProductMajorVersion() throws XQException {
+        isClosedXQException();
+        return zorba.getMajorVersion();
+    }
+
+    @Override
+    public int getProductMinorVersion() throws XQException {
+        isClosedXQException();
+        return zorba.getMinorVersion();
+    }
+
+    @Override
+    public String getProductName() throws XQException {
+        isClosedXQException();
+        return "Zorba - The XQuery Processor";
+    }
+
+    @Override
+    public String getProductVersion() throws XQException {
+        isClosedXQException();
+        return zorba.getVersion();
+    }
+
+    @Override
+    public int getXQJMajorVersion() throws XQException {
+        isClosedXQException();
+        return XQJ_MAJOR;
+    }
+
+    @Override
+    public int getXQJMinorVersion() throws XQException {
+        isClosedXQException();
+        return XQJ_MINOR;
+    }
+
+    @Override
+    public String getXQJVersion() throws XQException {
+        isClosedXQException();
+        return new String().concat(new Integer(XQJ_MAJOR).toString()).concat(".").concat(new Integer(XQJ_MINOR).toString());
+    }
+
+    @Override
+    public boolean isReadOnly() throws XQException {
+        isClosedXQException();
+        return false;
+    }
+
+    @Override
+    public boolean isXQueryXSupported() throws XQException {
+        isClosedXQException();
+        return false;  //depends on compilation directive
+    }
+
+    @Override
+    public boolean isTransactionSupported() throws XQException {
+        isClosedXQException();
+        return false;
+    }
+
+    @Override
+    public boolean isStaticTypingFeatureSupported() throws XQException {
+        isClosedXQException();
+        return false;
+    }
+
+    @Override
+    public boolean isSchemaImportFeatureSupported() throws XQException {
+        isClosedXQException();
+        return true;
+    }
+
+    @Override
+    public boolean isSchemaValidationFeatureSupported() throws XQException {
+        isClosedXQException();
+        return true;
+    }
+
+    @Override
+    public boolean isFullAxisFeatureSupported() throws XQException {
+        isClosedXQException();
+        return true;
+    }
+
+    @Override
+    public boolean isModuleFeatureSupported() throws XQException {
+        isClosedXQException();
+        return true;
+    }
+
+    @Override
+    public boolean isSerializationFeatureSupported() throws XQException {
+        isClosedXQException();
+        return true;
+    }
+
+    @Override
+    public boolean isStaticTypingExtensionsSupported() throws XQException {
+        isClosedXQException();
+        return false;
+    }
+
+    @Override
+    public String getUserName() throws XQException {
+        isClosedXQException();
+        return null;
+    }
+
+    @Override
+    public int getMaxExpressionLength() throws XQException {
+        isClosedXQException();
+        return 0;
+    }
+
+    @Override
+    public int getMaxUserNameLength() throws XQException {
+        isClosedXQException();
+        return 0;
+    }
+
+    @Override
+    public boolean wasCreatedFromJDBCConnection() throws XQException {
+        isClosedXQException();
+        return false;
+    }
+
+    @Override
+    public boolean isXQueryEncodingDeclSupported() throws XQException {
+        isClosedXQException();
+        return false;
+    }
+
+    @Override
+    public Set getSupportedXQueryEncodings() throws XQException {
+        isClosedXQException();
+        Set<String> set = new HashSet<String>();
+        set.add("UTF8");
+        return set;
+        
+    }
+
+    @Override
+    public boolean isXQueryEncodingSupported(String string) throws XQException {
+        isClosedXQException();
+        isNullXQException(string);
+        return string.equals("UTF8");
+    }
+
+    @Override
+    public boolean isUserDefinedXMLSchemaTypeSupported() throws XQException {
+        isClosedXQException();
+        return true;
+    }
+    
+    private void isClosedXQException() throws XQException {
+        if (connection.isClosed()) {
+            throw new XQException("This connection is closed");
+        }
+    }
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+
+}

=== added file 'swig/xqj/XQPreparedExpression.java'
--- swig/xqj/XQPreparedExpression.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQPreparedExpression.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,675 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.nio.CharBuffer;
+import java.util.TimeZone;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQResultSequence;
+import javax.xml.xquery.XQSequence;
+import javax.xml.xquery.XQSequenceType;
+import javax.xml.xquery.XQStaticContext;
+import org.w3c.dom.Node;
+import org.zorbaxquery.api.XQuery;
+import org.zorbaxquery.api.Zorba;
+import javax.xml.xquery.XQConnection;
+import java.util.Collection;
+import java.util.ArrayList;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXResult;
+import javax.xml.transform.stax.StAXSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.zorbaxquery.api.DynamicContext;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.Iterator;
+import org.zorbaxquery.api.XmlDataManager;
+
+public class XQPreparedExpression implements javax.xml.xquery.XQPreparedExpression {
+
+    private XQuery query;
+    private XQConnection connection;
+    private boolean closed;
+    private Collection<XQResultSequence> resultSequences = new ArrayList<XQResultSequence>();
+    private DynamicContext dynamicContext;
+    private XmlDataManager xmlDataManager;
+    private XQStaticContext staticContext;
+    private Collection<String> itemsBounded = new ArrayList<String>();
+
+    
+    public XQPreparedExpression (XQConnection conn, String string) throws XQException {
+        if (conn.isClosed()) {
+            throw new XQException ("Connection is closed");
+        }
+        closed = false;
+        connection = conn;
+        Zorba zorba = ((org.zorbaxquery.api.xqj.XQConnection)connection).getZorbaInstance(); 
+        try {
+            query =  zorba.compileQuery(string);
+            dynamicContext = query.getDynamicContext();
+            xmlDataManager = ((org.zorbaxquery.api.xqj.XQConnection)connection).getZorbaInstance().getXmlDataManager();
+        } catch (Exception e) {
+            throw new XQException ("Error creating new Prepared expression with static context: " + e.getLocalizedMessage());
+        
+        }
+    }
+    public XQPreparedExpression (XQConnection conn, String string, XQStaticContext sc) throws XQException {
+        if (conn.isClosed()) {
+            throw new XQException ("Connection is closed");
+        }
+        closed = false;
+        connection = conn;
+        Zorba zorba = ((org.zorbaxquery.api.xqj.XQConnection)connection).getZorbaInstance(); 
+        try {
+            query =  zorba.compileQuery(string, ((org.zorbaxquery.api.xqj.XQStaticContext)sc).getZorbaStaticContext());
+            dynamicContext = query.getDynamicContext();
+            xmlDataManager = ((org.zorbaxquery.api.xqj.XQConnection)connection).getZorbaInstance().getXmlDataManager();
+        } catch (Exception e) {
+            throw new XQException ("Error creating new Prepared expression with static context: " + e.getLocalizedMessage());
+        
+        }
+    }
+
+    @Override
+    public void cancel() throws XQException {
+        isClosedXQException();
+        
+    }
+
+    @Override
+    public boolean isClosed() {
+        return closed;
+    }
+
+    @Override
+    public void close() throws XQException {
+        closed = true;
+        for (XQResultSequence sequence: resultSequences) {
+            sequence.close();
+        }
+        if (query!=null) {
+            query.delete();
+        }
+    }
+
+    @Override
+    public XQResultSequence executeQuery() throws XQException {
+        isClosedXQException();
+        XQResultSequence result = null;
+        try {
+            result = new org.zorbaxquery.api.xqj.XQResultSequence(connection, query, true);
+        } catch (Exception e) {
+            throw new XQException("Error executing query: " + e.getLocalizedMessage());
+        }
+        resultSequences.add(result);
+        return result;
+    }
+
+    @Override
+    public QName[] getAllExternalVariables() throws XQException {
+        isClosedXQException();
+        Collection<QName> result = new ArrayList<QName>();
+        Iterator iter = new Iterator();
+        query.getExternalVariables(iter);
+        iter.open();
+        Item item = new Item();
+        while (iter.next(item)) {
+            result.add(new QName(item.getNamespace(), item.getLocalName(), item.getPrefix()));
+        }
+        iter.close();
+        iter.delete();
+        return result.toArray(new QName[0]);
+    }
+
+    
+    private boolean isExternal(String varName) {
+        boolean found=false;
+        Iterator iter = new Iterator();
+        query.getExternalVariables(iter);
+        iter.open();
+        Item item = new Item();
+        while (iter.next(item)) {
+            if (item.getLocalName().equalsIgnoreCase(varName)) {
+                found = true;
+            }
+        }
+        iter.close();
+        iter.delete();
+        return found;
+    }
+    
+    @Override
+    public QName[] getAllUnboundExternalVariables() throws XQException {
+        isClosedXQException();
+        
+        Collection<QName> result = new ArrayList<QName>();
+        Iterator iter = new Iterator();
+        query.getExternalVariables(iter);
+        Item item = new Item();
+        iter.open();
+        while (iter.next(item)) {
+            boolean found = false;
+            for (String key: itemsBounded){
+                if (item.getLocalName().equalsIgnoreCase(key)) {
+                    found = true;
+                }
+            }
+            if (!found) {
+                result.add(new QName(item.getNamespace(), item.getLocalName(), item.getPrefix()));
+            }
+        }
+        iter.close();
+        iter.delete();
+        return result.toArray(new QName[0]);
+    }
+
+    @Override
+    public XQSequenceType getStaticResultType() throws XQException {
+        isClosedXQException();
+        XQSequenceType result = new org.zorbaxquery.api.xqj.XQSequenceType(new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ITEM), XQSequenceType.OCC_ZERO_OR_MORE );
+        return result;
+    }
+
+    @Override
+    public XQSequenceType getStaticVariableType(QName varName) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        XQSequenceType result = null;
+        Iterator iter = new Iterator();
+        query.getExternalVariables(iter);
+        iter.open();
+        Item item = new Item();
+        while (iter.next(item)) {
+            if ( item.getLocalName().equalsIgnoreCase(varName.getLocalPart()) &&
+                 item.getNamespace().equalsIgnoreCase(varName.getNamespaceURI()) &&
+                 item.getPrefix().equalsIgnoreCase(varName.getPrefix()) ) {
+                 if (item.getType().getStringValue().equals("xs:QName")) {
+                     result = new org.zorbaxquery.api.xqj.XQSequenceType(new org.zorbaxquery.api.xqj.XQItemType(XQItemType.XQITEMKIND_ITEM), XQItemType.OCC_ZERO_OR_MORE);
+                 } else {
+                     result = new org.zorbaxquery.api.xqj.XQSequenceType(new org.zorbaxquery.api.xqj.XQItemType(item), XQItemType.OCC_ZERO_OR_MORE);
+                 }
+                 
+            }
+        }
+        iter.close();
+        iter.delete();
+        if (result==null) {
+            throw new XQException("Item not found");
+        }
+        return result;
+    }
+
+    @Override
+    public XQStaticContext getStaticContext() throws XQException {
+        isClosedXQException();
+        if (staticContext==null) {
+            staticContext = new org.zorbaxquery.api.xqj.XQStaticContext(query);
+        }
+        return staticContext;
+    }
+
+    @Override
+    public TimeZone getImplicitTimeZone() throws XQException {
+        isClosedXQException();
+        Integer timeZone = (dynamicContext.getImplicitTimezone()/60); // in minutes
+        TimeZone result = TimeZone.getTimeZone("GMT"+timeZone.toString());
+        return result;
+    }
+
+    @Override
+    public void bindAtomicValue(QName varName, String value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        isNullXQException(type);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        if (type.getItemKind()!=XQItemType.XQITEMKIND_ATOMIC) {
+            throw new XQException ("Item kind is not atomic.");
+        }
+        try {
+            XQItem xqitem = connection.createItemFromAtomicValue(value, type);
+            Item item = ((org.zorbaxquery.api.xqj.XQItem)xqitem).getZorbaItem();
+            dynamicContext.setVariable(varName.getLocalPart(), item);
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding the atomic value: " + e.getLocalizedMessage());
+        }
+        
+    }
+
+    @Override
+    public void bindString(QName varName, String value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        isNullXQException(value);
+        if (type==null) {
+            type = ((org.zorbaxquery.api.xqj.XQConnection)connection).createAtomicType(XQItemType.XQBASETYPE_STRING);
+        }
+        try {
+            Iterator iter = new Iterator();
+            boolean found = false;
+            query.getExternalVariables(iter);
+            Item tmpItem = new Item();
+            iter.open();
+            while (iter.next(tmpItem)) {
+                if (tmpItem.getStringValue().equalsIgnoreCase(varName.getLocalPart())) {
+                    XQItem item = connection.createItemFromString(value, type);
+                    dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+                    itemsBounded.add(varName.getLocalPart());
+                    found=true;
+                }
+            }
+            iter.close();
+            iter.delete();
+            if (!found) {
+                throw new XQException ("The variable: " + varName.getLocalPart() + " doesn't exist.");
+            }
+        } catch (XQException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new XQException ("Error binding string to the defined type: " + e.getLocalizedMessage());
+        }
+        
+    }
+
+    @Override
+    public void bindDocument(QName varName, String value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        isNullXQException(value);
+        if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+            throw new XQException ("Invalid type.");
+        }
+        if (type==null) {
+            type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+        }
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("Variable not found in context.");
+        }
+        try {
+            Iterator iter = xmlDataManager.parseXML(value);
+            Item item = new Item();
+            iter.next(item);
+            dynamicContext.setVariable(varName.getLocalPart(), item);
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding document: " + e.getLocalizedMessage());
+        }
+        
+    }
+
+    @Override
+    public void bindDocument(QName varName, Reader value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        isNullXQException(value);
+        if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+            throw new XQException ("Invalid type.");
+        }
+        if (type==null) {
+            type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+        }
+        StringBuffer string = new StringBuffer();
+        CharBuffer buffer = CharBuffer.allocate(1024);
+        Writer writer = new StringWriter();
+        
+        try {
+            while( value.read(buffer) >= 0 ) {
+                buffer.flip();
+                writer.append(buffer);
+                buffer.clear();
+            }
+            value.close();
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        
+        bindDocument(varName, writer.toString(), baseURI, type);
+    }
+
+    @Override
+    public void bindDocument(QName varName, InputStream value, String baseURI, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        isNullXQException(value);
+        if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+            throw new XQException ("Invalid type.");
+        }
+        if (type==null) {
+            type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+        }
+        StringBuffer  out = new StringBuffer ();
+        try {
+            byte[] b = new byte[4096];
+            for (int n; (n = value.read(b)) != -1;) {
+                out.append(new String(b, 0, n));
+            }
+        } catch (Exception ex) {
+            throw new XQException("Error preparing expression" + ex.getLocalizedMessage());
+        }
+        bindDocument(varName, out.toString(), baseURI, type);
+    }
+
+    @Override
+    public void bindDocument(QName varName, XMLStreamReader value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        isNullXQException(value);
+        if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+            throw new XQException ("Invalid type.");
+        }
+        if (type==null) {
+            type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+        }
+        
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer t;
+        StAXSource source;
+        StAXResult result;
+        XMLOutputFactory xof = XMLOutputFactory.newInstance();
+        Writer writer = new StringWriter();
+        try {
+            XMLStreamWriter xmlStreamWriter =  xof.createXMLStreamWriter(writer);
+            t = tf.newTransformer();
+            source = new StAXSource(value);
+            result = new StAXResult(xmlStreamWriter);
+            t.transform(source, result);        
+        } catch (Exception ex) {
+            throw new XQException("Error transforming xml expression" + ex.getLocalizedMessage());
+        }
+        bindDocument(varName, writer.toString(), null, type);
+    }
+
+    private String nodeToString(Node node) {
+     StringWriter sw = new StringWriter();
+     try {
+       Transformer t = TransformerFactory.newInstance().newTransformer();
+       t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+       t.transform(new DOMSource(node), new StreamResult(sw));
+     } catch (TransformerException te) {
+       System.out.println("nodeToString Transformer Exception" + te.getLocalizedMessage());
+     }
+     return sw.toString();
+    }
+
+    @Override
+    public void bindDocument(QName varName, Source value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        if (!((type==null) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_ELEMENT) || (type.getItemKind()==XQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT))) {
+            throw new XQException ("Invalid type.");
+        }
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        if (type==null) {
+            type = connection.createDocumentElementType(connection.createElementType(null, XQItemType.XQBASETYPE_UNTYPED));
+        }
+        if (value instanceof StreamSource) {
+            bindDocument(varName, ((StreamSource)value).getReader(), null, type);
+        } else if (value instanceof SAXSource) {
+            bindDocument(varName, ((SAXSource)value).getInputSource().getCharacterStream(), null, type);
+        } else if (value instanceof DOMSource) {
+            bindDocument(varName, nodeToString(((DOMSource)value).getNode()), null, type);
+        } else {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+    }
+
+    @Override
+    public void setImplicitTimeZone(TimeZone value) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        try {
+            dynamicContext.setImplicitTimezone((value.getRawOffset()/60000));
+        } catch (Exception e) {
+            throw new XQException("Error setting implicit TimeZone: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindItem(QName varName, XQItem value) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)value).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding item: " + varName.getLocalPart() + " with error: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindSequence(QName varName, XQSequence value) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        if (value.isClosed()) {
+            throw new XQException ("Sequence is closed.");
+        }
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            if (!value.isOnItem()) {
+                value.next();
+            }
+            Item item = new Item(((org.zorbaxquery.api.xqj.XQItem)value.getItem()).getZorbaItem());
+            //Item item2 = new Item(item);
+            //String val = item.getStringValue();
+            dynamicContext.setVariable(varName.getLocalPart(), item);
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding item: " + varName.getLocalPart() + " with error: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindObject(QName varName, Object value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        isNullXQException(value);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromObject(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindBoolean(QName varName, boolean value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromBoolean(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindByte(QName varName, byte value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromByte(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindDouble(QName varName, double value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromDouble(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindFloat(QName varName, float value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromFloat(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindInt(QName varName, int value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromInt(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindLong(QName varName, long value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromLong(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindNode(QName varName, Node value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(value);
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromNode(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public void bindShort(QName varName, short value, XQItemType type) throws XQException {
+        isClosedXQException();
+        isNullXQException(varName);
+        if (!isExternal(varName.getLocalPart())) {
+            throw new XQException ("The bound variable must be declared external in the prepared expression.");
+        }
+        try {
+            XQItem item = connection.createItemFromShort(value, type);
+            dynamicContext.setVariable(varName.getLocalPart(), ((org.zorbaxquery.api.xqj.XQItem)item).getZorbaItem());
+            itemsBounded.add(varName.getLocalPart());
+        } catch (Exception e) {
+            throw new XQException ("Error binding object: " + e.getLocalizedMessage());
+        }
+    }
+
+    private void isClosedXQException() throws XQException {
+        if (closed) {
+            throw new XQException("This prepared expression is closed");
+        }
+    }
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+    
+}

=== added file 'swig/xqj/XQResultItem.java'
--- swig/xqj/XQResultItem.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQResultItem.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQException;
+import org.zorbaxquery.api.Item;
+
+public class XQResultItem extends XQItem implements javax.xml.xquery.XQResultItem {
+
+    private XQConnection connection;
+    
+    
+    public XQResultItem(Item item, XQConnection conn) {
+        super(item);
+        connection = conn;
+    }
+
+    @Override
+    public XQConnection getConnection() throws XQException {
+        if (super.isClosed()) {
+            throw new XQException("Object closed");
+        }
+        return connection;
+    }
+    
+    
+    
+}

=== added file 'swig/xqj/XQResultSequence.java'
--- swig/xqj/XQResultSequence.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQResultSequence.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,464 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.Iterator;
+
+public class XQResultSequence implements javax.xml.xquery.XQResultSequence {
+    
+    private boolean closed = false;
+    private boolean delivered = false;
+    //private boolean isonitem = false;
+    private boolean consumedItem = false;
+    private boolean iterDeleted = false;
+
+    private XQConnection connection = null;
+    private Iterator iter = null;
+    private XQResultItem current = null;
+    private Collection<XQResultItem> items = new ArrayList<XQResultItem>();
+    private org.zorbaxquery.api.XQuery lQuery=null;
+    private boolean preparedExpression;
+
+    public XQResultSequence(XQConnection conn, org.zorbaxquery.api.XQuery query, boolean prepared) {
+        lQuery = query;
+        iter = query.iterator();
+        iter.open();
+        connection = conn;
+        preparedExpression = prepared;
+    }
+    
+    @Override
+    public XQConnection getConnection() throws XQException {
+        isClosedXQException();
+        return connection;
+    }
+
+    @Override
+    public boolean absolute(int i) throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public void afterLast() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public void beforeFirst() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public void close() throws XQException {
+        if (!closed) {
+            closed = true;
+            for (XQResultItem xitem: items){
+                xitem.close();
+            }
+            items.removeAll(items);
+            if (!iterDeleted) {
+                if (iter.isOpen()) {
+                    iter.close();
+                    iter.delete();
+                }
+                if (!preparedExpression) {
+                    lQuery.delete();
+                }
+            }
+        }
+    }
+
+    @Override
+    public boolean isClosed() {
+        return closed;
+    }
+
+    @Override
+    public int count() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public int getPosition() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public boolean isOnItem() throws XQException {
+        isClosedXQException();
+        return (current!=null);
+    }
+
+    @Override
+    public boolean isScrollable() throws XQException {
+        isClosedXQException();
+        return false;
+    }
+
+    @Override
+    public boolean first() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public XQItem getItem() throws XQException {
+        isClosedXQException();
+        isItemDeliveredXQException();
+        isOnItemXQException();
+
+        delivered = true;
+        consumedItem = true;
+        return current;
+    }
+
+    @Override
+    public XMLStreamReader getSequenceAsStream() throws XQException {
+        isClosedXQException();
+        isConsumedXQException();
+        Properties properties = null;
+        String str = getSequenceAsString(properties);
+        XMLInputFactory fac = XMLInputFactory.newInstance();
+        Reader read = new StringReader(str);
+        XMLStreamReader result = null;
+        try {
+            result = fac.createXMLStreamReader(read);
+        } catch (XMLStreamException ex) {
+            throw new XQException("Problem reading the stream: " + str + " - with error: " + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public String getSequenceAsString(Properties prprts) throws XQException {
+        isClosedXQException();
+        isConsumedXQException();
+        String result = null;
+        try {
+        /*
+        if (item.isNode() && item.getNodeKind()==3) { //attribute node
+            resultString = resultString.concat(item.getStringValue()).concat(" ");
+        } else {
+            resultString = resultString.concat(item.serialize().replace("&gt;", ">").replace("&lt;", "<")).concat(" ");
+        }
+         * 
+         */
+            if (iter.isOpen()) {
+                iter.close();
+                iter.delete();
+            }
+            iterDeleted = true;
+            consumedItem = true;
+            result = lQuery.execute().replace("&gt;", ">").replace("&lt;", "<");
+        } catch (Exception e) {
+            throw new XQException("Error getting stream: " + e.getLocalizedMessage());
+        } finally {
+            if (!preparedExpression) {
+                lQuery.delete();
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public boolean isAfterLast() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public boolean isBeforeFirst() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public boolean isFirst() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public boolean isLast() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public boolean last() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public boolean next() throws XQException {
+        isClosedXQException();
+        Item lItem = new Item();
+        current = null;
+        if (iter.next(lItem)) {
+            current = new XQResultItem(lItem, connection);
+            items.add(current);
+            delivered = false;
+            lItem.delete();
+        }
+        return (current != null);
+    }
+
+    @Override
+    public boolean previous() throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public boolean relative(int i) throws XQException {
+        isClosedXQException();
+        throw new XQException("This sequence is forward-only");
+    }
+
+    @Override
+    public void writeSequence(OutputStream out, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(out);
+        if (isOnItem()) {
+            getItem().writeItem(out, prprts);
+        }
+        while (next()) {
+            getItem().writeItem(out, prprts);
+        }
+    }
+
+    @Override
+    public void writeSequence(Writer writer, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(writer);
+        if (isOnItem()) {
+            getItem().writeItem(writer, prprts);
+        }
+        while (next()) {
+            getItem().writeItem(writer, prprts);
+        }
+    }
+
+    @Override
+    public void writeSequenceToSAX(ContentHandler ch) throws XQException {
+        isClosedXQException();
+        isNullXQException(ch);
+        if (isOnItem()) {
+            getItem().writeItemToSAX(ch);
+        }
+        while (next()) {
+            getItem().writeItemToSAX(ch);
+        }
+    }
+
+    @Override
+    public void writeSequenceToResult(Result result) throws XQException {
+        isClosedXQException();
+        isNullXQException(result);
+        if (isOnItem()) {
+            getItem().writeItemToResult(result);
+        }
+        while (next()) {
+            getItem().writeItemToResult(result);
+        }
+    }
+
+    @Override
+    public boolean getBoolean() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getBoolean();
+    }
+
+    @Override
+    public byte getByte() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getByte();
+    }
+
+    @Override
+    public double getDouble() throws XQException {
+        isClosedXQException();
+        
+        return getItem().getDouble();
+    }
+
+    @Override
+    public float getFloat() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getFloat();
+    }
+
+    @Override
+    public int getInt() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getInt();
+    }
+
+    @Override
+    public XQItemType getItemType() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return current.getItemType();
+    }
+
+    @Override
+    public String getAtomicValue() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getAtomicValue();
+    }
+
+    @Override
+    public long getLong() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getLong();
+    }
+
+    @Override
+    public Node getNode() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getNode();
+    }
+
+    @Override
+    public URI getNodeUri() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return current.getNodeUri();
+    }
+
+    @Override
+    public Object getObject() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getObject();
+    }
+
+    @Override
+    public XMLStreamReader getItemAsStream() throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        return getItem().getItemAsStream();
+    }
+
+    @Override
+    public String getItemAsString(Properties prprts) throws XQException {
+        isClosedXQException();
+        return getItem().getItemAsString(prprts);
+    }
+
+    @Override
+    public short getShort() throws XQException {
+        isClosedXQException();
+        return getItem().getShort();
+    }
+
+    @Override
+    public boolean instanceOf(XQItemType xqit) throws XQException {
+        isClosedXQException();
+        isOnItemXQException();
+        isNullXQException(xqit);
+        return current.instanceOf(xqit);
+    }
+
+    @Override
+    public void writeItem(OutputStream out, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(out);
+        isNullXQException(prprts);
+        getItem().writeItem(out, prprts);
+    }
+
+    @Override
+    public void writeItem(Writer writer, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(writer);
+        isNullXQException(prprts);
+        getItem().writeItem(writer, prprts);
+    }
+
+    @Override
+    public void writeItemToSAX(ContentHandler ch) throws XQException {
+        isClosedXQException();
+        isNullXQException(ch);
+        getItem().writeItemToSAX(ch);
+    }
+
+    @Override
+    public void writeItemToResult(Result result) throws XQException {
+        isClosedXQException();
+        isNullXQException(result);
+        getItem().writeItemToResult(result);
+    }
+    
+    private void isClosedXQException() throws XQException {
+        if (closed) {
+            throw new XQException("This sequence is closed");
+        }
+    }
+    private void isConsumedXQException() throws XQException {
+        if (consumedItem) {
+            throw new XQException("Items already consumed");
+        }
+    }
+    private void isItemDeliveredXQException() throws XQException {
+        if (delivered) {
+            throw new XQException("Item already consumed");
+        }
+    }
+    private void isOnItemXQException() throws XQException {
+        if (current==null) {
+            throw new XQException("There are no more items to consume");
+        }
+    }
+
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+}

=== added file 'swig/xqj/XQResultSequenceScrollable.java'
--- swig/xqj/XQResultSequenceScrollable.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQResultSequenceScrollable.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,464 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQResultItem;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.zorbaxquery.api.Item;
+import org.zorbaxquery.api.Iterator;
+
+public class XQResultSequenceScrollable implements javax.xml.xquery.XQResultSequence {
+
+    private boolean closed = false;
+    private boolean forwardOnly = false;
+    private boolean currentItemGet = false;
+    private Collection<XQResultItem> content = new ArrayList<XQResultItem>();
+    private int position = 0;
+    int size = 0;
+    private XQConnection connection = null;
+    boolean preparedExpression;
+
+    public XQResultSequenceScrollable(XQConnection conn, org.zorbaxquery.api.XQuery query, boolean prepared) {
+        Iterator iter;
+        iter = query.iterator();
+        iter.open();
+        Item item = new Item();
+        while (iter.next(item)) {
+            XQResultItem rItem = new org.zorbaxquery.api.xqj.XQResultItem(item, conn);
+            content.add(rItem);
+        }
+        iter.close();
+        iter.delete();
+        size = content.size();
+        connection = conn;
+        preparedExpression = prepared;
+    }
+
+    @Override
+    public boolean absolute(int i) throws XQException {
+        isClosedXQException();
+        boolean result  = false;
+        position = 0;
+        if (size>0) {
+            if (i>0) {
+                if (i>size) {
+                    position = size+1;
+                } else {
+                    position = i;
+                    result = true;
+                }
+            } else if(i<0) {
+                if (i>(-size)) {
+                    position = size+i+1;
+                    result = true;
+                }
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void afterLast() throws XQException {
+        isClosedXQException();
+        position = size+1;
+    }
+
+    @Override
+    public void beforeFirst() throws XQException {
+        isClosedXQException();
+        position = 0;
+    }
+
+    @Override
+    public void close() throws XQException {
+        closed = true;
+        for (XQItem item: content) {
+            item.close();
+        }
+    }
+
+    @Override
+    public boolean isClosed() {
+        return closed;
+    }
+
+    @Override
+    public int count() throws XQException {
+        isClosedXQException();
+        return size;
+    }
+
+    @Override
+    public int getPosition() throws XQException {
+        isClosedXQException();
+        return position;
+    }
+
+    @Override
+    public boolean isOnItem() throws XQException {
+        isClosedXQException();
+        return (position>0) && (position<(content.size()+1));
+    }
+
+    @Override
+    public boolean isScrollable() throws XQException {
+        isClosedXQException();
+        return !forwardOnly;
+    }
+
+    @Override
+    public boolean first() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (content.size()>0) {
+            position = 1;
+            result = true;
+        }
+        return result;
+    }
+
+    @Override
+    public XQItem getItem() throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        return (XQItem)content.toArray()[position-1];
+    }
+
+    @Override
+    public XMLStreamReader getSequenceAsStream() throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        StringBuffer sb = new StringBuffer();
+        for (XQItem item: content) {
+            sb.append(item.getItemAsString(null));
+        }
+        XMLInputFactory fac = XMLInputFactory.newInstance();
+        Reader read = new StringReader(sb.toString());
+        XMLStreamReader result = null;
+        try {
+            result = fac.createXMLStreamReader(read);
+        } catch (XMLStreamException ex) {
+            throw new XQException("Problem reading the stream: " + sb + " - with error: " + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public String getSequenceAsString(Properties prprts) throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        StringBuffer sb = new StringBuffer();
+        for (XQItem item: content) {
+            sb.append(item.getItemAsString(null));
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public boolean isAfterLast() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (size>0) {
+            result = position==size+1;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean isBeforeFirst() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (content.size()>0) {
+            result = position==0;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean isFirst() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (content.size()>0) {
+            result = position==1;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean isLast() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (size>0) {
+            result = position==size;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean last() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (size>0) {
+            position = size;
+            result = true;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean next() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if ((position<=size) && (size>0)) {
+            result = (position<size);
+            position++;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean previous() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if ((position>0) && (size>0)) {
+            result = (position>1);
+            position--;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean relative(int i) throws XQException {
+        isClosedXQException();
+        boolean result  = false;
+        if ((i!=0) && (size>0)) {
+            position = position + i;
+            if (position<0) {
+                position = 0;
+            } else if (position>size) {
+                position=size+1;
+            } else {
+                result = true;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void writeSequence(OutputStream out, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(out);
+        if (isOnItem()) {
+            getItem().writeItem(out, prprts);
+        }
+        while (next()) {
+            getItem().writeItem(out, prprts);
+        }
+    }
+
+    @Override
+    public void writeSequence(Writer writer, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(writer);
+        if (isOnItem()) {
+            getItem().writeItem(writer, prprts);
+        }
+        while (next()) {
+            getItem().writeItem(writer, prprts);
+        }
+    }
+
+    @Override
+    public void writeSequenceToSAX(ContentHandler ch) throws XQException {
+        isClosedXQException();
+        isNullXQException(ch);
+        if (isOnItem()) {
+            getItem().writeItemToSAX(ch);
+        }
+        while (next()) {
+            getItem().writeItemToSAX(ch);
+        }
+    }
+
+    @Override
+    public void writeSequenceToResult(Result result) throws XQException {
+        isClosedXQException();
+        isNullXQException(result);
+        if (isOnItem()) {
+            getItem().writeItemToResult(result);
+        }
+        while (next()) {
+            getItem().writeItemToResult(result);
+        }
+    }
+
+    @Override
+    public boolean getBoolean() throws XQException {
+        isClosedXQException();
+        return getItem().getBoolean();
+    }
+
+    @Override
+    public byte getByte() throws XQException {
+        isClosedXQException();
+        return getItem().getByte();
+    }
+
+    @Override
+    public double getDouble() throws XQException {
+        isClosedXQException();
+        return getItem().getDouble();
+    }
+
+    @Override
+    public float getFloat() throws XQException {
+        isClosedXQException();
+        return getItem().getFloat();
+    }
+
+    @Override
+    public int getInt() throws XQException {
+        isClosedXQException();
+        return getItem().getInt();
+    }
+
+    @Override
+    public XQItemType getItemType() throws XQException {
+        isClosedXQException();
+        return getItem().getItemType();
+    }
+
+    @Override
+    public String getAtomicValue() throws XQException {
+        isClosedXQException();
+        return getItem().getAtomicValue();
+    }
+
+    @Override
+    public long getLong() throws XQException {
+        isClosedXQException();
+        return getItem().getLong();
+    }
+
+    @Override
+    public Node getNode() throws XQException {
+        isClosedXQException();
+        return getItem().getNode();
+    }
+
+    @Override
+    public URI getNodeUri() throws XQException {
+        isClosedXQException();
+        return getItem().getNodeUri();
+    }
+
+    @Override
+    public Object getObject() throws XQException {
+        isClosedXQException();
+        return getItem().getObject();
+    }
+
+    @Override
+    public XMLStreamReader getItemAsStream() throws XQException {
+        isClosedXQException();
+        return getItem().getItemAsStream();
+    }
+
+    @Override
+    public String getItemAsString(Properties prprts) throws XQException {
+        return getItem().getItemAsString(prprts);
+    }
+
+    @Override
+    public short getShort() throws XQException {
+        isClosedXQException();
+        return getItem().getShort();
+    }
+
+    @Override
+    public boolean instanceOf(XQItemType xqit) throws XQException {
+        isClosedXQException();
+        isNullXQException(xqit);
+        return getItem().instanceOf(xqit);
+    }
+
+    @Override
+    public void writeItem(OutputStream out, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(out);
+        getItem().writeItem(out, prprts);
+    }
+
+    @Override
+    public void writeItem(Writer writer, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(writer);
+        getItem().writeItem(writer, prprts);
+    }
+
+    @Override
+    public void writeItemToSAX(ContentHandler ch) throws XQException {
+        isClosedXQException();
+        isNullXQException(ch);
+        getItem().writeItemToSAX(ch);
+    }
+
+    @Override
+    public void writeItemToResult(Result result) throws XQException {
+        isClosedXQException();
+        isNullXQException(result);
+        getItem().writeItemToResult(result);
+    }
+
+    private void isClosedXQException() throws XQException {
+        if (closed) {
+            throw new XQException("This sequence is closed");
+        }
+    }
+    private void isItemGetXQException() throws XQException {
+        if (forwardOnly && currentItemGet) {
+            throw new XQException("Item already consumed on a forward-only sequence");
+        }
+    }
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+
+
+    @Override
+    public XQConnection getConnection() throws XQException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+}

=== added file 'swig/xqj/XQSequence.java'
--- swig/xqj/XQSequence.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQSequence.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,471 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.zorbaxquery.api.Item;
+
+public class XQSequence implements javax.xml.xquery.XQSequence {
+
+    private boolean closed = false;
+    private boolean forwardOnly = true;
+    private boolean currentItemGet = false;
+    private Collection<XQItem> content = new ArrayList<XQItem>();
+    private int position = 0;
+    int size = 0;
+
+    public XQSequence(javax.xml.xquery.XQSequence sequence) throws XQException {
+        try {
+            while (sequence.next()) {
+                XQItem tmpItem = sequence.getItem();
+                Item item = null;
+                if (tmpItem instanceof XQItem) {
+                    item = ((org.zorbaxquery.api.xqj.XQItem)tmpItem).getZorbaItem();
+                } else if (tmpItem instanceof XQResultItem) {
+                    item = ((org.zorbaxquery.api.xqj.XQResultItem)tmpItem).getZorbaItem();
+                }
+                content.add(new org.zorbaxquery.api.xqj.XQItem(item));
+            }
+            size = content.size();
+        } catch (Exception e) {
+            throw new XQException("Error iterating from origin object" + e.getLocalizedMessage());
+        }
+        
+    }
+
+    public XQSequence(java.util.Iterator iterator) {
+        while (iterator.hasNext()) {
+            Object o = iterator.next();
+            if (o instanceof XQItem) {
+                content.add((XQItem)o);
+            }
+        }
+        size = content.size();
+    }
+
+    @Override
+    public boolean absolute(int i) throws XQException {
+        isClosedXQException();
+        boolean result  = false;
+        position = 0;
+        if (size>0) {
+            if (i>0) {
+                if (i>size) {
+                    position = size+1;
+                } else {
+                    position = i;
+                    result = true;
+                }
+            } else if(i<0) {
+                if (i>(-size)) {
+                    position = size+i+1;
+                    result = true;
+                }
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void afterLast() throws XQException {
+        isClosedXQException();
+        position = content.size()+1;
+    }
+
+    @Override
+    public void beforeFirst() throws XQException {
+        isClosedXQException();
+        position = 0;
+    }
+
+    @Override
+    public void close() throws XQException {
+        closed = true;
+        for (XQItem item: content) {
+            item.close();
+        }
+    }
+
+    @Override
+    public boolean isClosed() {
+        return closed;
+    }
+
+    @Override
+    public int count() throws XQException {
+        isClosedXQException();
+        return size;
+    }
+
+    @Override
+    public int getPosition() throws XQException {
+        isClosedXQException();
+        return position;
+    }
+
+    @Override
+    public boolean isOnItem() throws XQException {
+        isClosedXQException();
+        return (position>0) && (position<(content.size()+1));
+    }
+
+    @Override
+    public boolean isScrollable() throws XQException {
+        isClosedXQException();
+        return !forwardOnly;
+    }
+
+    @Override
+    public boolean first() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (content.size()>0) {
+            position = 1;
+            result = true;
+        }
+        return result;
+    }
+
+    @Override
+    public XQItem getItem() throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        return (XQItem)content.toArray()[position-1];
+    }
+
+    @Override
+    public XMLStreamReader getSequenceAsStream() throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        StringBuffer sb = new StringBuffer();
+        for (XQItem item: content) {
+            sb.append(item.getItemAsString(null));
+        }
+        XMLInputFactory fac = XMLInputFactory.newInstance();
+        Reader read = new StringReader(sb.toString());
+        XMLStreamReader result = null;
+        try {
+            result = fac.createXMLStreamReader(read);
+        } catch (XMLStreamException ex) {
+            throw new XQException("Problem reading the stream: " + sb + " - with error: " + ex.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public String getSequenceAsString(Properties prprts) throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        StringBuffer sb = new StringBuffer();
+        for (XQItem item: content) {
+            sb.append(item.getItemAsString(null));
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public boolean isAfterLast() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (size>0) {
+            result = position==size+1;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean isBeforeFirst() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (content.size()>0) {
+            result = position==0;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean isFirst() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (content.size()>0) {
+            result = position==1;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean isLast() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (size>0) {
+            result = position==size;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean last() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if (size>0) {
+            position = size;
+            result = true;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean next() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if ((position<=size) && (size>0)) {
+            result = (position<size);
+            position++;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean previous() throws XQException {
+        isClosedXQException();
+        boolean result = false;
+        if ((position>0) && (size>0)) {
+            result = (position>1);
+            position--;
+        }
+        return result;
+    }
+
+    @Override
+    public boolean relative(int i) throws XQException {
+        isClosedXQException();
+        boolean result  = false;
+        if ((i!=0) && (size>0)) {
+            position = position + i;
+            if (position<0) {
+                position = 0;
+            } else if (position>size) {
+                position=size+1;
+            } else {
+                result = true;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void writeSequence(OutputStream out, Properties prprts) throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        isNullXQException(out);
+        if (isOnItem()) {
+            getItem().writeItem(out, prprts);
+        }
+        while (next()) {
+            getItem().writeItem(out, prprts);
+        }
+    }
+
+    @Override
+    public void writeSequence(Writer writer, Properties prprts) throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        isNullXQException(writer);
+        if (isOnItem()) {
+            getItem().writeItem(writer, prprts);
+        }
+        while (next()) {
+            getItem().writeItem(writer, prprts);
+        }
+    }
+
+    @Override
+    public void writeSequenceToSAX(ContentHandler ch) throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        isNullXQException(ch);
+        if (isOnItem()) {
+            getItem().writeItemToSAX(ch);
+        }
+        while (next()) {
+            getItem().writeItemToSAX(ch);
+        }
+    }
+
+    @Override
+    public void writeSequenceToResult(Result result) throws XQException {
+        isClosedXQException();
+        isItemGetXQException();
+        isNullXQException(result);
+        if (isOnItem()) {
+            getItem().writeItemToResult(result);
+        }
+        while (next()) {
+            getItem().writeItemToResult(result);
+        }
+    }
+
+    @Override
+    public boolean getBoolean() throws XQException {
+        isClosedXQException();
+        return getItem().getBoolean();
+    }
+
+    @Override
+    public byte getByte() throws XQException {
+        isClosedXQException();
+        return getItem().getByte();
+    }
+
+    @Override
+    public double getDouble() throws XQException {
+        isClosedXQException();
+        return getItem().getDouble();
+    }
+
+    @Override
+    public float getFloat() throws XQException {
+        isClosedXQException();
+        return getItem().getFloat();
+    }
+
+    @Override
+    public int getInt() throws XQException {
+        isClosedXQException();
+        return getItem().getInt();
+    }
+
+    @Override
+    public XQItemType getItemType() throws XQException {
+        isClosedXQException();
+        return getItem().getItemType();
+    }
+
+    @Override
+    public String getAtomicValue() throws XQException {
+        isClosedXQException();
+        return getItem().getAtomicValue();
+    }
+
+    @Override
+    public long getLong() throws XQException {
+        isClosedXQException();
+        return getItem().getLong();
+    }
+
+    @Override
+    public Node getNode() throws XQException {
+        isClosedXQException();
+        return getItem().getNode();
+    }
+
+    @Override
+    public URI getNodeUri() throws XQException {
+        isClosedXQException();
+        return getItem().getNodeUri();
+    }
+
+    @Override
+    public Object getObject() throws XQException {
+        isClosedXQException();
+        return getItem().getObject();
+    }
+
+    @Override
+    public XMLStreamReader getItemAsStream() throws XQException {
+        isClosedXQException();
+        return getItem().getItemAsStream();
+    }
+
+    @Override
+    public String getItemAsString(Properties prprts) throws XQException {
+        isClosedXQException();
+        return getItem().getItemAsString(prprts);
+    }
+
+    @Override
+    public short getShort() throws XQException {
+        isClosedXQException();
+        return getItem().getShort();
+    }
+
+    @Override
+    public boolean instanceOf(XQItemType xqit) throws XQException {
+        isClosedXQException();
+        isNullXQException(xqit);
+        return getItem().instanceOf(xqit);
+    }
+
+    @Override
+    public void writeItem(OutputStream out, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(out);
+        getItem().writeItem(out, prprts);
+    }
+
+    @Override
+    public void writeItem(Writer writer, Properties prprts) throws XQException {
+        isClosedXQException();
+        isNullXQException(writer);
+        getItem().writeItem(writer, prprts);
+    }
+
+    @Override
+    public void writeItemToSAX(ContentHandler ch) throws XQException {
+        isClosedXQException();
+        isNullXQException(ch);
+        getItem().writeItemToSAX(ch);
+    }
+
+    @Override
+    public void writeItemToResult(Result result) throws XQException {
+        isClosedXQException();
+        isNullXQException(result);
+        getItem().writeItemToResult(result);
+    }
+
+    private void isClosedXQException() throws XQException {
+        if (closed) {
+            throw new XQException("This sequence is closed");
+        }
+    }
+    private void isItemGetXQException() throws XQException {
+        if (forwardOnly && currentItemGet) {
+            throw new XQException("Item already consumed on a forward-only sequence");
+        }
+    }
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+}

=== added file 'swig/xqj/XQSequenceType.java'
--- swig/xqj/XQSequenceType.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQSequenceType.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import javax.xml.xquery.XQItemType;
+
+
+public class XQSequenceType implements javax.xml.xquery.XQSequenceType {
+
+    XQItemType type;
+    int occurence;
+    
+    public XQSequenceType(XQItemType type, int occurence) {
+        this.type = type;
+        this.occurence = occurence;
+    }
+    
+    @Override
+    public XQItemType getItemType() {
+        return type;
+    }
+
+    @Override
+    public int getItemOccurrence() {
+        return occurence;
+    }
+    
+    @Override
+    public String toString() {
+        StringBuffer result = new StringBuffer();
+
+        try {
+
+            result.append(type.toString());
+            
+            for (java.lang.reflect.Field field: XQSequenceType.class.getFields()) {
+                if (field.getName().startsWith("OCC_")) {
+                    if (field.getInt(this)==occurence) {
+                        result.append("Ocurrence: ").append(field.getName().substring(4));
+                    }
+                }
+            }
+        } catch (Exception e){
+            result.append("Sequence Type error: ").append(e.getLocalizedMessage());
+        }
+
+        return result.toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        boolean result = false;
+        if (o instanceof XQSequenceType) {
+            result = (occurence != XQSequenceType.OCC_EMPTY) && 
+                     (type.equals(((XQSequenceType)o).getItemType())) && 
+                     (occurence == ((XQSequenceType)o).getItemOccurrence());
+        }
+        return result;
+    }
+
+    @Override
+    public int hashCode() {
+        int hashCode;
+        if (occurence == XQSequenceType.OCC_EMPTY) {
+            hashCode = 1; 
+        } else {
+            hashCode = occurence * 31 + type.hashCode();
+        }
+        return hashCode;
+    }
+
+}

=== added file 'swig/xqj/XQStaticContext.java'
--- swig/xqj/XQStaticContext.java	1970-01-01 00:00:00 +0000
+++ swig/xqj/XQStaticContext.java	2012-03-26 23:10:25 +0000
@@ -0,0 +1,427 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+package org.zorbaxquery.api.xqj;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.xquery.XQConstants;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItemType;
+import org.zorbaxquery.api.StaticContext;
+import org.zorbaxquery.api.StringPair;
+import org.zorbaxquery.api.StringPairVector;
+import org.zorbaxquery.api.StringVector;
+import org.zorbaxquery.api.XQuery;
+import org.zorbaxquery.api.Zorba;
+import org.zorbaxquery.api.ZorbaConstants.BoundarySpaceMode;
+import org.zorbaxquery.api.ZorbaConstants.ConstructionMode;
+import org.zorbaxquery.api.ZorbaConstants.InheritMode;
+import org.zorbaxquery.api.ZorbaConstants.OrderEmptyMode;
+import org.zorbaxquery.api.ZorbaConstants.OrderingMode;
+import org.zorbaxquery.api.ZorbaConstants.PreserveMode;
+
+public class XQStaticContext implements javax.xml.xquery.XQStaticContext {
+
+    
+    private StaticContext staticContext;
+    private int scrollability = XQConstants.SCROLLTYPE_FORWARD_ONLY;
+    private int holdability = XQConstants.HOLDTYPE_CLOSE_CURSORS_AT_COMMIT;
+    private int queryLang = XQConstants.LANGTYPE_XQUERY;
+    private int binding = XQConstants.BINDING_MODE_IMMEDIATE;
+    Map<String, String> namespaces = new HashMap<String, String>();
+    private StringVector uriPaths;
+    private StringVector libPaths;
+    private StringVector modulePaths;
+
+    private Zorba zorba;
+    private XQuery query;
+    
+    String baseURI = null;  //Patch for Zorba, bug filed on https://bugs.launchpad.net/zorba/+bug/905028
+    XQItemType contextItemStaticType = null; //Patch for Zorba, TypeIdentifier is not complete
+    protected StaticContext getZorbaStaticContext() {
+      return staticContext;
+    }
+            
+    public XQStaticContext(Zorba aZorba) {
+        zorba = aZorba;
+        staticContext = zorba.createStaticContext();
+        if (uriPaths!=null) {
+            staticContext.setURIPath(uriPaths);
+        }
+    }
+    public XQStaticContext(XQuery aQuery) {
+        query = aQuery;
+        staticContext = query.getStaticContext();
+        if (uriPaths!=null) {
+            staticContext.setURIPath(uriPaths);
+        }
+    }
+
+    protected void setURIPaths(StringVector aURIPath) {
+        uriPaths = aURIPath;
+        if (staticContext!=null) {
+            staticContext.setURIPath(uriPaths);
+        }
+    }
+    protected void setLIBPaths(StringVector aLIBPath) {
+        libPaths = aLIBPath;
+        if (staticContext!=null) {
+            staticContext.setLIBPath(libPaths);
+        }
+    }
+    protected void setMODPaths(StringVector aMODPath) {
+        modulePaths = aMODPath;
+        if (staticContext!=null) {
+            staticContext.setModulePath(modulePaths);
+        }
+    }
+            
+    @Override
+    public String[] getNamespacePrefixes() {
+        
+        StringPairVector bindings = staticContext.getNamespaceBindings();
+        Collection<String> stringBindings = new ArrayList<String>();
+        int size= (int) bindings.size();
+        for (int i=0; i<size; i++) {
+            StringPair pair = bindings.get(i);
+            stringBindings.add(pair.getFirst());
+        }
+        return stringBindings.toArray(new String[0]);
+    }
+
+    @Override
+    public String getNamespaceURI(String prefix) throws XQException {
+        isNullXQException(prefix);
+        String result = null;
+        try {
+            result = staticContext.getNamespaceURIByPrefix(prefix);
+        } catch (Exception e) {
+            throw new XQException("Error getting Namespace URI" + e.getLocalizedMessage());
+        }
+        return result;
+    }
+
+    @Override
+    public void declareNamespace(String prefix, String URI) throws XQException {
+        isNullXQException(prefix);
+        isNullXQException(URI);
+        try {
+            if ((URI.isEmpty()) && (namespaces.containsKey(prefix))) {
+                namespaces.remove(prefix);
+                StaticContext sc = null;
+                if (zorba==null) {
+                    sc = query.getStaticContext();
+                } else {
+                    sc = zorba.createStaticContext();
+                }
+                StringPairVector scNamespaces = sc.getNamespaceBindings();
+                int scNamespacesSize = (int) scNamespaces.size();
+                
+                for (String key: namespaces.keySet()) {
+                    Boolean found = false;
+                    for (int i = 0; i<scNamespacesSize; i++) {
+                        StringPair pair = scNamespaces.get(i);
+                        if (key.equalsIgnoreCase(pair.getFirst())) {
+                            found = true;
+                        }
+                    }
+                    if (!found) {
+                        sc.addNamespace(key, namespaces.get(key));
+                    }
+                }
+                staticContext = sc;
+                 
+            } else {
+                staticContext.addNamespace(prefix, URI);
+                namespaces.put(prefix, URI);
+            }
+        } catch (Exception e) {
+            throw new XQException("Error declaring namespace on static context:" + e.getLocalizedMessage());
+        }
+    }
+
+    @Override
+    public String getDefaultElementTypeNamespace() {
+        return staticContext.getDefaultElementAndTypeNamespace();
+    }
+
+    @Override
+    public void setDefaultElementTypeNamespace(String URI) throws XQException {
+        isNullXQException(URI);
+        staticContext.setDefaultElementAndTypeNamespace(URI);
+    }
+
+    @Override
+    public String getDefaultFunctionNamespace() {
+        return staticContext.getDefaultFunctionNamespace();
+    }
+
+    @Override
+    public void setDefaultFunctionNamespace(String URI) throws XQException {
+        isNullXQException(URI);
+        staticContext.setDefaultFunctionNamespace(URI);
+    }
+
+    @Override
+    public XQItemType getContextItemStaticType() {
+        //not very complete implementation
+        //TypeIdentifier type = staticContext.getContextItemStaticType();
+        return contextItemStaticType;
+    }
+
+    @Override
+    public void setContextItemStaticType(XQItemType xqit) throws XQException {
+        contextItemStaticType = xqit;
+        if (xqit instanceof XQItemType) {
+            org.zorbaxquery.api.xqj.XQItemType wrapper = (org.zorbaxquery.api.xqj.XQItemType) xqit;
+            staticContext.setContextItemStaticType(wrapper.getTypeIdentifier());
+        }
+    }
+
+    @Override
+    public String getDefaultCollation() {
+        return staticContext.getDefaultCollation();
+    }
+
+    @Override
+    public void setDefaultCollation(String URI) throws XQException {
+        isNullXQException(URI);
+        staticContext.setDefaultCollation(URI);
+    }
+
+    @Override
+    public int getConstructionMode() {
+        int result = XQConstants.CONSTRUCTION_MODE_PRESERVE;
+        int mode = staticContext.getConstructionMode();
+        if (mode == ConstructionMode.STRIP_CONSTRUCTION) {
+            result = XQConstants.CONSTRUCTION_MODE_STRIP;
+        }
+        return result;
+    }
+
+    @Override
+    public void setConstructionMode(int i) throws XQException {
+        if (!((i==XQConstants.CONSTRUCTION_MODE_PRESERVE) || (i==XQConstants.CONSTRUCTION_MODE_STRIP))) {
+            throw new XQException("Invalid construction mode.");
+        }
+        int mode = ConstructionMode.STRIP_CONSTRUCTION;
+        if (i==XQConstants.CONSTRUCTION_MODE_PRESERVE) {
+            mode = ConstructionMode.PRESERVE_CONSTRUCTION;
+        }
+        staticContext.setConstructionMode(mode);
+    }
+
+    @Override
+    public int getOrderingMode() {
+        int result = XQConstants.ORDERING_MODE_ORDERED;
+        int mode = staticContext.getOrderingMode();
+        if (mode == OrderingMode.UNORDERED) {
+            result = XQConstants.ORDERING_MODE_UNORDERED;
+        }
+        return result;
+    }
+
+    @Override
+    public void setOrderingMode(int i) throws XQException {
+        if (!((i==XQConstants.ORDERING_MODE_ORDERED) || (i==XQConstants.ORDERING_MODE_UNORDERED))) {
+            throw new XQException("Invalid ordering mode.");
+        }
+        int mode = OrderingMode.ORDERED;
+        if (i==XQConstants.ORDERING_MODE_UNORDERED) {
+            mode = OrderingMode.UNORDERED;
+        }
+        staticContext.setOrderingMode(mode);
+    }
+
+    @Override
+    public int getDefaultOrderForEmptySequences() {
+        int result = XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST;
+        int order = staticContext.getDefaultOrderForEmptySequences();
+        if (order == OrderEmptyMode.EMPTY_LEAST) {
+            result = XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST;
+        }
+        return result;
+    }
+
+    @Override
+    public void setDefaultOrderForEmptySequences(int i) throws XQException {
+        if  (!((i == XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST) || (i==XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST))) {
+            throw new XQException("Invalid order specified.");
+        }
+        int result = OrderEmptyMode.EMPTY_GREATEST;
+        if (i == XQConstants.DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST) {
+            result = OrderEmptyMode.EMPTY_LEAST;
+        }
+        staticContext.setDefaultOrderForEmptySequences(result);
+    }
+
+    @Override
+    public int getBoundarySpacePolicy() {
+        int result = XQConstants.BOUNDARY_SPACE_PRESERVE;
+        int boundary = staticContext.getBoundarySpacePolicy();
+        if (boundary == BoundarySpaceMode.STRIP_SPACE) {
+            result = XQConstants.BOUNDARY_SPACE_STRIP;
+        }
+        return result;
+    }
+
+    @Override
+    public void setBoundarySpacePolicy(int i) throws XQException {
+        if  (!((i == XQConstants.BOUNDARY_SPACE_PRESERVE) || (i==XQConstants.BOUNDARY_SPACE_STRIP))) {
+            throw new XQException("Invalid boundary specified.");
+        }
+        int result = BoundarySpaceMode.PRESERVE_SPACE;
+        if (i == XQConstants.BOUNDARY_SPACE_STRIP) {
+            result = BoundarySpaceMode.STRIP_SPACE;
+        }
+        staticContext.setBoundarySpacePolicy(result);
+    }
+
+    @Override
+    public int getCopyNamespacesModePreserve() {
+        int result = XQConstants.COPY_NAMESPACES_MODE_NO_PRESERVE;
+        int preserve = staticContext.getCopyNamespacesModePreserve();
+        if (preserve == PreserveMode.PRESERVE) {
+            result = XQConstants.COPY_NAMESPACES_MODE_PRESERVE;
+        }
+        return result;
+    }
+
+    @Override
+    public void setCopyNamespacesModePreserve(int i) throws XQException {
+        if (!((i==XQConstants.COPY_NAMESPACES_MODE_PRESERVE) || (i==XQConstants.COPY_NAMESPACES_MODE_NO_PRESERVE))) {
+          throw new XQException("The specified mode is invalid.");
+        }
+        int inherit = staticContext.getCopyNamespacesModeInherit();
+        int preserve = PreserveMode.NO_PRESERVE;
+        if (i==XQConstants.COPY_NAMESPACES_MODE_PRESERVE) {
+            preserve = PreserveMode.PRESERVE;
+        }
+        staticContext.setCopyNamespacesMode(preserve, inherit);
+    }
+
+    @Override
+    public int getCopyNamespacesModeInherit() {
+        int result = XQConstants.COPY_NAMESPACES_MODE_NO_INHERIT;
+        int inherit = staticContext.getCopyNamespacesModeInherit();
+        if (inherit == InheritMode.INHERIT) {
+            result = XQConstants.COPY_NAMESPACES_MODE_INHERIT;
+        }
+        return result;
+    }
+
+    @Override
+    public void setCopyNamespacesModeInherit(int i) throws XQException {
+        if (!((i==XQConstants.COPY_NAMESPACES_MODE_INHERIT) || (i==XQConstants.COPY_NAMESPACES_MODE_NO_INHERIT))) {
+          throw new XQException("The specified mode is invalid.");
+        }
+        int preserve = staticContext.getCopyNamespacesModePreserve();
+        int inherit = InheritMode.NO_INHERIT;
+        if (i==XQConstants.COPY_NAMESPACES_MODE_INHERIT) {
+            inherit = InheritMode.INHERIT;
+        }
+        staticContext.setCopyNamespacesMode(preserve, inherit);
+    }
+
+    @Override
+    public String getBaseURI() {
+        if (baseURI==null) {
+            return staticContext.getBaseURI();
+        } else {
+            return baseURI;
+        }
+    }
+
+    @Override
+    public void setBaseURI(String URI) throws XQException {
+        isNullXQException(URI);
+        staticContext.setBaseURI(URI);
+        baseURI = URI;
+    }
+
+    @Override
+    public int getBindingMode() {
+        return binding;
+    }
+
+    @Override
+    public void setBindingMode(int i) throws XQException {
+        if (!((i==XQConstants.BINDING_MODE_DEFERRED) || (i==XQConstants.BINDING_MODE_IMMEDIATE))) {
+          throw new XQException("The specified mode is invalid.");
+        }
+        binding = i;
+    }
+
+    @Override
+    public int getHoldability() {
+        return holdability;
+    }
+
+    @Override
+    public void setHoldability(int i) throws XQException {
+        if (!((i==XQConstants.HOLDTYPE_HOLD_CURSORS_OVER_COMMIT) || (i==XQConstants.HOLDTYPE_CLOSE_CURSORS_AT_COMMIT))) {
+            throw new XQException ("Invalid holdability parameter.");
+        }
+        holdability = i;
+    }
+
+    @Override
+    public int getQueryLanguageTypeAndVersion() {
+        return queryLang;
+    }
+
+    @Override
+    public void setQueryLanguageTypeAndVersion(int i) throws XQException {
+        if (!((i==XQConstants.LANGTYPE_XQUERY) || (i==XQConstants.LANGTYPE_XQUERYX))) {
+            throw new XQException ("Invalid holdability parameter.");
+        }
+        queryLang = i;
+    }
+
+    @Override
+    public int getScrollability() {
+        return scrollability;
+    }
+
+    @Override
+    public void setScrollability(int i) throws XQException {
+        if (!((i==XQConstants.SCROLLTYPE_FORWARD_ONLY) || (i==XQConstants.SCROLLTYPE_SCROLLABLE))) {
+            throw new XQException ("Invalid scroll type.");
+        }
+        scrollability = i;
+    }
+
+    @Override
+    public int getQueryTimeout() {
+        return 0;
+    }
+
+    @Override
+    public void setQueryTimeout(int i) throws XQException {
+        if (i<0) {
+            throw new XQException("Value can't be negative.");
+        }
+    }
+
+    private void isNullXQException(Object value) throws XQException {
+        if (value==null) {
+            throw new XQException("Parameter shouldn't be null");
+        }
+    }
+    
+}

=== added directory 'swig/xqj/tck'
=== added file 'swig/xqj/tck/junit-4.9.jar'
Binary files swig/xqj/tck/junit-4.9.jar	1970-01-01 00:00:00 +0000 and swig/xqj/tck/junit-4.9.jar	2012-03-26 23:10:25 +0000 differ
=== added file 'swig/xqj/tck/xqj_test.bat.in'
--- swig/xqj/tck/xqj_test.bat.in	1970-01-01 00:00:00 +0000
+++ swig/xqj/tck/xqj_test.bat.in	2012-03-26 23:10:25 +0000
@@ -0,0 +1,46 @@
+@ECHO OFF
+
+:: Copyright 2006-2008 The FLWOR Foundation.
+::
+:: Licensed under the Apache License, Version 2.0 (the "License");
+:: you may not use this file except in compliance with the License.
+:: You may obtain a copy of the License at
+::
+:: http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing, software
+:: distributed under the License is distributed on an "AS IS" BASIS,
+:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+:: See the License for the specific language governing permissions and
+:: limitations under the License.
+::
+
+SET JAVA_LOAD_PATH=@JAVA_LOAD_PATH@
+SET XQJ_LOAD_PATH=@XQJ_LOAD_PATH@
+SET PATH=%PATH%;%XQJ_LOAD_PATH%
+
+ECHO "xqj_test.bat: Deleting old Java API if found..."
+RD /S /Q "%XQJ_LOAD_PATH%\tck\org"
+DEL "%XQJ_LOAD_PATH%\tck\zorba_api.jar"
+
+ECHO "xqj_test.bat: Compile Java API ..."
+"@Java_JAVAC_EXECUTABLE@" -source 1.6 -target 1.6 -d tck "%JAVA_LOAD_PATH%\*.java"
+
+ECHO "xqj_test.bat: Creating API JAR..."
+cd tck
+"@Java_JAR_EXECUTABLE@" -cf "zorba_api.jar" org
+cd..
+RD /S /Q "%XQJ_LOAD_PATH%\tck\org"
+
+ECHO "xqj_test.bat: Compile XQJ API ..."
+"@Java_JAVAC_EXECUTABLE@" -source 1.6 -target 1.6 -cp tck\xqjapi.jar;tck\zorba_api.jar -d tck *.java
+
+ECHO "xqj_test.bat: Creating XQJ JAR..."
+cd tck
+"@Java_JAR_EXECUTABLE@" -cf "zorba_xqj.jar" org
+cd..
+RD /S /Q "%XQJ_LOAD_PATH%\tck\org"
+
+
+ECHO "xqj_test.bat: Executing XQJ TCK ..."
+"@Java_JAVA_EXECUTABLE@" -cp tck\xqjapi.jar;tck\xqjtck.jar;tck\junit-4.9.jar;tck\zorba_api.jar;tck\zorba_xqj.jar -Dcom.oracle.xqj.tck.datasource=tck\zorba.properties com.oracle.xqj.tck.AllTests

=== added file 'swig/xqj/tck/xqj_test.sh.in'
--- swig/xqj/tck/xqj_test.sh.in	1970-01-01 00:00:00 +0000
+++ swig/xqj/tck/xqj_test.sh.in	2012-03-26 23:10:25 +0000
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# 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.
+#
+
+JAVA_LOAD_PATH=@JAVA_LOAD_PATH@
+XQJ_LOAD_PATH=@XQJ_LOAD_PATH@
+export LD_LIBRARY_PATH=$JAVA_LOAD_PATH
+PATH=$PATH:$XQJ_LOAD_PATH
+# The following for Mac OS X
+export DYLD_LIBRARY_PATH=$JAVA_LOAD_PATH
+export CLASSPATH="tck:$XQJ_LOAD_PATH"
+
+echo "xqj_test.bat: Deleting old Java API if found..."
+rm -r "$XQJ_LOAD_PATH/tck/org"
+rm "$XQJ_LOAD_PATH/tck/zorba_api.jar"
+
+echo "java_test.sh: Compile Java API ..."
+"@Java_JAVAC_EXECUTABLE@"  -source 1.6 -target 1.6 -d tck $JAVA_LOAD_PATH/*.java
+
+echo "xqj_test.bat: Creating API JAR..."
+cd tck
+"@Java_JAR_EXECUTABLE@" -cf "zorba_api.jar" org
+cd ..
+rm -r "$XQJ_LOAD_PATH/tck/org"
+
+echo "java_test.sh: Compile XQJ API ..."
+"@Java_JAVAC_EXECUTABLE@" -source 1.6 -target 1.6 -cp tck/xqjapi.jar:tck/zorba_api.jar -d tck $XQJ_LOAD_PATH/*.java
+
+echo "xqj_test.bat: Creating XQJ JAR..."
+cd tck
+"@Java_JAR_EXECUTABLE@" -cf "zorba_xqj.jar" org
+cd ..
+rm -r "$XQJ_LOAD_PATH/tck/org"
+
+echo "java_test.sh: Executing XQJ TCK ..."
+"@Java_JAVA_EXECUTABLE@" -cp tck/xqjapi.jar:tck/xqjtck.jar:tck/junit-4.9.jar:tck/zorba_api.jar:tck/zorba_xqj.jar -Dcom.oracle.xqj.tck.datasource=tck/zorba.properties com.oracle.xqj.tck.AllTests

=== added file 'swig/xqj/tck/xqjapi.jar'
Binary files swig/xqj/tck/xqjapi.jar	1970-01-01 00:00:00 +0000 and swig/xqj/tck/xqjapi.jar	2012-03-26 23:10:25 +0000 differ
=== added file 'swig/xqj/tck/xqjtck.jar'
Binary files swig/xqj/tck/xqjtck.jar	1970-01-01 00:00:00 +0000 and swig/xqj/tck/xqjtck.jar	2012-03-26 23:10:25 +0000 differ
=== added file 'swig/xqj/tck/zorba.properties'
--- swig/xqj/tck/zorba.properties	1970-01-01 00:00:00 +0000
+++ swig/xqj/tck/zorba.properties	2012-03-26 23:10:25 +0000
@@ -0,0 +1,2 @@
+XQDataSourceClassName = org.zorbaxquery.api.xqj.XQDataSource
+


Follow ups