# Extension Module - Ft.Xml.Xslt.BuiltInExtElements

    Fourthought proprietary XSLT extension elements

    Copyright 2005 Fourthought, Inc. (USA).
    Detailed license and copyright information: http://4suite.org/COPYRIGHT
    Project home, documentation, distributions: http://4suite.org/

## Namespaces

The namespace for extensions defined in this document are:

Prefix | Namespace
--- | ---
`f` | `http://xmlns.4suite.org/ext`

The prefix is given for this document only. Any other prefix can be used within a particular stylesheet.

## Elements

Element | Syntax
--- | ---
f:apply-imports | <f:apply-imports <!-- Content: xsl:with-param* --> />
f:apply-templates | <f:apply-templates mode = { qname } select = expression <!-- Content: (xsl:sort | xsl:with-param)* --> />
f:assign | <f:assign name = qname body-as-ns = { "yes" | "no" } select = expression <!-- Content: template --> />
f:chain-to | <f:chain-to href = { uri-reference } <!-- Content: xsl:with-param* --> />
f:create-index | <f:create-index name = { string } select = expression use = expression <!-- Content: template --> />
f:dump-keys | <f:dump-keys force-update = { "yes" | "no" } raw = { "yes" | "no" } <!-- Content: template --> />
f:dump-vars | <f:dump-vars raw = { "yes" | "no" } <!-- Content: template --> />
f:message-control | <f:message-control suppress = { "yes" | "no" } <!-- Content: template --> />
f:output | <f:output cdata-section-elements = { qnames } doctype-public = { string } doctype-system = { string } encoding = { string } indent = { "yes" | "no" } media-type = { string } method = { qname } omit-xml-declaration = { "yes" | "no" } standalone = { "yes" | "no" } version = { nmtoken } <!-- Content: template --> />
f:raw-text-output | <f:raw-text-output select = expression <!-- Content: template --> />
f:replace | <f:replace substring = string-expression string = string-expression <!-- Content: template --> />
f:uri-to-element | <f:uri-to-element default-name = { qname } uri = { uri-reference } default-namespace = { uri-reference } use-attribute-sets = qnames <!-- Content: template --> />

## Elements

### Element - f:apply-imports

#### Element Syntax

<f:apply-imports
<!-- Content: xsl:with-param* -->
/>

The f:apply-imports element is an extension of the xsl:apply-imports element. It differs from xsl:apply-imports in the following way: The element accepts xsl:with-param children that designate parameters that will be passed to the applied templates.

### Element - f:apply-templates

#### Element Syntax

<f:apply-templates
mode = { qname }
select = expression
<!-- Content: (xsl:sort | xsl:with-param)* -->
/>

The f:apply-templates element is an extension of the xsl:apply-templates element. It differs from xsl:apply-templates in the following way: The value of the mode attribute is an attribute value template rather than a static string. Thus, the mode can be computed at run time.

### Element - f:assign

#### Element Syntax

<f:assign
name = qname
body-as-ns = { "yes" | "no" }
select = expression
<!-- Content: template -->
/>

The f:assign element works like xsl:variable, but forces both a local and a global variable binding, replacing any other in-scope bindings having the same expanded-name. Thus, it can be used to circumvent XSLT's restriction on variables not being reassignable. However, its use is not recommended, for reasons explained below. As with xsl:variable, the name of the variable is given in the mandatory name attribute, and the new value may be given either by an expression in the select attribute, or by instantiating the content of the element. If no select attribute is given, then a body-as-ns attribute may be used to indicate whether to assign the variable to the contents as a node-set (value 'yes') or as a result tree fragment (default, or value 'no'). In either case, be aware that the node-set or result tree fragment will have a root node. Note that reassignment of variables is generally never actually needed. Before using f:assign, read the XSL FAQ or ask on xsl-list if there is a better, more portable way to solve your problem. XSLT is designed as a language that is free of side-effects, which is why assignment is not allowed and variables have very specific scope. When variable assignment is allowed, certain optimizations in the XSLT processor become impossible. Also, there are some circumstances in which the order of execution may not be quite what you expect, in which case f:assign may show anomalous behavior. It does not work predictably when called from within a tail-recursive template, for example. That said, f:assign can be a convenient way to create a node-set from a result tree fragment in XSLT 1.0. The proper way to do this is with EXSLT: <xsl:variable name="rtf"><foo/></xsl:variable> <xsl:variable name="ns" select="exsl:node-set($rtf)" xmlns:exsl="http://exslt.org/common"/> but f:assign can do it in one step: <f:assign name="ns" body-as-ns="yes"><foo/></f:assign>

