XQuery Function Documentation

Search and Browse

http://exist-db.org/xquery/templates

/db/apps/shared-resources/content/templates.xql

HTML templating module

version 2.1
author Wolfgang Meier

templates:apply

templates:apply($content as node()+, $resolver as function(*), $model as map(*)?) as item()*

Start processing the provided content. Template functions are looked up by calling the provided function $resolver. The function should take a name as a string and return the corresponding function item. The simplest implementation of this function could look like this: <pre>function($functionName as xs:string, $arity as xs:int) { function-lookup(xs:QName($functionName), $arity) }</pre>

Parameters:
$content+ the sequence of nodes which will be processed
$resolver a function which takes a name and returns a function with that name
$model? a sequence of items which will be passed to all called template functions. Use this to pass information between templating instructions.
Returns:
item()*

templates:apply

templates:apply($content as node()+, $resolver as function(*), $model as map(*)?, $configuration as map(*)?) as item()*

Start processing the provided content. Template functions are looked up by calling the provided function $resolver. The function should take a name as a string and return the corresponding function item. The simplest implementation of this function could look like this: <pre>function($functionName as xs:string, $arity as xs:int) { function-lookup(xs:QName($functionName), $arity) }</pre>

Parameters:
$content+ the sequence of nodes which will be processed
$resolver a function which takes a name and returns a function with that name
$model? a sequence of items which will be passed to all called template functions. Use this to pass information between templating instructions.
$configuration? a map of configuration parameters. For example you may provide a 'parameter value resolver' by mapping $templates:CONFIG_PARAM_RESOLVER to a function whoose job it is to provide values for templated parameters. The function signature for the 'parameter value resolver' is f($param-name as xs:string) as item()*
Returns:
item()*

templates:copy-node

templates:copy-node($node as element(), $model as item()*) as item()*

Parameters:
$node $node
$model* $model*
Returns:
item()*

templates:each

templates:each($node as node(), $model as map(*), $from as xs:string, $to as xs:string) as item()*

Parameters:
$node $node
$model $model
$from $from
$to $to
Returns:
item()*

templates:error-description

templates:error-description($node as node(), $model as map(*)) as item()*

Parameters:
$node $node
$model $model
Returns:
item()*

templates:form-control

templates:form-control($node as node(), $model as map(*)) as node()*

Processes input and select form controls, setting their value/selection to values found in the request - if present.

Parameters:
$node $node
$model $model
Returns:
node()*

templates:get-app-root

templates:get-app-root($model as map(*)) as xs:string?

Parameters:
$model $model
Returns:
xs:string?

templates:get-root

templates:get-root($model as map(*)) as xs:string?

Parameters:
$model $model
Returns:
xs:string?

templates:if-attribute-set

templates:if-attribute-set($node as node(), $model as map(*), $attribute as xs:string) as item()*

Parameters:
$node $node
$model $model
$attribute $attribute
Returns:
item()*

templates:if-model-key-equals

templates:if-model-key-equals($node as node(), $model as map(*), $key as xs:string, $value as xs:string) as item()*

Parameters:
$node $node
$model $model
$key $key
$value $value
Returns:
item()*

templates:if-module-missing

templates:if-module-missing($node as node(), $model as map(*), $uri as xs:string, $at as xs:string) as item()*

Evaluate the enclosed block if there's a model property $key equal to $value.

Parameters:
$node $node
$model $model
$uri $uri
$at $at
Returns:
item()*

templates:if-parameter-set

templates:if-parameter-set($node as node(), $model as map(*), $param as xs:string) as node()*

Parameters:
$node $node
$model $model
$param $param
Returns:
node()*

templates:if-parameter-unset

templates:if-parameter-unset($node as node(), $model as item()*, $param as xs:string) as node()*

Parameters:
$node $node
$model* $model*
$param $param
Returns:
node()*

templates:include

templates:include($node as node(), $model as map(*), $path as xs:string) as item()*

Parameters:
$node $node
$model $model
$path $path
Returns:
item()*

templates:load-source

templates:load-source($node as node(), $model as map(*)) as node()*

Parameters:
$node $node
$model $model
Returns:
node()*

templates:process

templates:process($nodes as node()*, $model as map(*)) as item()*

Continue template processing on the given set of nodes. Call this function from within other template functions to enable recursive processing of templates.

Parameters:
$nodes* the nodes to process
$model a sequence of items which will be passed to all called template functions. Use this to pass information between templating instructions.
Returns:
item()*

templates:resolve

templates:resolve($uri as xs:string) as xs:string?

Parameters:
$uri $uri
Returns:
xs:string?

templates:surround

templates:surround($node as node(), $model as map(*), $with as xs:string, $at as xs:string?, $using as xs:string?, $options as xs:string?) as item()*

Parameters:
$node $node
$model $model
$with $with
$at? $at?
$using? $using?
$options? $options?
Returns:
item()*

templates:unless-model-key-equals

templates:unless-model-key-equals($node as node(), $model as map(*), $key as xs:string, $value as xs:string) as item()*

Evaluates its enclosed block unless the model property $key is set to value $value.

Parameters:
$node $node
$model $model
$key $key
$value $value
Returns:
item()*