Author(s): Per Cederberg.
Context sensitivity can be interesting for several different purposes, having different requirements on the context predicates. This module is an attempt at creating a uniform and general purpose interface for the context predicates needed.
The framework in this module is based on generic operators, calling the appropriate implementing predicate. All to avoid a massive amount of different predicates in the interface. Currently the framework within this module supports WSDL and HTML contexts, but it can be easily exendible for other types of terms.
context
):- use_module(library(context)).
html2context/3
,
wsdl2context/3
,
context_type/2
,
context_attribute/3
,
context_data/2
,
context_depth/2
,
context_position/2
,
context_type_position/2
,
context_children/2
,
context_parent/2
,
context_ancestor/2
,
context_child/2
,
context_descendant/2
,
context_sibling/2
.
context/1
.
context
)
Usage: context(T)
T
is a context.
regtype/1
)
Usage 1: html2context(HTMLNode,HTMLTree,Context)
Context
term for a HTMLNode
that is a descendant from a top HTMLTree
node.
HTMLNode
is any term.
(term/1
)
HTMLTree
is any term.
(term/1
)
Context
is a free variable.
(var/1
)
Context
is a context.
(context/1
)
Usage 2: html2context(HTMLNode,HTMLTree,Context)
HTMLNode
and HTMLTree
nodes from a Context
term.
HTMLNode
is a free variable.
(var/1
)
HTMLTree
is a free variable.
(var/1
)
Context
is a context.
(context/1
)
HTMLNode
is any term.
(term/1
)
HTMLTree
is any term.
(term/1
)
Usage 1: wsdl2context(WSDLNode,WSDLTree,Context)
Context
term for a WSDLNode
that is a descendant from a top WSDLTree
node.
WSDLNode
is any term.
(term/1
)
WSDLTree
is any term.
(term/1
)
Context
is a free variable.
(var/1
)
Context
is a context.
(context/1
)
Usage 2: wsdl2context(WSDLNode,WSDLTree,Context)
WSDLNode
and WSDLTree
nodes from a Context
term.
WSDLNode
is a free variable.
(var/1
)
WSDLTree
is a free variable.
(var/1
)
Context
is a context.
(context/1
)
WSDLNode
is any term.
(term/1
)
WSDLTree
is any term.
(term/1
)
Usage: context_type(Context,NodeType)
NodeType
for the Context
.
Context
is a context.
(context/1
)
NodeType
is currently instantiated to an atom.
(atom/1
)
Usage: context_attribute(Context,Name,Value)
Name
s Value
in the Context
. The predicate fails if there is no attribute named Name
.
Context
is a context.
(context/1
)
Name
is currently instantiated to an atom.
(atom/1
)
Value
is currently instantiated to an atom.
(atom/1
)
Usage: context_data(Context,DataLs)
Context
. The data will be returned in a list (DataLs
), but the list element type depends on the type of context. No nodes will be present in the list.
Context
is a context.
(context/1
)
DataLs
is a list.
(list/1
)
Usage: context_depth(Context,Depth)
Depth
of the Context
.
Context
is a context.
(context/1
)
Depth
is an integer.
(int/1
)
Usage: context_position(Context,ChildNumber)
ChildNumber
, i.e. the position of the Context
in the parent child list. The predicate fails if the Context
hasn't got a parent.
Context
is a context.
(context/1
)
ChildNumber
is an integer.
(int/1
)
Usage: context_type_position(Context,ChildNumber)
ChildNumber
, i.e. the position of the Context
in the parent child list, only considering the siblings of the same type. The predicate fails if the Context
hasn't got a parent.
Context
is a context.
(context/1
)
ChildNumber
is an integer.
(int/1
)
Usage: context_children(Context,NumberOfChildren)
NumberOfChildren
to a Context
node.
Context
is a context.
(context/1
)
NumberOfChildren
is an integer.
(int/1
)
Usage: context_parent(Context,ParentContext)
ParentContext
to a Context
.
Parent
is a context.
(context/1
)
ParentContext
is a context.
(context/1
)
Usage: context_ancestor(Context,AncestorContext)
AncestorContext
to a Context
. Upon backtracking the predicate returns all ancestors.
Context
is a context.
(context/1
)
AncestorContext
is a context.
(context/1
)
Usage: context_child(Context,ChildContext)
ChildContext
node to a Context
node. The predicate will return all children upon backtracking.
Context
is a context.
(context/1
)
ChildContext
is a context.
(context/1
)
Usage: context_descendant(Context,DescendantContext)
DescendantContext
node to a Context
node. Upon backtracking the predicate returns all descendants.
Context
is a context.
(context/1
)
DescendantContext
is a context.
(context/1
)
Usage: context_sibling(Context,SiblingContext)
SiblingContext
node to a Context
node. The predicate will return all siblings upon backtracking. Note that the Context
node is not considered a sibling to itself.
Context
is a context.
(context/1
)
SiblingContext
is a context.
(context/1
)
Go to the first, previous, next, last section, table of contents.