zorba::StaticContext#include <zorba/static_context.h> Inherited from: zorba::SmartObject Instances of the class StaticContext contain the information that is available at the time the query is compiled and run. This class contains the information that is defined in the XQuery specification (see http://www.w3.org/TR/xquery/#static_context).A StaticContext can be created by calling Zorba::createStaticContext and then be passed to the Zorba::compileQuery or XQuery::compile functions. If no static context has been passed to any of these functions, a default static context is used. It can be accessed by calling XQuery::getStaticContext on a compiled XQuery object.Note: This class is reference counted. When writing multi-threaded clients, it is the responibility of the client code to synchronize assignments to the SmartPtr holding this object.Public Functions
Protected Attributes
Public FunctionsaddCollationvoid addCollation(const String &aURI)=0 Adds a collation URI. The URI specifies the locale and collation strength of the collation that is added. A valid collation URI must begin with http://zorba.io/collations/. This prefix is followed by a collation strength (i.e. PRIMARY, SECONDARY, TERTIARY, QUATTERNARY, or IDENTICAL) followed by a '/'. After the strength a lower-case two- or three-letter ISO-639 language code must follow. The URI may end with an upper-case two-letter ISO-3166. For example, http://zorba.io/collations/PRIMARY/en/US specifies an english language with US begin the country..Internally, ICU is used for comparing strings. For detailed description see http://www.icu-project.org/apiref/icu4c/classCollator.html and http://www.icu-project.org/apiref/icu4c/classLocale.html Parameters
Parameters
addNamespacebool addNamespace(const String &aPrefix, const String &aURI)=0 Add a pair (prefix, URI) to the statically known namespaces that are available during query compilation. See http://www.w3.org/TR/xquery/#static_context. Returnstrue if the pair was added to the set of statically known namespaces, false otherwise.Parameters
addReferencevoid addReference() const
clearBaseURIvoid clearBaseURI()=0 Clears the base URI and sets it to undefined state. containsFunctionbool containsFunction(const String &aFnNameUri, const String &aFnNameLocal, int arity) const =0 Check if a function with the given name and arity are registered in the context.
createChildContextStaticContext_t createChildContext() const =0 Create a child static context, i.e. a context with the same information, of the given static context.A child static context carries the same context as it's parent but can override any information. declareOptionvoid declareOption(const Item &aQName, const String &aOptionValue)=0 Declare an option (same as using declare option in XQuery)
Parameters
disableFunctionvoid disableFunction(const Function_t &aFunction)=0
disableFunctionvoid disableFunction(const Item &aQName, int arity)=0
fetchItem fetch(const String &aURI) const =0 Fetches an resource refered to by the given URI. Resolution is done using the URI mappers and resolvers registered in this static context. If no such mappers or resolvers have been registered, the built-in ones are used.The default EntityKind for resources fetched by this function is "SOME_CONTENT". The default encoding that is used to read the resource is "UTF-8". Parameters
Returnsthe fetched resourcefetchItem fetch(const String &aURI, const String &aEntityKind) const =0 Fetches an resource refered to by the given URI. Resolution is done using the URI mappers and resolvers registered in this static context. If no such mappers or resolvers have been registered, the built-in ones are used.The default encoding that is used to read the * resource is "UTF-8". Parameters
Returnsthe fetched resourcefetchItem fetch(const String &aURI, const String &aEntityKind, const String &aEncoding) const =0 Fetches an resource refered to by the given URI. Resolution is done using the URI mappers and resolvers registered in this static context. If no such mappers or resolvers have been registered, the built-in ones are used. Parameters
Returnsthe fetched resourcefetchBinaryItem fetchBinary(const String &aURI) const =0 Fetches an resource refered to by the given URI and returns it as a base64binary. Resolution is done using the URI mappers and resolvers registered in this static context. If no such mappers or resolvers have been registered, the built-in ones are used.The default EntityKind for resources fetched by this function is "SOME_CONTENT". Parameters
Returnsthe fetched resourcefetchBinaryItem fetchBinary(const String &aURI, const String &aEntityKind) const =0 Fetches an resource refered to by the given URI and returns it as a base64binary. Resolution is done using the URI mappers and resolvers registered in this static context. If no such mappers or resolvers have been registered, the built-in ones are used. Parameters
Returnsthe fetched resourcefindFunctionsvoid findFunctions(const Item &aQName, std::vector< Function_t > &aFunctions) const =0
freevoid free()
getAuditEventaudit::Event * getAuditEvent() const =0 gets the audit event that is populated during execution
Returnsthe audit eventgetBoundarySpacePolicyboundary_space_mode_t getBoundarySpacePolicy() const =0 Get the boundary space policy. (see http://www.w3.org/TR/xquery/#static_context) Returnsboundary_space_mode_t the boundary space policy.getCollectionTypeSequenceType getCollectionType(const String &aCollectionUri) const =0 Get the type of a statically known collection.
getConstructionModeconstruction_mode_t getConstructionMode() const =0 Get the construction mode. (see http://www.w3.org/TR/xquery/#static_context) Returnsconstruction_mode_t the construction mode.getContextItemStaticTypeSequenceType getContextItemStaticType() const =0 Fetch the type of the context item.
getCopyNamespacesModevoid getCopyNamespacesMode(preserve_mode_t &aPreserve, inherit_mode_t &aInherit) const =0 Get the copy namespace mode. (see http://www.w3.org/TR/xquery/#static_context) ReturnsaPreserve the preserve mode.getDefaultCollationString getDefaultCollation() const =0 getDefaultElementAndTypeNamespaceString getDefaultElementAndTypeNamespace() const =0 Get the default element and type namespace URI.
ReturnsString the URI for the default element and type namespace.Parameters
getDefaultFunctionNamespaceString getDefaultFunctionNamespace() const =0 Get the default function namespace.
Parameters
getDefaultOrderForEmptySequencesorder_empty_mode_t getDefaultOrderForEmptySequences() const =0 Get the default order for the empty sequence. (see http://www.w3.org/TR/xquery/#static_context) Returnsorder_empty_mode_t the ordering mode.getDocumentTypeSequenceType getDocumentType(const String &aDocUri) const =0 Get the type of a statically known document.
getExternalVariablesvoid getExternalVariables(Iterator_t &aVarsIter) const =0 Returns the QName of all external variables within the static context.
Parameters
Parameters
getFullLibPathvoid getFullLibPath(std::vector< String > &aLibPath) const =0 Return the URI lookup path (list of filesystem directories) for this static context and all its parents.
getFullModulePathsvoid getFullModulePaths(std::vector< String > &aFullModulePaths) const =0 Return the union of the URI and library lookup paths (lists of filesystem directories) for this static context and all its parents.
getFullURIPathvoid getFullURIPath(std::vector< String > &aURIPath) const =0 Return the URI lookup path (list of filesystem directories) for this static context and all its parents.
getFunctionAnnotationsvoid getFunctionAnnotations(const Item &aQName, int arity, std::vector< Annotation_t > &aAnnotations) const =0
getFunctionsvoid getFunctions(std::vector< Function_t > &aFunctions) const =0 Get all functions declared in the given static context.
ReturnsaFunctions all of the said functionsgetFunctionsvoid getFunctions(const String &aFnNameUri, uint32_t arity, std::vector< Function_t > &aFunctions) const =0 Get all functions with a specified namespace and airty\ declared in the given static context.
Parameters
getJSONiqVersionjsoniq_version_t getJSONiqVersion() const =0 Get the JSONiq processing mode.
Returnsjsoniq_version_t the JSONiq version processing mode.getLibPathvoid getLibPath(std::vector< String > &aLibPath) const =0 Return the URI lookup path (list of filesystem directories) for this static context. Returns any values set by StaticContext::setLibPath() on this static context. To return the full library lookup path for this static context and all its parents (usually most useful), call StaticContext::getFullLibPath(). getModulePathsvoid getModulePaths(std::vector< String > &aModulePaths) const =0 Return the union of the URI and library lookup paths (lists of filesystem directories) for this static context.
getNamespaceBindingsvoid getNamespaceBindings(NsBindings &aBindings) const =0 Get the list of all namespace bindings (prefix, uri) declared in this and its parent static contexts.
Parameters
getNamespaceURIByPrefixString getNamespaceURIByPrefix(const String &aPrefix) const =0 Get the namespace URI for a given prefix.
Parameters
ReturnsString the URI for the given prefix or an empty String if no URI could be found for the given prefix and an DiagnosticHandler has been registered.Parameters
getOptionbool getOption(const Item &aQName, String &aOptionValue) const =0 Get an option that was declared using the declare option syntax.
Parameters
Returnstrue if the option was found, false otherwise.getOrderingModeordering_mode_t getOrderingMode() const =0 Get the ordering mode. (see http://www.w3.org/TR/xquery/#static_context) Returnsordering_mode_t the ordering mode.getRefCountlong getRefCount() const
getRevalidationModevalidation_mode_t getRevalidationMode() const =0 Get the revalidation mode.
Returnsthe revalidation mode.getStaticCollectionManagerStaticCollectionManager * getStaticCollectionManager() const =0 Returns a CollectionManager responsible for all collections which are statically declared in this static context. The collection manager provides a set of functions for managing collections and their contents. ReturnsThe collection manager responsible for managing collections of this context.getURIPathvoid getURIPath(std::vector< String > &aURIPath) const =0 Return the URI lookup path (list of filesystem directories) for this static context. Returns any values set by StaticContext::setURIPath() on this static context. To return the full URI lookup path for this static context and all its parents (usually most useful), call StaticContext::getFullURIPath(). getXPath1_0CompatibModexpath1_0compatib_mode_t getXPath1_0CompatibMode() const =0 Get the XPath 1.0 compatibility mode. (see http://www.w3.org/TR/xquery/#static_context) Returnsxpath1_0compatib_mode_t the XPath 1.0 compatibility mode.getXQueryVersionxquery_version_t getXQueryVersion() const =0 invokeItemSequence_t invoke(const Item &aQName, const std::vector< ItemSequence_t > &aArgs) const =0 Invokes the XQuery function with the given name and the given parameters. Note that the function to be invoked needs to be declared in this static context. In order to declare a function in the static context, the loadProlog method of this class can be used.Also note that if the function to be invoked is an updating function, its resulting pending update list is implicitly applied by this function. Parameters
ReturnsThe result of the function that is invoked. If the function to be invoked is an updating function, the resulting item sequence is empty.loadPrologvoid loadProlog(const String &, const Zorba_CompilerHints_t &hints)=0 Loads the declarations and definitions of a given XQuery prolog into this static context. This function compiles the prolog passed as first parameter and loads all declarations and definitions into this static context.The static context extended by this prolog can then be used for creating a compiling a new query.A StaticException is raised if the prolog could not be compiled or if the prolog does not contain valid declarations (e.g. duplicate declarations). registerModulebool registerModule(ExternalModule *aModule)=0 Register a module providing access to external functions. Register a module that provides access to external functions. The caller keeps the ownership of the Module and the StatelessExternalFunction objects passed to this function. Parameters
Returnstrue if the module has been set, false otherwise.registerURIMappervoid registerURIMapper(URIMapper *aMapper)=0 Register a URI Mapper which will transform a given URI into several alternate potential URIs. QQQ doc registerURLResolvervoid registerURLResolver(URLResolver *aResolver)=0 Register a URL Resolver which will transform a given URL into a Resource. QQQ doc removeReferencevoid removeReference()
resetTraceStreamvoid resetTraceStream()=0 Resets the output stream that is used by the fn:trace function to std::cerr.
resolveString resolve(const String &aRelativeUri) const =0 Resolves the given URI against the value of the base-uri property from the static context.
Parameters
resolveString resolve(const String &aRelativeUri, const String &aBaseUri) const =0 Resolves the given relative URI against the absolute base URI.
Parameters
setAuditEventvoid setAuditEvent(audit::Event *anEvent)=0 sets the audit event that will be populated during execution
Parameters
setBaseURIbool setBaseURI(const String &aBaseURI)=0 Set the base URI. (see http://www.w3.org/TR/xquery/#static_context) Parameters
Returnstrue if the base URI has been set, false otherwise.setBoundarySpacePolicybool setBoundarySpacePolicy(boundary_space_mode_t aMode)=0 Set the boundary space policy. (see http://www.w3.org/TR/xquery/#static_context) Parameters
Returnstrue if the mode was set, false otherwise.setCollectionTypevoid setCollectionType(const String &aCollectionUri, const SequenceType &type)=0 Set the type of a statically known collection.
setConstructionModebool setConstructionMode(construction_mode_t aMode)=0 Set the construction mode. (see http://www.w3.org/TR/xquery/#static_context) Parameters
Returnstrue if the mode was set, false otherwise.setContextItemStaticTypevoid setContextItemStaticType(const SequenceType &type)=0 Set the type of the context item.
setCopyNamespacesModebool setCopyNamespacesMode(preserve_mode_t aPreserve, inherit_mode_t aInherit)=0 Set the copy namespace mode. (see http://www.w3.org/TR/xquery/#static_context) Parameters
Returnstrue if the mode was set, false otherwise.setDefaultCollationvoid setDefaultCollation(const String &aURI)=0 Set the URI of the default collation. (see http://www.w3.org/TR/xquery/#static_context) Parameters
Parameters
setDefaultElementAndTypeNamespacebool setDefaultElementAndTypeNamespace(const String &aURI)=0 Set the default element and type namespace (see http://www.w3.org/TR/xquery/#static_context)
Parameters
Returnstrue if the default element and type namespace URI has been set, false otherwise if an DiagnosticHandler has been registered.Parameters
setDefaultFunctionNamespacebool setDefaultFunctionNamespace(const String &aURI)=0 Set the default functionnamespace (see http://www.w3.org/TR/xquery/#static_context)
Parameters
Returnstrue if the default function namespace URI has been set, false otherwise if an DiagnosticHandler has been registered.Parameters
setDefaultFunctionNamespacesbool setDefaultFunctionNamespaces(const std::vector< String > &aURIs)=0 Sets a list of default function namespaces that will be used in order during the lookup of functions.
Parameters
Returnstrue if the said namespaces have been set, false otherwise if an DiagnosticHandler has been registered.Parameters
setDefaultOrderForEmptySequencesbool setDefaultOrderForEmptySequences(order_empty_mode_t aMode)=0 Set the default order for the empty sequence. (see http://www.w3.org/TR/xquery/#static_context) Parameters
Returnstrue if the mode was set, false otherwise.setDocumentTypevoid setDocumentType(const String &aDocUri, const SequenceType &type)=0 Set the type of a statically known document.
setJSONiqVersionbool setJSONiqVersion(jsoniq_version_t aMode)=0 Set the JSONiq processing mode.
Parameters
Returnstrue if the version was set, false otherwise.setLibPathvoid setLibPath(const std::vector< String > &aLibPath)=0 Set the library lookup path (list of filesystem directories) for this static context. Queries which import modules that have external function implementations will look for the implementation of those functions (shared libraries) in these directories. setModulePathsvoid setModulePaths(const std::vector< String > &aModulePaths)=0 Set the URI and library lookup paths (lists of filesystem directories) for this static context.
Note that calling this method will override any values previously passed to StaticContext::setURIPath() and StaticContext::setLibPath(). setOrderingModebool setOrderingMode(ordering_mode_t aMode)=0 Set the ordering mode. (see http://www.w3.org/TR/xquery/#static_context) Parameters
Returnstrue if the mode was set, false otherwise.setRevalidationModevoid setRevalidationMode(validation_mode_t aMode)=0 Set the revalidation mode.
Parameters
setTraceStreamvoid setTraceStream(std::ostream &)=0 Set the output stream that is used by the fn:trace function. Sets the output stream that is used by the fn:trace function to the given output stream. The default stream is std::cerr. setURIPathvoid setURIPath(const std::vector< String > &aURIPath)=0 Set the URI lookup path (list of filesystem directories) for this static context. Queries which resolve URIs (for instance, importing modules or schemas) will look in these directories. setXPath1_0CompatibModebool setXPath1_0CompatibMode(xpath1_0compatib_mode_t aMode)=0 Set the XPath 1.0 compatibility mode. (see http://www.w3.org/TR/xquery/#static_context) Parameters
Returnstrue if the mode was set, false otherwise.setXQueryVersionbool setXQueryVersion(xquery_version_t aMode)=0 validatebool validate(const Item &rootElement, Item &validatedResult, validation_mode_t validationMode=validate_strict) const =0 Validates this Item. Note: works only on document and element nodes, otherwise returns false. Parameters
Returnstrue if validation is correct, false if validation is disabled, throws errors if validation failsParameters
validatebool validate(const Item &rootElement, Item &validatedResult, const String &targetNamespace, validation_mode_t validationMode=validate_strict) const =0 Validates this Item while loading the schema for targetNamespace Note: works only on document or element nodes, otherwise returns false.
Parameters
Returnstrue if validation is correct, false if validation is disabled, throws errors if validation failsParameters
validateSimpleContentbool validateSimpleContent(const String &stringValue, const Item &typeQName, std::vector< Item > &resultList) const =0 Validates stringValue as XML simple content, i.e. the text value of attributes or text only element content. Parameters
Returnstrue if validation is correct, false if validation is disabled, throws errors if validation failsParameters
~StaticContext ~StaticContext() Destructor.
Protected AttributestheRefCountunsigned int theRefCount
|