1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import sys
16sys.path.insert(0, '@pythonPath@')
17import zorba_api
18
19class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
20  def error(self, *args):
21    print "Error args: ", args
22
23def test(zorba):
24  #Read and write result
25  print 'Executing: compilerHints.xq'
26  f = open('compilerHints.xq', 'r')
27  lines = f.read()
28  f.close()
29  diagnosticHandler = MyDiagnosticHandler()
30  compilerHints = zorba_api.CompilerHints()
31  compilerHints.setLibModule(True)
32  compilerHints.setOptimizationLevel(1)
33  xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
34
35  result = xquery.execute()
36  print result
37  return
38
39
40store = zorba_api.InMemoryStore_getInstance()
41zorba = zorba_api.Zorba_getInstance(store)
42
43print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 1 - setLibModule(True)"
44test(zorba)
45print "Success"
46
47
48zorba.shutdown()
49zorba_api.InMemoryStore_shutdown(store)
50
51