Public Member Functions | Friends | List of all members
StaticContext Class Reference

Instances of the class StaticContext contain the information that is available at the time the query is compiled. More...

Public Member 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.
TypeIdentifier getCollectionType (const std::string &aCollectionUri)
 Get the type of a statically known collection.
ZorbaConstants::ConstructionMode getConstructionMode ()
 Get the construction mode.
TypeIdentifier 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.
TypeIdentifier 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 TypeIdentifier &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)

Friends

class XQuery
class Zorba

Detailed Description

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.

Definition at line 79 of file StaticContext.h.

Constructor & Destructor Documentation

StaticContext::StaticContext ( const StaticContext aStaticContext)
StaticContext::StaticContext ( zorba::StaticContext_t  aStaticContext)

Member Function Documentation

void StaticContext::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://www.zorba-xquery.com/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://www.zorba-xquery.com/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
aURIthe URI of the collation.
Exceptions
ZorbaExceptionif an error occured (e.g. the URI was not a valid collation URI).
bool StaticContext::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
aPrefixthe prefix String.
aURIthe URI String.
Returns
true if the pair was added to the set of statically known namespaces, false otherwise.
Exceptions
ZorbaExceptionif an error occures.
bool StaticContext::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 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.

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

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

Parameters
aQNameThe QName of the option to declare.
aOptionValThe value of the option to declare.
void StaticContext::destroy ( )

Destroy this object from memory.

void StaticContext::disableFunction ( const Item aQName,
int  arity 
)
std::string StaticContext::getBaseURI ( ) const

Get the base URI.

Returns
String the base URI.
ZorbaConstants::BoundarySpaceMode StaticContext::getBoundarySpacePolicy ( )

