StaticContext

#include </home/jenkins/.jenkins/ubuntu-remote-queue/jenkins-BuildZorbaUbuntu-462/source/zorba/swig/StaticContext.h>

Instances of the class StaticContext contain the information that is available at the time the query is compiled. 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.

Friend Classes

friend class

SequenceType

friend class

XQuery

friend class

Zorba

Private Attributes

zorba::StaticContext_t

theStaticContext

Public Functions

void

addColation(const std::string &aURI)

Adds a collation URI.

bool

addNamespace(const std::string &aPrefix, const std::string &aURI)

Add a pair (prefix, URI) to the statically known namespaces that are available during query compilation.

bool

containsFunction(const std::string &aFnNameUri, const std::string &aFnNameLocal, int arity) const

Check if a function with the given name and arity are registered in the context.

StaticContext

createChildContext() const

Create a child static context, i.e.

void

declareOption(const Item &aQName, const std::string &aOptionVal)

Declare an option (same as using declare option in XQuery)

void

destroy()

Destroy this object from memory.

void

disableFunction(const Item &aQName, int arity)

std::string

getBaseURI() const

Get the base URI.

ZorbaConstants::BoundarySpaceMode

getBoundarySpacePolicy()

Get the boundary space policy.

SequenceType

getCollectionType(const std::string &aCollectionUri)

Get the type of a statically known collection.

ZorbaConstants::ConstructionMode

getConstructionMode()

Get the construction mode.

SequenceType

getContextItemStaticType()

Fetch the type of the context item.

ZorbaConstants::InheritMode

getCopyNamespacesModeInherit()

Get the copy namespace mode for Preserve.

ZorbaConstants::PreserveMode

getCopyNamespacesModePreserve()

Get the copy namespace mode for Preserve.

std::string

getDefaultCollation() const

Get the URI of the default collation.

std::string

getDefaultElementAndTypeNamespace() const

Get the default element and type namespace URI.

std::string

getDefaultFunctionNamespace() const

Get the default function namespace.

ZorbaConstants::OrderEmptyMode

getDefaultOrderForEmptySequences()

Get the default order for the empty sequence.

SequenceType

getDocumentType(const std::string &aDocUri)

Get the type of a statically known document.

void

getExternalVariables(Iterator &vars) const

Returns the QName of all external variables within the static context.

std::vector< std::pair< std::string, std::string > >

getNamespaceBindings()

Get the list of all namespace bindings (prefix, uri) declared in this and its parent static contexts.

std::string

getNamespaceURIByPrefix(const std::string &aPrefix) const

Get the namespace URI for a given prefix.

bool

getOption(const Item &aQName, std::string &aOptionValue) const

Get an option that was declared using the declare option syntax.

ZorbaConstants::OrderingMode

getOrderingMode()

Get the ordering mode.

ZorbaConstants::RevalidationMode

getRevalidationMode()

Get the revalidation mode.

StaticCollectionManager

getStaticCollectionManager()

Returns a CollectionManager responsible for all collections which are statically declared in this static context.

ZorbaConstants::XPath1_0CompatibleMode

getXPath1_0CompatibMode()

Get the XPath 1.0 compatibility mode.

void

loadProlog(const std::string &aProlog, const CompilerHints &hints)

Loads the declarations and definitions of a given XQuery prolog into this static context.

void

resetTraceStream()

Resets the output stream that is used by the fn:trace function to std::cerr.

bool

setBaseURI(const std::string &aBaseURI)

Set the base URI.

bool

setBoundarySpacePolicy(ZorbaConstants::BoundarySpaceMode aMode)

Set the boundary space policy.

bool

setConstructionMode(ZorbaConstants::ConstructionMode aMode)

Set the construction mode.

void

setContextItemStaticType(const SequenceType &aType)

Set the type of the context item.

bool

setCopyNamespacesMode(ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit)

Set the copy namespace mode.

void

setDefaultCollation(const std::string &aURI)

Set the URI of the default collation.

bool

setDefaultElementAndTypeNamespace(const std::string &aURI)

