org.ucl.xpath
Class DefaultStaticContext

java.lang.Object
  extended byorg.ucl.xpath.DefaultStaticContext
All Implemented Interfaces:
StaticContext
Direct Known Subclasses:
DefaultDynamicContext

public class DefaultStaticContext
extends java.lang.Object
implements StaticContext

Default implementation of a static context as described by the XPath 2.0 specification.


Constructor Summary
DefaultStaticContext()
          Constructor for schema-less documents.
DefaultStaticContext(org.apache.xerces.xs.XSModel schema)
          Constructor.
 
Method Summary
 void add_function_library(FunctionLibrary fl)
          Adds a function to the library.
 void add_namespace(java.lang.String prefix, java.lang.String namespace)
          adds namespace
 void add_variable(QName var)
          Adds a variable to current scope.
 boolean attribute_declared(QName attr)
          Checks if an attribute is in the in-scope schema definitions.
 org.apache.xerces.xs.XSTypeDefinition attribute_type_definition(QName elem)
          Retrieves type definition of the attribute in an element.
 XSAnyURI base_uri()
          return the base URI
 void debug_print_vars()
          Debug function which will print current variable scopes and info.
 java.lang.String default_function_namespace()
          Retrieves the defaul function namespace
 java.lang.String default_namespace()
          Retrieves the default namespace, when one is not allocated
 boolean del_variable(QName var)
          Deletes a variable from current scope.
 boolean derives_from(NodeType at, QName et)
          Checks if an XML node derives from a specified type.
 boolean derives_from(NodeType at, org.apache.xerces.xs.XSTypeDefinition et)
          Checks if an XML node derives from a specified type definition.
 void destroy_scope()
          Destroys a scope.
 boolean element_declared(QName elem)
          is element declared?
 org.apache.xerces.xs.XSTypeDefinition element_type_definition(QName elem)
          Obtains schema definition of the type of an element.
 boolean expand_elem_type_qname(QName name)
          Expands a qname and uses the default type/element namespace if unprefixed.
 boolean expand_function_qname(QName name)
          Expands a qname and uses the default function namespace if unprefixed.
 boolean expand_qname(QName name)
          Expands the qname's prefix into a namespace.
 boolean function_exists(QName name, int arity)
          Check for existance of function.
protected  Function function(QName name, int arity)
           
protected  AnyType get_var(QName var)
           
 AnyAtomicType make_atomic(QName name)
          Creates an atomic from a specific type name initialized with a default value.
 void new_scope()
          Creates a new scope level.
 boolean prefix_exists(java.lang.String pref)
          does prefix exist?
 java.lang.String resolve_prefix(java.lang.String pref)
          Resolves a prefix into a namespace URI.
protected  void set_variable(QName var, AnyType val)
           
 boolean type_defined(QName qname)
          Checks whether the type is defined in the in scope schema definitions.
 boolean type_defined(java.lang.String ns, java.lang.String type)
          Checks whether the type is defined in the in scope schema definitions.
 boolean variable_exists(QName var)
          does variable exist in current scope ?
 boolean variable_in_scope(QName var)
          checks to see if variable is in scope
 boolean xpath1_compatible()
          is it xpath1 compatible?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultStaticContext

public DefaultStaticContext(org.apache.xerces.xs.XSModel schema)
Constructor.

Parameters:
schema - Schema information from document. May be null.

DefaultStaticContext

public DefaultStaticContext()
Constructor for schema-less documents.

Method Detail

base_uri

public XSAnyURI base_uri()
return the base URI

Specified by:
base_uri in interface StaticContext
Returns:
XSAnyURI

xpath1_compatible

public boolean xpath1_compatible()
is it xpath1 compatible?

Specified by:
xpath1_compatible in interface StaticContext
Returns:
boolean

add_namespace

public void add_namespace(java.lang.String prefix,
                          java.lang.String namespace)
adds namespace

Specified by:
add_namespace in interface StaticContext
Parameters:
prefix - namespace prefix
namespace - namespace URI

default_namespace

public java.lang.String default_namespace()
Retrieves the default namespace, when one is not allocated

Specified by:
default_namespace in interface StaticContext
Returns:
string

default_function_namespace

public java.lang.String default_function_namespace()
Retrieves the defaul function namespace

Specified by:
default_function_namespace in interface StaticContext
Returns:
string

add_function_library

public void add_function_library(FunctionLibrary fl)
Adds a function to the library.

Specified by:
add_function_library in interface StaticContext
Parameters:
fl - Function library to add.

function_exists

public boolean function_exists(QName name,
                               int arity)
Check for existance of function.

Specified by:
function_exists in interface StaticContext
Parameters:
name - function name.
arity - arity of function.
Returns:
true if function exists. False otherwise.

function

