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 Get the XQuery processing mode (version 1.0 or 3.0).
209  *
210  *
211  * @return xquery_version_t the XQuery version processing mode.
212  */
213  virtual xquery_version_t
214  getXQueryVersion( ) const = 0;
215 
216  /** \brief Set the XPath 1.0 compatibility mode.
217  * (see http://www.w3.org/TR/xquery/#static_context)
218  *
219  * @param aMode the XPath 1.0 compatibility mode.
220  * @return true if the mode was set, false otherwise.
221  */
222  virtual bool
223  setXPath1_0CompatibMode( xpath1_0compatib_mode_t aMode ) = 0;
224 
225  /** \brief Get the XPath 1.0 compatibility mode.
226  * (see http://www.w3.org/TR/xquery/#static_context)
227  *
228  * @return xpath1_0compatib_mode_t the XPath 1.0 compatibility mode.
229  */
231  getXPath1_0CompatibMode( ) const = 0;
232 
233  /** \brief Set the construction mode.
234  * (see http://www.w3.org/TR/xquery/#static_context)
235  *
236  * @param aMode the construction mode.
237  * @return true if the mode was set, false otherwise.
238  */
239  virtual bool
240  setConstructionMode( construction_mode_t aMode ) = 0;
241 
242  /** \brief Get the construction mode.
243  * (see http://www.w3.org/TR/xquery/#static_context)
244  *
245  * @return construction_mode_t the construction mode.
246  */
247  virtual construction_mode_t
248  getConstructionMode( ) const = 0;
249 
250  /** \brief Set the ordering mode.
251  * (see http://www.w3.org/TR/xquery/#static_context)
252  *
253  * @param aMode the ordering mode.
254  * @return true if the mode was set, false otherwise.
255  */
256  virtual bool
257  setOrderingMode( ordering_mode_t aMode ) = 0;
258 
259  /** \brief Get the ordering mode.
260  * (see http://www.w3.org/TR/xquery/#static_context)
261  *
262  * @return ordering_mode_t the ordering mode.
263  */
264  virtual ordering_mode_t
265  getOrderingMode( ) const = 0;
266 
267  /** \brief Set the default order for the empty sequence.
268  * (see http://www.w3.org/TR/xquery/#static_context)
269  *
270  * @param aMode the default order for the empty sequence.
271  * @return true if the mode was set, false otherwise.
272  */
273  virtual bool
274  setDefaultOrderForEmptySequences( order_empty_mode_t aMode ) = 0;
275 
276  /** \brief Get the default order for the empty sequence.
277  * (see http://www.w3.org/TR/xquery/#static_context)
278  *
279  * @return order_empty_mode_t the ordering mode.
280  */
281  virtual order_empty_mode_t
282  getDefaultOrderForEmptySequences( ) const = 0;
283 
284  /** \brief Set the boundary space policy.
285  * (see http://www.w3.org/TR/xquery/#static_context)
286  *
287  * @param aMode the boundary space policy.
288  * @return true if the mode was set, false otherwise.
289  */
290  virtual bool
291  setBoundarySpacePolicy( boundary_space_mode_t aMode) = 0;
292 
293  /** \brief Get the boundary space policy.
294  * (see http://www.w3.org/TR/xquery/#static_context)
295  *
296  * @return boundary_space_mode_t the boundary space policy.
297  */
298  virtual boundary_space_mode_t
299  getBoundarySpacePolicy( ) const = 0;
300 
301  /** \brief Set the copy namespace mode.
302  * (see http://www.w3.org/TR/xquery/#static_context)
303  *
304  * @param aPreserve the preserve mode.
305  * @param aInherit the inherit mode.
306  * @return true if the mode was set, false otherwise.
307  */
308  virtual bool
309  setCopyNamespacesMode( preserve_mode_t aPreserve,
310  inherit_mode_t aInherit ) = 0;
311 
312  /** \brief Get the copy namespace mode.
313  * (see http://www.w3.org/TR/xquery/#static_context)
314  *
315  * @return aPreserve the preserve mode.
316  * @return aInherit the inherit mode.
317  */
318  virtual void
319  getCopyNamespacesMode( preserve_mode_t& aPreserve,
320  inherit_mode_t& aInherit ) const = 0;
321 
322  /** \brief Set the base URI.
323  * (see http://www.w3.org/TR/xquery/#static_context)
324  *
325  * @param aBaseURI the base URI as String.
326  * @return true if the base URI has been set, false otherwise.
327  */
328  virtual bool
329  setBaseURI( const String& aBaseURI ) = 0;
330 
331  /** \brief Get the base URI.
332  *
333  * @return String the base URI.
334  */
335  virtual String
336  getBaseURI( ) const = 0;
337 
338  /** \brief Get the revalidation mode.
339  *
340  * @return the revalidation mode.
341  */
342  virtual validation_mode_t
343  getRevalidationMode() const = 0;
344 
345  /** \brief Set the revalidation mode.
346  *
347  * @param aMode the revalidation mode.
348  */
349  virtual void
350  setRevalidationMode(validation_mode_t aMode) = 0;
351 
352  /** \brief Register a module providing access to external functions.
353  *
354  * Register a module that provides access to external functions.
355  * The caller keeps the ownership of the Module and the StatelessExternalFunction
356  * objects passed to this function.
357  *
358  * @param aModule the module object
359  * @return true if the module has been set, false otherwise.
360  */
361  virtual bool
362  registerModule(ExternalModule* aModule) = 0;
363 
364  /**
365  * \brief Register a URI Mapper which will transform a given URI
366  * into several alternate potential URIs.
367  *
368  * QQQ doc
369  */
370  virtual void
371  registerURIMapper(URIMapper* aMapper) = 0;
372 
373  /**
374  * \brief Register a URL Resolver which will transform a given
375  * URL into a Resource.
376  *
377  * QQQ doc
378  */
379  virtual void
380  registerURLResolver(URLResolver* aResolver) = 0;
381 
382  /** \brief Set the type of a statically known document
383  */
384  virtual void
385  setDocumentType(const String& aDocUri, TypeIdentifier_t type) = 0;
386 
387  /** \brief Get the type of a statically known document
388  */
389  virtual TypeIdentifier_t
390  getDocumentType(const String& aDocUri) const = 0;
391 
392  /** \brief Set the type of a statically known collection
393  */
394  virtual void
395  setCollectionType(const String& aCollectionUri, TypeIdentifier_t type) = 0;
396 
397  /** \brief Get the type of a statically known collection
398  */
399  virtual TypeIdentifier_t
400  getCollectionType(const String& aCollectionUri) const = 0;
401 
402  /** \brief Check if a function with the given name and arity are registered in the context.
403  */
404  virtual bool
405  containsFunction(const String& aFnNameUri, const String& aFnNameLocal, int arity) const = 0;
406 
407  virtual void
408  findFunctions(const Item& aQName, std::vector<Function_t>& aFunctions) const = 0;
409 
410  virtual void
411  disableFunction(const Function_t& aFunction) = 0;
412 
413  virtual void
414  disableFunction(const Item& aQName, int arity) = 0;
415 
416  virtual void
417  getFunctionAnnotations(const Item& aQName, int arity, std::vector<Annotation_t>& aAnnotations) const = 0;
418 
419  /** \brief Get all functions declared in the given static context
420  *
421  * @return aFunctions all of the said functions
422  */
423  virtual void
424  getFunctions(std::vector<Function_t>& aFunctions) const = 0;
425 
426  /** \brief Get all functions with a specified namespace and airty\
427  * declared in the given static context.
428  *
429  * @param aFnNameUri the namespace for the functions to return
430  * @param arity the arity for the functions to return
431  * @param aFunctions all of the said functions
432  */
433  virtual void
434  getFunctions(
435  const String& aFnNameUri,
436  uint32_t arity,
437  std::vector<Function_t>& aFunctions) const = 0;
438 
439  /** \brief Set the type of the context item.
440  */
441  virtual void
442  setContextItemStaticType(TypeIdentifier_t type) = 0;
443 
444  /** \brief Fetch the type of the context item.
445  */
446  virtual TypeIdentifier_t
447  getContextItemStaticType() const = 0;
448 
449  /** \brief Set the output stream that is used by the fn:trace function
450  *
451  * Sets the output stream that is used by the fn:trace function to the given output stream.
452  * The default stream is std::cerr.
453  *
454  */
455  virtual void
456  setTraceStream(std::ostream&) = 0;
457 
458  /** \brief Resets the output stream that is used by the fn:trace function to std::cerr
459  */
460  virtual void
461  resetTraceStream() = 0;
462 
463  /** \brief Get an option that was declared using the declare option syntax
464  *
465  * @param aQName The QName of the option to get.
466  * @param aOptionValue The value of the option if found.
467  * @return true if the option was found, false otherwise.
468  */
469  virtual bool
470  getOption( const Item& aQName, String& aOptionValue) const = 0;
471 
472  /** \brief Declare an option (same as using declare option in XQuery)
473  *
474  * @param aQName The QName of the option to declare.
475  * @param aOptionValue The value of the option to declare.
476  */
477  virtual void
478  declareOption( const Item& aQName, const String& aOptionValue) = 0;
479 
480  /**
481  * @brief Set the URI and library lookup paths (lists of filesystem
482  * directories) for this static context. Note that calling this method
483  * will override any values previously passed to StaticContext::setURIPath()
484  * and StaticContext::setLibPath().
485  * @deprecated Use StaticContext::setURIPath() and StaticContext::setLibPath().
486  *
487  * Convenience method which adds the listed directories to both the
488  * URI path and Library path for this static context.
489  */
490  virtual void
491  setModulePaths( const std::vector<String>& aModulePaths ) = 0;
492 
493  /**
494  * @brief Return the union of the URI and library lookup paths (lists of
495  * filesystem directories) for this static context. @deprecated Use
496  * StaticContext::getURIPath() and StaticContext::getLibPath().
497  * @deprecated Use StaticContext::getURIPath() and StaticContext::getLibPath().
498  *
499  * Returns any values set by StaticContext::setLibPath() and/or StaticContext::setURIPath()
500  * on this static context.
501  */
502  virtual void
503  getModulePaths( std::vector<String>& aModulePaths ) const = 0;
504 
505  /**
506  * @brief Return the union of the URI and library lookup paths (lists of
507  * filesystem directories) for this static context and all its parents.
508  * @deprecated Use StaticContext::getFullURIPath() and StaticContext::getFullLibPath().
509  */
510  virtual void
511  getFullModulePaths( std::vector<String>& aFullModulePaths ) const = 0;
512 
513  /** \brief Resolves the given URI against the value of the base-uri
514  * property from the static context.
515  *
516  * @param aRelativeUri The relative URI to be resolved.
517  */
518  virtual String
519  resolve(const String& aRelativeUri) const = 0;
520 
521  /** \brief Resolves the given relative URI against the absolute base URI.
522  *
523  * @param aRelativeUri The relative URI to be resolved.
524  * @param aBaseUri The absolute URI against which the resolving is performed.
525  */
526  virtual String
527  resolve(const String& aRelativeUri, const String& aBaseUri) const = 0;
528 
529  /** \brief Validates this Item.
530  * Note: works only on document and element nodes, otherwise returns false.
531  *
532  * @param rootElement the root of the tree beeing validated
533  * @param validatedResult the result of the validation
534  * @param validationMode Validation mode: default value is validate_strict
535  * @return true if validation is correct, false if validation is disabled, throws errors if validation fails
536  * @throw ZorbaException if any validation error occured
537  */
538  virtual bool
539  validate(
540  const Item& rootElement,
541  Item& validatedResult,
542  validation_mode_t validationMode = validate_strict) const = 0;
543 
544  /** \brief Validates this Item while loading the schema for targetNamespace
545  * Note: works only on document or element nodes, otherwise returns false.
546  *
547  * @param rootElement the root of the tree beeing validated
548  * @param validatedResult the result of the validation
549  * @param targetNamespace the expected namespace of root of the tree beeing validated ???
550  * @param validationMode Validation mode: default value is validate_strict
551  * @return true if validation is correct, false if validation is disabled, throws errors if validation fails
552  * @throw ZorbaException if any validation error occured
553  */
554  virtual bool
555  validate(
556  const Item& rootElement,
557  Item& validatedResult,
558  const String& targetNamespace,
559  validation_mode_t validationMode = validate_strict) const = 0;
560 
561  /** \brief Validates stringValue as XML simple content, i.e. the text value of attributes or
562  * text only element content.
563  *
564  * @param stringValue the value to be validated
565  * @param typeQName
566  * @param resultList the result of the validation, a vector of atomic Items
567  * @return true if validation is correct, false if validation is disabled, throws errors if validation fails
568  * @throw ZorbaException if any validation error occured
569  */
570  virtual bool
571  validateSimpleContent(
572  const String& stringValue,
573  const Item& typeQName,
574  std::vector<Item>& resultList) const= 0;
575 
576  /** \brief Invokes the XQuery function with the given name and
577  * the given parameters.
578  *
579  * Note that the function to be invoked needs to be declared in this static
580  * context. In order to declare a function in the static context, the
581  * loadProlog method of this class can be used.
582  *
583  * Also note that if the function to be invoked is an updating function,
584  * its resulting pending update list is implicitly applied by this function.
585  *
586  * @param aQName the name of the function to be invoked
587  * @param aArgs a vector of ItemSequences. One entry in the vector
588  * corresponds to one argument that is passed to the function.
589  *
590  * @return The result of the function that is invoked. If the function
591  * to be invoked is an updating function, the resulting item sequence
592  * is empty.
593  */
594  virtual ItemSequence_t
595  invoke(const Item& aQName, const std::vector<ItemSequence_t>& aArgs) const = 0;
596 
597  /** \brief Returns a CollectionManager responsible for all collections
598  * which are statically declared in this static context.
599  *
600  * The collection manager provides a set of functions for managing
601  * collections and their contents.
602  *
603  * @return The collection manager responsible for managing
604  * collections of this context.
605  *
606  */
607  virtual StaticCollectionManager*
608  getStaticCollectionManager() const = 0;
609 
610  /**
611  * @brief sets the audit event that will be populated during execution
612  *
613  * @param anEvent the audit event
614  */
615  virtual void
616  setAuditEvent(audit::Event* anEvent) = 0;
617 
618  /**
619  * @brief gets the audit event that is populated during execution
620  *
621  * @return the audit event
622  */
623  virtual audit::Event*
624  getAuditEvent() const = 0;
625 
626 
627  /** \brief Returns the QName of all external variables within the
628  * static context
629  *
630  * @param aVarsIter iterator to store the results.
631  * @throw ZorbaException if an error occured.
632  */
633  virtual void
634  getExternalVariables(Iterator_t& aVarsIter) const = 0;
635 
636  /**
637  * @brief Set the URI lookup path (list of filesystem directories) for this
638  * static context.
639  *
640  * Queries which resolve URIs (for instance, importing modules or schemas)
641  * will look in these directories.
642  */
643  virtual void
644  setURIPath(const std::vector<String>& aURIPath) = 0;
645 
646  /**
647  * @brief Return the URI lookup path (list of filesystem directories) for
648  * this static context.
649  *
650  * Returns any values set by StaticContext::setURIPath() on this static context.
651  * To return the full URI lookup path for this static context and
652  * all its parents (usually most useful), call StaticContext::getFullURIPath().
653  */
654  virtual void
655  getURIPath(std::vector<String>& aURIPath) const = 0;
656 
657  /**
658  * @brief Return the URI lookup path (list of filesystem directories) for
659  * this static context and all its parents.
660  */
661  virtual void
662  getFullURIPath(std::vector<String>& aURIPath) const = 0;
663 
664  /**
665  * @brief Set the library lookup path (list of filesystem directories) for
666  * this static context.
667  *
668  * Queries which import modules that have external function
669  * implementations will look for the implementation of those functions
670  * (shared libraries) in these directories.
671  */
672  virtual void
673  setLibPath(const std::vector<String>& aLibPath) = 0;
674 
675  /**
676  * @brief Return the URI lookup path (list of filesystem directories) for
677  * this static context.
678  *
679  * Returns any values set by StaticContext::setLibPath() on this static context.
680  * To return the full library lookup path for this static context and
681  * all its parents (usually most useful), call StaticContext::getFullLibPath().
682  */
683  virtual void
684  getLibPath(std::vector<String>& aLibPath) const = 0;
685 
686  /**
687  * @brief Return the URI lookup path (list of filesystem directories) for
688  * this static context and all its parents.
689  */
690  virtual void
691  getFullLibPath(std::vector<String>& aLibPath) const = 0;
692 
693  /** \brief Fetches an resource refered to by the given URI.
694  *
695  * Resolution is done using the URI mappers and resolvers registered
696  * in this static context. If no such mappers or resolvers have been
697  * registered, the built-in ones are used.
698  *
699  * The default EntityKind for resources fetched by this function
700  * is "SOME_CONTENT". The default encoding that is used to read the
701  * resource is "UTF-8".
702  *
703  * @param aURI the name of the resource to fetch
704  *
705  * @return the fetched resource
706  */
707  virtual Item
708  fetch(const String& aURI) 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 encoding that is used to read the * resource is "UTF-8".
717  *
718  * @param aURI the name of the resource to fetch
719  *
720  * @param aEntityKind the kind of the entity to fetch (i.e.
721  * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
722  *
723  * @return the fetched resource
724  */
725 
726  virtual Item
727  fetch(const String& aURI, const String& aEntityKind) const = 0;
728 
729  /** \brief Fetches an resource refered to by the given URI.
730  *
731  * Resolution is done using the URI mappers and resolvers registered
732  * in this static context. If no such mappers or resolvers have been
733  * registered, the built-in ones are used.
734  *
735  * @param aURI the name of the resource to fetch
736  * @param aEncoding the encoding to use when reading the resource.
737  *
738  * @param aEntityKind the kind of the entity to fetch (i.e.
739  * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
740  *
741  * @return the fetched resource
742  */
743  virtual Item
744  fetch(
745  const String& aURI,
746  const String& aEntityKind,
747  const String& aEncoding) const = 0;
748 
749  /** \brief Fetches an resource refered to by the given URI
750  * and returns it as a base64binary.
751  *
752  * Resolution is done using the URI mappers and resolvers registered
753  * in this static context. If no such mappers or resolvers have been
754  * registered, the built-in ones are used.
755  *
756  * The default EntityKind for resources fetched by this function
757  * is "SOME_CONTENT".
758  *
759  * @param aURI the name of the resource to fetch
760  *
761  * @return the fetched resource
762  */
763  virtual Item
764  fetchBinary(const String& aURI) 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  * @param aURI the name of the resource to fetch
774  *
775  * @param aEntityKind the kind of the entity to fetch (i.e.
776  * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
777  *
778  * @return the fetched resource
779  */
780  virtual Item
781  fetchBinary(const String& aURI, const String& aEntityKind) const = 0;
782 
783  /** \brief Clears the base URI and sets it to undefined state.
784  * (see http://www.w3.org/TR/xquery/#static_context)
785  */
786  virtual void
787  clearBaseURI() = 0;
788 
789 };
790 
791 } /* namespace zorba */
792 #endif
793 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus