static_context.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef XQP_STATIC_CONTEXT_API_H
17 #define XQP_STATIC_CONTEXT_API_H
18 
19 #include <zorba/config.h>
20 #include <zorba/api_shared_types.h>
21 #include <zorba/zorba_string.h>
22 #include <zorba/typeident.h>
24 #include <zorba/options.h> // for compiler hints class
25 #include <vector>
26 #include <zorba/function.h>
27 #include <zorba/annotation.h>
28 #include <zorba/smart_ptr.h>
29 #include <zorba/smart_ptr.h>
30 #ifndef ZORBA_NO_FULL_TEXT
31 #include <zorba/thesaurus.h>
32 #endif /* ZORBA_NO_FULL_TEXT */
33 #include <zorba/zorba.h>
34 #include <zorba/store_manager.h>
35 #include <zorba/zorba_exception.h>
36 
37 namespace zorba {
38 
39  /** \brief Instances of the class StaticContext contain the information that is available
40  * at the time the query is compiled.
41  *
42  * This class contains the information that is defined in the %XQuery specification
43  * (see http://www.w3.org/TR/xquery/#static_context).
44  *
45  * A StaticContext can be created by calling Zorba::createStaticContext and then be passed
46  * to the Zorba::compileQuery or XQuery::compile functions.
47  * If no static context has been passed to any of these functions, a default static context
48  * is used. It can be accessed by calling XQuery::getStaticContext on a compiled XQuery object.
49  *
50  * Note: This class is reference counted. When writing multi-threaded clients,
51  * it is the responibility of the client code to synchronize assignments to the
52  * SmartPtr holding this object.
53  */
54 class ZORBA_DLL_PUBLIC StaticContext : public SmartObject
55 {
56  public:
57  /** \brief Destructor
58  */
59  virtual ~StaticContext() {}
60 
61  /** \brief Loads the declarations and definitions of a given XQuery prolog into
62  * this static context.
63  *
64  * This function compiles the prolog passed as first parameter and loads
65  * all declarations and definitions into this static context.
66  *
67  * The static context extended by this prolog can then be used for creating
68  * a compiling a new query.
69  *
70  * A StaticException is raised if the prolog could not be compiled or
71  * if the prolog does not contain valid declarations (e.g. duplicate declarations).
72  */
73  virtual void
74  loadProlog(const String&, const Zorba_CompilerHints_t &hints) = 0;
75 
76  /** \brief Create a child static context, i.e. a context with the same information,
77  * of the given static context.
78  *
79  * A child static context carries the same context as it's parent but
80  * can override any information.
81  */
82  virtual StaticContext_t
83  createChildContext() const = 0;
84 
85  /** \brief Add a pair (prefix, URI) to the statically known namespaces that
86  * are available during query compilation.
87  *
88  * See http://www.w3.org/TR/xquery/#static_context.
89  *
90  * @param aPrefix the prefix String.
91  * @param aURI the URI String.
92  * @return true if the pair was added to the set of statically known namespaces,
93  * false otherwise.
94  * @throw ZorbaException if an error occures.
95  */
96  virtual bool
97  addNamespace( const String& aPrefix, const String& aURI ) = 0;
98 
99  /** \brief Get the namespace URI for a given prefix.
100  *
101  * @param aPrefix the prefix for which to retrieve the namespace URI.
102  * @return String the URI for the given prefix or an empty String if no URI
103  * could be found for the given prefix and an DiagnosticHandler has been
104  * registered.
105  * @throw ZorbaException if an error occured (e.g. no URI could be found for the given prefix).
106  *
107  * @deprecated This function is deprecated. Use getNamespaceBindings instead.
108  */
109  virtual String
110  getNamespaceURIByPrefix( const String& aPrefix ) const = 0;
111 
112  /**
113  * \brief Get the list of all namespace bindings (prefix, uri)
114  * declared in this and its parent static contexts.
115  *
116  * @param aBindings the bindings are added to this list
117  */
118  virtual void
119  getNamespaceBindings( NsBindings& aBindings ) const = 0;
120 
121  /** \brief Set the default element and type namespace
122  * (see http://www.w3.org/TR/xquery/#static_context)
123  *
124  * @param aURI of the default element and type namespace URI.
125  * @return true if the default element and type namespace URI has been set, false otherwise
126  * if an DiagnosticHandler has been registered.
127  * @throw ZorbaException if an error occured.
128  */
129  virtual bool
130  setDefaultElementAndTypeNamespace( const String& aURI ) = 0;
131 
132  /** \brief Get the default element and type namespace URI.
133  *
134  * @return String the URI for the default element and type namespace.
135  * @throw ZorbaException if an error occured.
136  */
137  virtual String
138  getDefaultElementAndTypeNamespace( ) const = 0;
139 
140  /** \brief Set the default functionnamespace
141  * (see http://www.w3.org/TR/xquery/#static_context)
142  *
143  * @param aURI of the default function namespace.
144  * @return true if the default function namespace URI has been set, false otherwise
145  * if an DiagnosticHandler has been registered.
146  * @throw ZorbaException if an error occured.
147  */
148  virtual bool
149  setDefaultFunctionNamespace( const String& aURI ) = 0;
150 
151  /** \brief Get the default function namespace.
152  *
153  * @return String the URI of the default function namespace.
154  * DiagnosticHandler has been registered.
155  * @throw ZorbaException if an error occured.
156  */
157  virtual String
158  getDefaultFunctionNamespace( ) const = 0;
159 
160  /** \brief Adds a collation URI.
161  *
162  * The URI specifies the locale and collation strength of the collation that is added.
163  * A valid collation URI must begin with %http://www.zorba-xquery.com/collations/.
164  * This prefix is followed by a collation strength (i.e. PRIMARY, SECONDARY, TERTIARY,
165  * QUATTERNARY, or IDENTICAL) followed by a '/'.
166  * After the strength a lower-case two- or three-letter ISO-639 language code must follow.
167  * The URI may end with an upper-case two-letter ISO-3166.
168  * For example, %http://www.zorba-xquery.com/collations/PRIMARY/en/US
169  * specifies an english language with US begin the country..
170  *
171  * Internally, ICU is used for comparing strings. For detailed description see
172  * http://www.icu-project.org/apiref/icu4c/classCollator.html
173  * and http://www.icu-project.org/apiref/icu4c/classLocale.html
174  *
175  * @param aURI the URI of the collation.
176  * @throw ZorbaException if an error occured (e.g. the URI was not a valid
177  * collation URI).
178  */
179  virtual void
180  addCollation( const String& aURI ) = 0;
181 
182  /** \brief Set the URI of the default collation.
183  * (see http://www.w3.org/TR/xquery/#static_context)
184  *
185  * @param aURI URI of the default collation.
186  * @throw ZorbaException if an error occured (e.g., the URI does not
187  * identify a collation among the statically known collations.
188  */
189  virtual void
190  setDefaultCollation( const String& aURI ) = 0;
191 
192  /** \brief Get the URI of the default collation
193  *
194  * @return String the URI of the default collation.
195  */
196  virtual String
197  getDefaultCollation() const = 0;
198 
199  /** \brief Set the XQuery processing mode (version 1.0 or 3.0).
200  *
201  *
202  * @param aMode the XQuery version.
203  * @return true if the version was set, false otherwise.
204  */
205  virtual bool
206  setXQueryVersion( xquery_version_t aMode ) = 0;
207 
208  /** \brief Set the JSONiq processing mode
209  *
210  *
211  * @param aMode the JSONiq version
212  * @return true if the version was set, false otherwise.
213  */
214  virtual bool
215  setJSONiqVersion( jsoniq_version_t aMode ) = 0;
216 
217  /** \brief Get the XQuery processing mode (version 1.0 or 3.0).
218  *
219  *
220  * @return xquery_version_t the XQuery version processing mode.
221  */
222  virtual xquery_version_t
223  getXQueryVersion( ) const = 0;
224 
225  /** \brief Get the JSONiq processing mode.
226  *
227  *
228  * @return jsoniq_version_t the JSONiq version processing mode.
229  */
230  virtual jsoniq_version_t
231  getJSONiqVersion( ) const = 0;
232 
233  /** \brief Set the XPath 1.0 compatibility mode.
234  * (see http://www.w3.org/TR/xquery/#static_context)
235  *
236  * @param aMode the XPath 1.0 compatibility mode.
237  * @return true if the mode was set, false otherwise.
238  */
239  virtual bool
240  setXPath1_0CompatibMode( xpath1_0compatib_mode_t aMode ) = 0;
241 
242  /** \brief Get the XPath 1.0 compatibility mode.
243  * (see http://www.w3.org/TR/xquery/#static_context)
244  *
245  * @return xpath1_0compatib_mode_t the XPath 1.0 compatibility mode.
246  */
248  getXPath1_0CompatibMode( ) const = 0;
249 
250  /** \brief Set the construction mode.
251  * (see http://www.w3.org/TR/xquery/#static_context)
252  *
253  * @param aMode the construction mode.
254  * @return true if the mode was set, false otherwise.
255  */
256  virtual bool
257  setConstructionMode( construction_mode_t aMode ) = 0;
258 
259  /** \brief Get the construction mode.
260  * (see http://www.w3.org/TR/xquery/#static_context)
261  *
262  * @return construction_mode_t the construction mode.
263  */
264  virtual construction_mode_t
265  getConstructionMode( ) const = 0;
266 
267  /** \brief Set the ordering mode.
268  * (see http://www.w3.org/TR/xquery/#static_context)
269  *
270  * @param aMode the ordering mode.
271  * @return true if the mode was set, false otherwise.
272  */
273  virtual bool
274  setOrderingMode( ordering_mode_t aMode ) = 0;
275 
276  /** \brief Get the ordering mode.
277  * (see http://www.w3.org/TR/xquery/#static_context)
278  *
279  * @return ordering_mode_t the ordering mode.
280  */
281  virtual ordering_mode_t
282  getOrderingMode( ) const = 0;
283 
284  /** \brief Set the default order for the empty sequence.
285  * (see http://www.w3.org/TR/xquery/#static_context)
286  *
287  * @param aMode the default order for the empty sequence.
288  * @return true if the mode was set, false otherwise.
289  */
290  virtual bool
291  setDefaultOrderForEmptySequences( order_empty_mode_t aMode ) = 0;
292 
293  /** \brief Get the default order for the empty sequence.
294  * (see http://www.w3.org/TR/xquery/#static_context)
295  *
296  * @return order_empty_mode_t the ordering mode.
297  */
298  virtual order_empty_mode_t
299  getDefaultOrderForEmptySequences( ) const = 0;
300 
301  /** \brief Set the boundary space policy.
302  * (see http://www.w3.org/TR/xquery/#static_context)
303  *
304  * @param aMode the boundary space policy.
305  * @return true if the mode was set, false otherwise.
306  */
307  virtual bool
308  setBoundarySpacePolicy( boundary_space_mode_t aMode) = 0;
309 
310  /** \brief Get the boundary space policy.
311  * (see http://www.w3.org/TR/xquery/#static_context)
312  *
313  * @return boundary_space_mode_t the boundary space policy.
314  */
315  virtual boundary_space_mode_t
316  getBoundarySpacePolicy( ) const = 0;
317 
318  /** \brief Set the copy namespace mode.
319  * (see http://www.w3.org/TR/xquery/#static_context)
320  *
321  * @param aPreserve the preserve mode.
322  * @param aInherit the inherit mode.
323  * @return true if the mode was set, false otherwise.
324  */
325  virtual bool
326  setCopyNamespacesMode( preserve_mode_t aPreserve,
327  inherit_mode_t aInherit ) = 0;
328 
329  /** \brief Get the copy namespace mode.
330  * (see http://www.w3.org/TR/xquery/#static_context)
331  *
332  * @return aPreserve the preserve mode.
333  * @return aInherit the inherit mode.
334  */
335  virtual void
336  getCopyNamespacesMode( preserve_mode_t& aPreserve,
337  inherit_mode_t& aInherit ) const = 0;
338 
339  /** \brief Set the base URI.
340  * (see http://www.w3.org/TR/xquery/#static_context)
341  *
342  * @param aBaseURI the base URI as String.
343  * @return true if the base URI has been set, false otherwise.
344  */
345  virtual bool
346  setBaseURI( const String& aBaseURI ) = 0;
347 
348  /** \brief Get the base URI.
349  *
350  * @return String the base URI.
351  */
352  virtual String
353  getBaseURI( ) const = 0;
354 
355  /** \brief Get the revalidation mode.
356  *
357  * @return the revalidation mode.
358  */
359  virtual validation_mode_t
360  getRevalidationMode() const = 0;
361 
362  /** \brief Set the revalidation mode.
363  *
364  * @param aMode the revalidation mode.
365  */
366  virtual void
367  setRevalidationMode(validation_mode_t aMode) = 0;
368 
369  /** \brief Register a module providing access to external functions.
370  *
371  * Register a module that provides access to external functions.
372  * The caller keeps the ownership of the Module and the StatelessExternalFunction
373  * objects passed to this function.
374  *
375  * @param aModule the module object
376  * @return true if the module has been set, false otherwise.
377  */
378  virtual bool
379  registerModule(ExternalModule* aModule) = 0;
380 
381  /**
382  * \brief Register a URI Mapper which will transform a given URI
383  * into several alternate potential URIs.
384  *
385  * QQQ doc
386  */
387  virtual void
388  registerURIMapper(URIMapper* aMapper) = 0;
389 
390  /**
391  * \brief Register a URL Resolver which will transform a given
392  * URL into a Resource.
393  *
394  * QQQ doc
395  */
396  virtual void
397  registerURLResolver(URLResolver* aResolver) = 0;
398 
399  /** \brief Set the type of a statically known document
400  */
401  virtual void
402  setDocumentType(const String& aDocUri, TypeIdentifier_t type) = 0;
403 
404  /** \brief Get the type of a statically known document
405  */
406  virtual TypeIdentifier_t
407  getDocumentType(const String& aDocUri) const = 0;
408 
409  /** \brief Set the type of a statically known collection
410  */
411  virtual void
412  setCollectionType(const String& aCollectionUri, TypeIdentifier_t type) = 0;
413 
414  /** \brief Get the type of a statically known collection
415  */
416  virtual TypeIdentifier_t
417  getCollectionType(const String& aCollectionUri) const = 0;
418 
419  /** \brief Check if a function with the given name and arity are registered in the context.
420  */
421  virtual bool
422  containsFunction(const String& aFnNameUri, const String& aFnNameLocal, int arity) const = 0;
423 
424  virtual void
425  findFunctions(const Item& aQName, std::vector<Function_t>& aFunctions) const = 0;
426 
427  virtual void
428  disableFunction(const Function_t& aFunction) = 0;
429 
430  virtual void
431  disableFunction(const Item& aQName, int arity) = 0;
432 
433  virtual void
434  getFunctionAnnotations(const Item& aQName, int arity, std::vector<Annotation_t>& aAnnotations) const = 0;
435 
436  /** \brief Get all functions declared in the given static context
437  *
438  * @return aFunctions all of the said functions
439  */
440  virtual void
441  getFunctions(std::vector<Function_t>& aFunctions) const = 0;
442 
443  /** \brief Get all functions with a specified namespace and airty\
444  * declared in the given static context.
445  *
446  * @param aFnNameUri the namespace for the functions to return
447  * @param arity the arity for the functions to return
448  * @param aFunctions all of the said functions
449  */
450  virtual void
451  getFunctions(
452  const String& aFnNameUri,
453  uint32_t arity,
454  std::vector<Function_t>& aFunctions) const = 0;
455 
456  /** \brief Set the type of the context item.
457  */
458  virtual void
459  setContextItemStaticType(TypeIdentifier_t type) = 0;
460 
461  /** \brief Fetch the type of the context item.
462  */
463  virtual TypeIdentifier_t
464  getContextItemStaticType() const = 0;
465 
466  /** \brief Set the output stream that is used by the fn:trace function
467  *
468  * Sets the output stream that is used by the fn:trace function to the given output stream.
469  * The default stream is std::cerr.
470  *
471  */
472  virtual void
473  setTraceStream(std::ostream&) = 0;
474 
475  /** \brief Resets the output stream that is used by the fn:trace function to std::cerr
476  */
477  virtual void
478  resetTraceStream() = 0;
479 
480  /** \brief Get an option that was declared using the declare option syntax
481  *
482  * @param aQName The QName of the option to get.
483  * @param aOptionValue The value of the option if found.
484  * @return true if the option was found, false otherwise.
485  */
486  virtual bool
487  getOption( const Item& aQName, String& aOptionValue) const = 0;
488 
489  /** \brief Declare an option (same as using declare option in XQuery)
490  *
491  * @param aQName The QName of the option to declare.
492  * @param aOptionValue The value of the option to declare.
493  */
494  virtual void
495  declareOption( const Item& aQName, const String& aOptionValue) = 0;
496 
497  /**
498  * @brief Set the URI and library lookup paths (lists of filesystem
499  * directories) for this static context. Note that calling this method
500  * will override any values previously passed to StaticContext::setURIPath()
501  * and StaticContext::setLibPath().
502  * @deprecated Use StaticContext::setURIPath() and StaticContext::setLibPath().
503  *
504  * Convenience method which adds the listed directories to both the
505  * URI path and Library path for this static context.
506  */
507  virtual void
508  setModulePaths( const std::vector<String>& aModulePaths ) = 0;
509 
510  /**
511  * @brief Return the union of the URI and library lookup paths (lists of
512  * filesystem directories) for this static context. @deprecated Use
513  * StaticContext::getURIPath() and StaticContext::getLibPath().
514  * @deprecated Use StaticContext::getURIPath() and StaticContext::getLibPath().
515  *
516  * Returns any values set by StaticContext::setLibPath() and/or StaticContext::setURIPath()
517  * on this static context.
518  */
519  virtual void
520  getModulePaths( std::vector<String>& aModulePaths ) const = 0;
521 
522  /**
523  * @brief Return the union of the URI and library lookup paths (lists of
524  * filesystem directories) for this static context and all its parents.
525  * @deprecated Use StaticContext::getFullURIPath() and StaticContext::getFullLibPath().
526  */
527  virtual void
528  getFullModulePaths( std::vector<String>& aFullModulePaths ) const = 0;
529 
530  /** \brief Resolves the given URI against the value of the base-uri
531  * property from the static context.
532  *
533  * @param aRelativeUri The relative URI to be resolved.
534  */
535  virtual String
536  resolve(const String& aRelativeUri) const = 0;
537 
538  /** \brief Resolves the given relative URI against the absolute base URI.
539  *
540  * @param aRelativeUri The relative URI to be resolved.
541  * @param aBaseUri The absolute URI against which the resolving is performed.
542  */
543  virtual String
544  resolve(const String& aRelativeUri, const String& aBaseUri) const = 0;
545 
546  /** \brief Validates this Item.
547  * Note: works only on document and element nodes, otherwise returns false.
548  *
549  * @param rootElement the root of the tree beeing validated
550  * @param validatedResult the result of the validation
551  * @param validationMode Validation mode: default value is validate_strict
552  * @return true if validation is correct, false if validation is disabled, throws errors if validation fails
553  * @throw ZorbaException if any validation error occured
554  */
555  virtual bool
556  validate(
557  const Item& rootElement,
558  Item& validatedResult,
559  validation_mode_t validationMode = validate_strict) const = 0;
560 
561  /** \brief Validates this Item while loading the schema for targetNamespace
562  * Note: works only on document or element nodes, otherwise returns false.
563  *
564  * @param rootElement the root of the tree beeing validated
565  * @param validatedResult the result of the validation
566  * @param targetNamespace the expected namespace of root of the tree beeing validated ???
567  * @param validationMode Validation mode: default value is validate_strict
568  * @return true if validation is correct, false if validation is disabled, throws errors if validation fails
569  * @throw ZorbaException if any validation error occured
570  */
571  virtual bool
572  validate(
573  const Item& rootElement,
574  Item& validatedResult,
575  const String& targetNamespace,
576  validation_mode_t validationMode = validate_strict) const = 0;
577 
578  /** \brief Validates stringValue as XML simple content, i.e. the text value of attributes or
579  * text only element content.
580  *
581  * @param stringValue the value to be validated
582  * @param typeQName
583  * @param resultList the result of the validation, a vector of atomic Items
584  * @return true if validation is correct, false if validation is disabled, throws errors if validation fails
585  * @throw ZorbaException if any validation error occured
586  */
587  virtual bool
588  validateSimpleContent(
589  const String& stringValue,
590  const Item& typeQName,
591  std::vector<Item>& resultList) const= 0;
592 
593  /** \brief Invokes the XQuery function with the given name and
594  * the given parameters.
595  *
596  * Note that the function to be invoked needs to be declared in this static
597  * context. In order to declare a function in the static context, the
598  * loadProlog method of this class can be used.
599  *
600  * Also note that if the function to be invoked is an updating function,
601  * its resulting pending update list is implicitly applied by this function.
602  *
603  * @param aQName the name of the function to be invoked
604  * @param aArgs a vector of ItemSequences. One entry in the vector
605  * corresponds to one argument that is passed to the function.
606  *
607  * @return The result of the function that is invoked. If the function
608  * to be invoked is an updating function, the resulting item sequence
609  * is empty.
610  */
611  virtual ItemSequence_t
612  invoke(const Item& aQName, const std::vector<ItemSequence_t>& aArgs) const = 0;
613 
614  /** \brief Returns a CollectionManager responsible for all collections
615  * which are statically declared in this static context.
616  *
617  * The collection manager provides a set of functions for managing
618  * collections and their contents.
619  *
620  * @return The collection manager responsible for managing
621  * collections of this context.
622  *
623  */
624  virtual StaticCollectionManager*
625  getStaticCollectionManager() const = 0;
626 
627  /**
628  * @brief sets the audit event that will be populated during execution
629  *
630  * @param anEvent the audit event
631  */
632  virtual void
633  setAuditEvent(audit::Event* anEvent) = 0;
634 
635  /**
636  * @brief gets the audit event that is populated during execution
637  *
638  * @return the audit event
639  */
640  virtual audit::Event*
641  getAuditEvent() const = 0;
642 
643 
644  /** \brief Returns the QName of all external variables within the
645  * static context
646  *
647  * @param aVarsIter iterator to store the results.
648  * @throw ZorbaException if an error occured.
649  */
650  virtual void
651  getExternalVariables(Iterator_t& aVarsIter) const = 0;
652 
653  /**
654  * @brief Set the URI lookup path (list of filesystem directories) for this
655  * static context.
656  *
657  * Queries which resolve URIs (for instance, importing modules or schemas)
658  * will look in these directories.
659  */
660  virtual void
661  setURIPath(const std::vector<String>& aURIPath) = 0;
662 
663  /**
664  * @brief Return the URI lookup path (list of filesystem directories) for
665  * this static context.
666  *
667  * Returns any values set by StaticContext::setURIPath() on this static context.
668  * To return the full URI lookup path for this static context and
669  * all its parents (usually most useful), call StaticContext::getFullURIPath().
670  */
671  virtual void
672  getURIPath(std::vector<String>& aURIPath) const = 0;
673 
674  /**
675  * @brief Return the URI lookup path (list of filesystem directories) for
676  * this static context and all its parents.
677  */
678  virtual void
679  getFullURIPath(std::vector<String>& aURIPath) const = 0;
680 
681  /**
682  * @brief Set the library lookup path (list of filesystem directories) for
683  * this static context.
684  *
685  * Queries which import modules that have external function
686  * implementations will look for the implementation of those functions
687  * (shared libraries) in these directories.
688  */
689  virtual void
690  setLibPath(const std::vector<String>& aLibPath) = 0;
691 
692  /**
693  * @brief Return the URI lookup path (list of filesystem directories) for
694  * this static context.
695  *
696  * Returns any values set by StaticContext::setLibPath() on this static context.
697  * To return the full library lookup path for this static context and
698  * all its parents (usually most useful), call StaticContext::getFullLibPath().
699  */
700  virtual void
701  getLibPath(std::vector<String>& aLibPath) const = 0;
702 
703  /**
704  * @brief Return the URI lookup path (list of filesystem directories) for
705  * this static context and all its parents.
706  */
707  virtual void
708  getFullLibPath(std::vector<String>& aLibPath) const = 0;
709 
710  /** \brief Fetches an resource refered to by the given URI.
711  *
712  * Resolution is done using the URI mappers and resolvers registered
713  * in this static context. If no such mappers or resolvers have been
714  * registered, the built-in ones are used.
715  *
716  * The default EntityKind for resources fetched by this function
717  * is "SOME_CONTENT". The default encoding that is used to read the
718  * resource is "UTF-8".
719  *
720  * @param aURI the name of the resource to fetch
721  *
722  * @return the fetched resource
723  */
724  virtual Item
725  fetch(const String& aURI) const = 0;
726 
727  /** \brief Fetches an resource refered to by the given URI.
728  *
729  * Resolution is done using the URI mappers and resolvers registered
730  * in this static context. If no such mappers or resolvers have been
731  * registered, the built-in ones are used.
732  *
733  * The default encoding that is used to read the * resource is "UTF-8".
734  *
735  * @param aURI the name of the resource to fetch
736  *
737  * @param aEntityKind the kind of the entity to fetch (i.e.
738  * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
739  *
740  * @return the fetched resource
741  */
742 
743  virtual Item
744  fetch(const String& aURI, const String& aEntityKind) const = 0;
745 
746  /** \brief Fetches an resource refered to by the given URI.
747  *
748  * Resolution is done using the URI mappers and resolvers registered
749  * in this static context. If no such mappers or resolvers have been
750  * registered, the built-in ones are used.
751  *
752  * @param aURI the name of the resource to fetch
753  * @param aEncoding the encoding to use when reading the resource.
754  *
755  * @param aEntityKind the kind of the entity to fetch (i.e.
756  * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
757  *
758  * @return the fetched resource
759  */
760  virtual Item
761  fetch(
762  const String& aURI,
763  const String& aEntityKind,
764  const String& aEncoding) const = 0;
765 
766  /** \brief Fetches an resource refered to by the given URI
767  * and returns it as a base64binary.
768  *
769  * Resolution is done using the URI mappers and resolvers registered
770  * in this static context. If no such mappers or resolvers have been
771  * registered, the built-in ones are used.
772  *
773  * The default EntityKind for resources fetched by this function
774  * is "SOME_CONTENT".
775  *
776  * @param aURI the name of the resource to fetch
777  *
778  * @return the fetched resource
779  */
780  virtual Item
781  fetchBinary(const String& aURI) const = 0;
782 
783  /** \brief Fetches an resource refered to by the given URI
784  * and returns it as a base64binary.
785  *
786  * Resolution is done using the URI mappers and resolvers registered
787  * in this static context. If no such mappers or resolvers have been
788  * registered, the built-in ones are used.
789  *
790  * @param aURI the name of the resource to fetch
791  *
792  * @param aEntityKind the kind of the entity to fetch (i.e.
793  * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
794  *
795  * @return the fetched resource
796  */
797  virtual Item
798  fetchBinary(const String& aURI, const String& aEntityKind) const = 0;
799 
800  /** \brief Clears the base URI and sets it to undefined state.
801  * (see http://www.w3.org/TR/xquery/#static_context)
802  */
803  virtual void
804  clearBaseURI() = 0;
805 
806  /** \brief Sets a list of default function namespaces that will be
807  * used in order during the lookup of functions.
808  *
809  * @param aURIs the list of default function namespaces.
810  * @return true if the said namespaces have been set, false otherwise
811  * if an DiagnosticHandler has been registered.
812  * @throw ZorbaException if an error occured.
813  */
814  virtual bool
815  setDefaultFunctionNamespaces( const std::vector<String>& aURIs ) = 0;
816 };
817 
818 } /* namespace zorba */
819 #endif
820 /* vim:set et sw=2 ts=2: */