### Element - f:chain-to

#### Element Syntax

<f:chain-to
href = { uri-reference }
<!-- Content: xsl:with-param* -->
/>

f:chain-to tells the processor to apply the output of the current stylsheet as the input of another stylesheet, establishing a chain of transforms. The next stylesheet in the chain is specified using an AVT, which allows for dynamically constructed chains. Children can be xsl:with-param elements, in which case the specified values are passed on to the next stylesheet as top-level parameters Warning: if the href attribute is blank, it will chain back to this same stylesheet and could lead to an infinite loop. FIXME: Trap this condition

### Element - f:create-index

#### Element Syntax

<f:create-index
name = { string }
select = expression
use = expression
<!-- Content: template -->
/>

f:create-index allows one to create an arbitrary key at run time using any node data. It is similar to xsl:key, except that it is computed on demand at run-time, and uses an XPath selection rather than an XSLT match, which gives more flexibility over what is indexed. These keys can be accessed using the extension function f:lookup(). Avoid making a dynamic index have the same name as a proper xsl:key. In particular this will confuse tools such as the <f:dump-keys/> diagnostic extension.

### Element - f:dump-keys

#### Element Syntax

<f:dump-keys
force-update = { "yes" | "no" }
raw = { "yes" | "no" }
<!-- Content: template -->
/>

### Element - f:dump-vars

#### Element Syntax

<f:dump-vars
raw = { "yes" | "no" }
<!-- Content: template -->
/>

### Element - f:message-control

#### Element Syntax

<f:message-control
suppress = { "yes" | "no" }
<!-- Content: template -->
/>

f:msg-control provides, as a side effect, context-sensitive control over whether messages (i.e., those produced by xsl:message) and warnings are output by the processor.

### Element - f:output

#### Element Syntax

<f:output
cdata-section-elements = { qnames }
doctype-public = { string }
doctype-system = { string }
encoding = { string }
indent = { "yes" | "no" }
media-type = { string }
method = { qname }
omit-xml-declaration = { "yes" | "no" }
standalone = { "yes" | "no" }
version = { nmtoken }
<!-- Content: template -->
/>

f:output is similar to xsl:output, but it allows you to compute the output parameters dynamically (as attribute value templates). Unlike xsl:output, this element is not expected to be empty; the output parameters apply only to the serialization of the element's content.

### Element - f:raw-text-output

#### Element Syntax

<f:raw-text-output
select = expression
<!-- Content: template -->
/>

Given a foreign XPath object, f:raw-text-output creates a text node based on the object, just like xsl:value-of with disable-output-escaping="yes". Unlike xsl:value-of, however, this element does not use the string-value of the object; it instead feeds the object directly to the current output writer. Therefore, unless a custom output writer is used, the object must be a Python Unicode string. The intent is to provide a way to serialize a Unicode string that may contain characters that are not permitted in an XPath string object. For example, another extension can convert raw binary data to a Unicode string, and then this extension can reserialize that string through the XSLT output stream, without risk of losing any data due to XPath's restrictions on string content.

### Element - f:replace

#### Element Syntax

<f:replace
substring = string-expression
string = string-expression
<!-- Content: template -->
/>

f:replace performs a search and replace on a string, placing the results in the output. The content is treated as a template. The string value of the output from this template is the replacement string. All instances of the string given by the 'substring' attribute are replaced with the replacement string.

### Element - f:uri-to-element

#### Element Syntax

<f:uri-to-element
default-name = { qname }
uri = { uri-reference }
default-namespace = { uri-reference }
use-attribute-sets = qnames
<!-- Content: template -->
/>

Extends xsl:element by deriving the constructed element's QName and namespace from the supplied URI reference. The URI reference is first resolved to absolute form. Then, if the resulting URI begins with an in-scope namespace, that namespace will be used as if it had been supplied as the 'namespace' attribute to xsl:element, and the remainder of the URI will be combined with a prefix from the in-scope namespace bindings and used as if supplied as the 'name' attribute to xsl:element. Otherwise, the supplied default-name and default-namespace will be used, effecting the same result as calling xsl:element with these values. The intent is to allow an RDF resource, as identified by a URI with a fragment component, to be easily converted into an element.