Get the boundary space policy.

    (see http://www.w3.org/TR/xquery/#static_context)
Returns
boundary_space_mode_t the boundary space policy.
TypeIdentifier StaticContext::getCollectionType ( const std::string &  aCollectionUri)

Get the type of a statically known collection.

ZorbaConstants::ConstructionMode StaticContext::getConstructionMode ( )

Get the construction mode.

    (see http://www.w3.org/TR/xquery/#static_context)
Returns
construction_mode_t the construction mode.
TypeIdentifier StaticContext::getContextItemStaticType ( )

Fetch the type of the context item.

ZorbaConstants::InheritMode StaticContext::getCopyNamespacesModeInherit ( )

Get the copy namespace mode for Preserve.

    (see http://www.w3.org/TR/xquery/#static_context)
Returns
aInherit the inherit mode.
ZorbaConstants::PreserveMode StaticContext::getCopyNamespacesModePreserve ( )

Get the copy namespace mode for Preserve.

    (see http://www.w3.org/TR/xquery/#static_context)
Returns
aPreserve the preserve mode.
std::string StaticContext::getDefaultCollation ( ) const

Get the URI of the default collation.

Returns
String the URI of the default collation.
std::string StaticContext::getDefaultElementAndTypeNamespace ( ) const

Get the default element and type namespace URI.

Returns
String the URI for the default element and type namespace.
Exceptions
ZorbaExceptionif an error occured.
std::string StaticContext::getDefaultFunctionNamespace ( ) const

Get the default function namespace.

Returns
String the URI of the default function namespace. DiagnosticHandler has been registered.
Exceptions
ZorbaExceptionif an error occured.
ZorbaConstants::OrderEmptyMode StaticContext::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.
TypeIdentifier StaticContext::getDocumentType ( const std::string &  aDocUri)

Get the type of a statically known document.

void StaticContext::getExternalVariables ( Iterator vars) const

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

Parameters
varsiterator to store the results.
Exceptions
ZorbaExceptionif an error occured.
std::vector< std::pair< std::string, std::string > > StaticContext::getNamespaceBindings ( )

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

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

Get the namespace URI for a given prefix.

Parameters
aPrefixthe 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.
Exceptions
ZorbaExceptionif an error occured (e.g. no URI could be found for the given prefix).
Deprecated:
This function is deprecated. Use getNamespaceBindings instead.
bool StaticContext::getOption ( const Item aQName,
std::string &  aOptionValue 
) const

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

Parameters
aQNameThe QName of the option to get.
aOptionValueThe value of the option if found.
Returns
true if the option was found, false otherwise.
ZorbaConstants::OrderingMode StaticContext::getOrderingMode ( )

Get the ordering mode.

    (see http://www.w3.org/TR/xquery/#static_context)
Returns
ordering_mode_t the ordering mode.
ZorbaConstants::RevalidationMode StaticContext::getRevalidationMode ( )

Get the revalidation mode.

Returns
the revalidation mode.
StaticCollectionManager StaticContext::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.
ZorbaConstants::XPath1_0CompatibleMode StaticContext::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.
void StaticContext::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).

void StaticContext::resetTraceStream ( )

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

bool StaticContext::setBaseURI ( const std::string &  aBaseURI)

Set the base URI.

    (see http://www.w3.org/TR/xquery/#static_context)
Parameters
aBaseURIthe base URI as String.
Returns
true if the base URI has been set, false otherwise.
bool StaticContext::setBoundarySpacePolicy ( ZorbaConstants::BoundarySpaceMode  aMode)

Set the boundary space policy.

    (see http://www.w3.org/TR/xquery/#static_context)
Parameters
aModethe boundary space policy.
Returns
true if the mode was set, false otherwise.
bool StaticContext::setConstructionMode ( ZorbaConstants::ConstructionMode  aMode)

Set the construction mode.

    (see http://www.w3.org/TR/xquery/#static_context)
Parameters
aModethe construction mode.
Returns
true if the mode was set, false otherwise.
void StaticContext::setContextItemStaticType ( const TypeIdentifier aType)

Set the type of the context item.

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

Set the copy namespace mode.

    (see http://www.w3.org/TR/xquery/#static_context)
Parameters
aPreservethe preserve mode.
aInheritthe inherit mode.
Returns
true if the mode was set, false otherwise.
void StaticContext::setDefaultCollation ( const std::string &  aURI)

Set the URI of the default collation.

    (see http://www.w3.org/TR/xquery/#static_context)
Parameters
aURIURI of the default collation.
Exceptions
ZorbaExceptionif an error occured (e.g., the URI does not identify a collation among the statically known collations.
bool StaticContext::setDefaultElementAndTypeNamespace ( const std::string &  aURI)

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

Parameters
aURIof 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.
Exceptions
ZorbaExceptionif an error occured.
bool StaticContext::setDefaultFunctionNamespace ( const std::string &  aURI)

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

Parameters
aURIof the default function namespace.
Returns
true if the default function namespace URI has been set, false otherwise if an DiagnosticHandler has been registered.
Exceptions
ZorbaExceptionif an error occured.
bool StaticContext::setDefaultOrderForEmptySequences ( ZorbaConstants::OrderEmptyMode  aMode)

Set the default order for the empty sequence.

    (see http://www.w3.org/TR/xquery/#static_context)
Parameters
aModethe default order for the empty sequence.
Returns
true if the mode was set, false otherwise.
void StaticContext::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.

void StaticContext::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().

Deprecated:
Use StaticContext::setURIPath() and StaticContext::setLibPath().

Convenience method which adds the listed directories to both the URI path and Library path for this static context.

bool StaticContext::setOrderingMode ( ZorbaConstants::OrderingMode  aMode)

Set the ordering mode.

    (see http://www.w3.org/TR/xquery/#static_context)
Parameters
aModethe ordering mode.
Returns
true if the mode was set, false otherwise.
void StaticContext::setRevalidationMode ( ZorbaConstants::RevalidationMode  aMode)

Set the revalidation mode.

Parameters
aModethe revalidation mode.
void StaticContext::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.

bool StaticContext::setXPath1_0CompatibMode ( ZorbaConstants::XPath1_0CompatibleMode  aMode)

Set the XPath 1.0 compatibility mode.

    (see http://www.w3.org/TR/xquery/#static_context)
Parameters
aModethe XPath 1.0 compatibility mode.
Returns
true if the mode was set, false otherwise.

Friends And Related Function Documentation

friend class XQuery
friend

Definition at line 82 of file StaticContext.h.

friend class Zorba
friend

Definition at line 81 of file StaticContext.h.


The documentation for this class was generated from the following file:
blog comments powered by Disqus