Set the default element and type namespace (see http://www.w3.org/TR/xquery/#static_context)

bool

setDefaultFunctionNamespace(const std::string &aURI)

Set the default functionnamespace (see http://www.w3.org/TR/xquery/#static_context)

bool

setDefaultOrderForEmptySequences(ZorbaConstants::OrderEmptyMode aMode)

Set the default order for the empty sequence.

void

setLIBPath(std::vector< std::string > &aLIBPath)

Set the library lookup path (list of filesystem directories) for this static context.

void

setModulePath(std::vector< std::string > &aModulePath)

Set the URI and library lookup paths (lists of filesystem directories) for this static context.

bool

setOrderingMode(ZorbaConstants::OrderingMode aMode)

Set the ordering mode.

void

setRevalidationMode(ZorbaConstants::RevalidationMode aMode)

Set the revalidation mode.

void

setURIPath(std::vector< std::string > &aURIPath)

Set the URI lookup path (list of filesystem directories) for this static context.

bool

setXPath1_0CompatibMode(ZorbaConstants::XPath1_0CompatibleMode aMode)

Set the XPath 1.0 compatibility mode.

StaticContext(const StaticContext &aStaticContext)

StaticContext(zorba::StaticContext_t aStaticContext)

Friend Classes

SequenceType

friend class SequenceType

XQuery

friend class XQuery

Zorba

friend class Zorba

Private Attributes

theStaticContext

zorba::StaticContext_t theStaticContext

Public Functions

addColation

void addColation(const std::string &aURI)

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

aURI the URI of the collation.

Parameters

ZorbaException if an error occured (e.g. the URI was not a valid collation URI).

addNamespace

bool addNamespace(const std::string &aPrefix, const std::string &aURI)

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.

Parameters

aPrefix the prefix String.
aURI the URI String.

Returns

true if the pair was added to the set of statically known namespaces, false otherwise.

Parameters

ZorbaException if an error occures.

containsFunction

bool containsFunction(const std::string &aFnNameUri, const std::string &aFnNameLocal, int arity) const

Check if a function with the given name and arity are registered in the context.

createChildContext

StaticContext createChildContext() const

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.

declareOption

void declareOption(const Item &aQName, const std::string &aOptionVal)

Declare an option (same as using declare option in XQuery)

Parameters

aQName The QName of the option to declare.
aOptionVal The value of the option to declare.

destroy

void destroy()

Destroy this object from memory.

disableFunction

void disableFunction(const Item &aQName, int arity)

getBaseURI

std::string getBaseURI() const

Get the base URI.

Returns

String the base URI.

getBoundarySpacePolicy

ZorbaConstants::BoundarySpaceMode getBoundarySpacePolicy()

Get the boundary space policy.

(see http://www.w3.org/TR/xquery/#static_context)

Returns

boundary_space_mode_t the boundary space policy.

getCollectionType

SequenceType getCollectionType(const std::string &aCollectionUri)

Get the type of a statically known collection.

getConstructionMode

ZorbaConstants::ConstructionMode getConstructionMode()

Get the construction mode.

(see http://www.w3.org/TR/xquery/#static_context)

Returns

construction_mode_t the construction mode.

getContextItemStaticType

SequenceType getContextItemStaticType()

Fetch the type of the context item.

getCopyNamespacesModeInherit

ZorbaConstants::InheritMode getCopyNamespacesModeInherit()

Get the copy namespace mode for Preserve.

(see http://www.w3.org/TR/xquery/#static_context)

Returns

aInherit the inherit mode.

getCopyNamespacesModePreserve

ZorbaConstants::PreserveMode getCopyNamespacesModePreserve()

Get the copy namespace mode for Preserve.

(see http://www.w3.org/TR/xquery/#static_context)

Returns

aPreserve the preserve mode.

getDefaultCollation

std::string getDefaultCollation() const

Get the URI of the default collation.

Returns

String the URI of the default collation.

getDefaultElementAndTypeNamespace

std::string getDefaultElementAndTypeNamespace() const

Get the default element and type namespace URI.

Returns

String the URI for the default element and type namespace.

Parameters

ZorbaException if an error occured.

getDefaultFunctionNamespace

std::string getDefaultFunctionNamespace() const

Get the default function namespace.

Returns

String the URI of the default function namespace. DiagnosticHandler has been registered.

Parameters

ZorbaException if an error occured.

getDefaultOrderForEmptySequences

ZorbaConstants::OrderEmptyMode getDefaultOrderForEmptySequences()

Get the default order for the empty sequence.

(see http://www.w3.org/TR/xquery/#static_context)

Returns

order_empty_mode_t the ordering mode.

getDocumentType

SequenceType getDocumentType(const std::string &aDocUri)

Get the type of a statically known document.

getExternalVariables

void getExternalVariables(Iterator &vars) const

Returns the QName of all external variables within the static context.

Parameters

vars iterator to store the results.

Parameters

ZorbaException if an error occured.

getNamespaceBindings

std::vector< std::pair< std::string, std::string > > getNamespaceBindings()

Get the list of all namespace bindings (prefix, uri) declared in this and its parent static contexts.

getNamespaceURIByPrefix

std::string getNamespaceURIByPrefix(const std::string &aPrefix) const

Get the namespace URI for a given prefix.

Parameters

aPrefix the prefix for which to retrieve the namespace URI.

Returns

String 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

ZorbaException if an error occured (e.g. no URI could be found for the given prefix).
DeprecatedThis function is deprecated. Use getNamespaceBindings instead.

getOption

bool getOption(const Item &aQName, std::string &aOptionValue) const

Get an option that was declared using the declare option syntax.

Parameters

aQName The QName of the option to get.
aOptionValue The value of the option if found.

Returns

true if the option was found, false otherwise.

getOrderingMode

ZorbaConstants::OrderingMode getOrderingMode()

Get the ordering mode.

(see http://www.w3.org/TR/xquery/#static_context)

Returns

ordering_mode_t the ordering mode.

getRevalidationMode

ZorbaConstants::RevalidationMode getRevalidationMode()

Get the revalidation mode.

Returns

the revalidation mode.

getStaticCollectionManager

StaticCollectionManager getStaticCollectionManager()

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.

Returns

The collection manager responsible for managing collections of this context.

getXPath1_0CompatibMode

ZorbaConstants::XPath1_0CompatibleMode getXPath1_0CompatibMode()

Get the XPath 1.0 compatibility mode.

(see http://www.w3.org/TR/xquery/#static_context)

Returns

xpath1_0compatib_mode_t the XPath 1.0 compatibility mode.

loadProlog

void loadProlog(const std::string &aProlog, const CompilerHints &hints)

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).

resetTraceStream

void resetTraceStream()

Resets the output stream that is used by the fn:trace function to std::cerr.

setBaseURI

bool setBaseURI(const std::string &aBaseURI)

Set the base URI.

(see http://www.w3.org/TR/xquery/#static_context)

Parameters

aBaseURI the base URI as String.

Returns

true if the base URI has been set, false otherwise.

setBoundarySpacePolicy

bool setBoundarySpacePolicy(ZorbaConstants::BoundarySpaceMode aMode)

Set the boundary space policy.

(see http://www.w3.org/TR/xquery/#static_context)

Parameters

aMode the boundary space policy.

Returns

true if the mode was set, false otherwise.

setConstructionMode

bool setConstructionMode(ZorbaConstants::ConstructionMode aMode)

Set the construction mode.

(see http://www.w3.org/TR/xquery/#static_context)

Parameters

aMode the construction mode.

Returns

true if the mode was set, false otherwise.

setContextItemStaticType

void setContextItemStaticType(const SequenceType &aType)

Set the type of the context item.

setCopyNamespacesMode

bool setCopyNamespacesMode(ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit)

Set the copy namespace mode.

(see http://www.w3.org/TR/xquery/#static_context)

Parameters

aPreserve the preserve mode.
aInherit the inherit mode.

Returns

true if the mode was set, false otherwise.

setDefaultCollation

void setDefaultCollation(const std::string &aURI)

Set the URI of the default collation.

(see http://www.w3.org/TR/xquery/#static_context)

Parameters

aURI URI of the default collation.

Parameters

ZorbaException if an error occured (e.g., the URI does not identify a collation among the statically known collations.

setDefaultElementAndTypeNamespace

bool setDefaultElementAndTypeNamespace(const std::string &aURI)

Set the default element and type namespace (see http://www.w3.org/TR/xquery/#static_context)

Parameters

aURI of the default element and type namespace URI.

Returns

true if the default element and type namespace URI has been set, false otherwise if an DiagnosticHandler has been registered.

Parameters

ZorbaException if an error occured.

setDefaultFunctionNamespace

bool setDefaultFunctionNamespace(const std::string &aURI)

Set the default functionnamespace (see http://www.w3.org/TR/xquery/#static_context)

Parameters

aURI of the default function namespace.

Returns

true if the default function namespace URI has been set, false otherwise if an DiagnosticHandler has been registered.

Parameters

ZorbaException if an error occured.

setDefaultOrderForEmptySequences

bool setDefaultOrderForEmptySequences(ZorbaConstants::OrderEmptyMode aMode)

Set the default order for the empty sequence.

(see http://www.w3.org/TR/xquery/#static_context)

Parameters

aMode the default order for the empty sequence.

Returns

true if the mode was set, false otherwise.

setLIBPath

void setLIBPath(std::vector< std::string > &aLIBPath)

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.

setModulePath

void setModulePath(std::vector< std::string > &aModulePath)

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(). DeprecatedUse StaticContext::setURIPath() and StaticContext::setLibPath().Convenience method which adds the listed directories to both the URI path and Library path for this static context.

setOrderingMode

bool setOrderingMode(ZorbaConstants::OrderingMode aMode)

Set the ordering mode.

(see http://www.w3.org/TR/xquery/#static_context)

Parameters

aMode the ordering mode.

Returns

true if the mode was set, false otherwise.

setRevalidationMode

void setRevalidationMode(ZorbaConstants::RevalidationMode aMode)

Set the revalidation mode.

Parameters

aMode the revalidation mode.

setURIPath

void setURIPath(std::vector< std::string > &aURIPath)

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_0CompatibMode

bool setXPath1_0CompatibMode(ZorbaConstants::XPath1_0CompatibleMode aMode)

Set the XPath 1.0 compatibility mode.

(see http://www.w3.org/TR/xquery/#static_context)

Parameters

aMode the XPath 1.0 compatibility mode.

Returns

true if the mode was set, false otherwise.

StaticContext

 StaticContext(const StaticContext &aStaticContext)

StaticContext

 StaticContext(zorba::StaticContext_t aStaticContext)