protected Function function(QName name,
                            int arity)

make_atomic

public AnyAtomicType make_atomic(QName name)
Creates an atomic from a specific type name initialized with a default value.

Specified by:
make_atomic in interface StaticContext
Parameters:
name - name of type to create
Returns:
Atomic type of desired type.

expand_qname

public boolean expand_qname(QName name)
Expands the qname's prefix into a namespace.

Specified by:
expand_qname in interface StaticContext
Parameters:
name - qname to expand.
Returns:
true on success.

expand_function_qname

public boolean expand_function_qname(QName name)
Expands a qname and uses the default function namespace if unprefixed.

Specified by:
expand_function_qname in interface StaticContext
Parameters:
name - qname to expand.
Returns:
true on success.

expand_elem_type_qname

public boolean expand_elem_type_qname(QName name)
Expands a qname and uses the default type/element namespace if unprefixed.

Specified by:
expand_elem_type_qname in interface StaticContext
Parameters:
name - qname to expand.
Returns:
true on success.

type_defined

public boolean type_defined(QName qname)
Checks whether the type is defined in the in scope schema definitions.

Specified by:
type_defined in interface StaticContext
Parameters:
qname - type name.
Returns:
true if type is defined.

type_defined

public boolean type_defined(java.lang.String ns,
                            java.lang.String type)
Checks whether the type is defined in the in scope schema definitions.

Parameters:
ns - namespace of type.
type - name of type.
Returns:
true if type is defined.

element_declared

public boolean element_declared(QName elem)
is element declared?

Specified by:
element_declared in interface StaticContext
Parameters:
elem - name of element.
Returns:
true if element declared.

element_type_definition

public org.apache.xerces.xs.XSTypeDefinition element_type_definition(QName elem)
Obtains schema definition of the type of an element.

Specified by:
element_type_definition in interface StaticContext
Parameters:
elem - name of element who's type is desired.
Returns:
schema definition of type

attribute_declared

public boolean attribute_declared(QName attr)
Checks if an attribute is in the in-scope schema definitions.

Specified by:
attribute_declared in interface StaticContext
Parameters:
attr - name of attribute.
Returns:
true if attribute is declared.

attribute_type_definition

public org.apache.xerces.xs.XSTypeDefinition attribute_type_definition(QName elem)
Retrieves type definition of the attribute in an element.

Specified by:
attribute_type_definition in interface StaticContext
Parameters:
elem - element name
Returns:
schema definition of the type of the attribute

prefix_exists

public boolean prefix_exists(java.lang.String pref)
does prefix exist?

Specified by:
prefix_exists in interface StaticContext
Parameters:
pref - prefix name.
Returns:
true if it does.

resolve_prefix

public java.lang.String resolve_prefix(java.lang.String pref)
Resolves a prefix into a namespace URI.

Specified by:
resolve_prefix in interface StaticContext
Parameters:
pref - prefix name
Returns:
uri prefix is resolved to or null.

derives_from

public boolean derives_from(NodeType at,
                            QName et)
Checks if an XML node derives from a specified type.

Specified by:
derives_from in interface StaticContext
Parameters:
at - node actual type
et - name of expected type
Returns:
true if a derivation exists

derives_from

public boolean derives_from(NodeType at,
                            org.apache.xerces.xs.XSTypeDefinition et)
Checks if an XML node derives from a specified type definition.

Specified by:
derives_from in interface StaticContext
Parameters:
at - node actual type.
et - type definition of expected type.
Returns:
true if a derivation exists.

new_scope

public void new_scope()
Creates a new scope level.

Specified by:
new_scope in interface StaticContext

destroy_scope

public void destroy_scope()
Destroys a scope.

Specified by:
destroy_scope in interface StaticContext

variable_exists

public boolean variable_exists(QName var)
does variable exist in current scope ?

Specified by:
variable_exists in interface StaticContext
Parameters:
var - variable name.
Returns:
true if it does.

variable_in_scope

public boolean variable_in_scope(QName var)
checks to see if variable is in scope

Specified by:
variable_in_scope in interface StaticContext
Parameters:
var - variable name.
Returns:
true if variable is in current or above scope.

add_variable

public void add_variable(QName var)
Adds a variable to current scope. used for static checking.... i.e. presence of variables

Specified by:
add_variable in interface StaticContext
Parameters:
var - variable name to add.

set_variable

protected void set_variable(QName var,
                            AnyType val)

del_variable

public boolean del_variable(QName var)
Deletes a variable from current scope.

Specified by:
del_variable in interface StaticContext
Parameters:
var - variable name to delete.
Returns:
false if variable doesn't exist.

get_var

protected AnyType get_var(QName var)

debug_print_vars

public void debug_print_vars()
Debug function which will print current variable scopes and info.