XML functions
xf:attribute() / xxf:attribute()
This function is available in both the xf
and xxf
namespaces, and we recommend you use it with the xf
namespace.
The xf:attribute()
function returns a new XML attribute with the qualified name provided as first argument. If the qualified name is not of type xs:QName
, its string value is used. If it has a prefix, it is resolved using in-scope namespaces. The second argument is an optional value for the attribute. It defaults to the empty string.
The first argument can be of type xs:QName
:
xxf:call-xpl()
This function lets you call an XPL pipeline.
$xplURL
is the URL of the pipeline. It must be an absolute URL.$inputNames
is a sequence of strings, each one representing the name of an input of the pipeline that you want to connect.$inputElements
is a sequence of elements to be used as input for the pipeline. The$inputNames
and$inputElements
sequences must have the same length. For each element in$inputElements
, a document is created and connected to an input of the pipeline. Elements are matched to input name by position, for instance the element at position 3 of$inputElements
is connected to the input with the name specified at position 3 in$inputNames
.$outputNames
is a sequence of output names to read.
The function returns a sequence of document nodes corresponding the output of the pipeline. The returned sequence will have the same length as $outputNames
and will correspond to the pipeline output with the name specified on $outputNames
based on position.
The example below shows a call to the xxf:call-xpl
function, calling a pipeline with two inputs and one output:
xxf:classes()
Returns for the context element or the given element if provided, all the classes on the class
attribute.
xxf:create-document()
The xxf:create-document()
creates a new empty XML document. You can then insert new data into that document with the xf:insert
action.
xf:element() / xxf:element()
This function is available in both the xf
and xxf
namespaces, and we recommend you use it with the xf
namespace.
The xf:element()
function returns a new XML element with the qualified name provided. If the qualified name is not of type xs:QName
, its string value is used. If it has a prefix, it is resolved using in-scope namespaces.
The second, optional argument can take a sequence of items specifying attributes and content for the new element:
The first argument can be of type xs:QName
:
xxf:evaluate()
The xxf:evaluate()
function allows you to evaluate XPath expressions dynamically. For example:
xxf:extract-document()
The xxf:extract-document()
function extracts a new XML document from a document fragment under an enclosing element. For example with the following instance:
The expression:
returns a new XML document rooted at the <book>
element:
$excludeResultPrefixes
: optional parameter; contains a list of space-separated namespace prefixes to exclude. Defaults to the empty string.$readonly
: optional parameter; when set totrue()
, return a readonly instance. Defaults tofalse()
.
xxf:form-urlencode()
xxf:has-class()
Returns whether the context element, or the given element, has a class
attribute containing the specified class name.
xxf:mutable-document()
The xxf:mutable-document()
function takes a document as input and returns a mutable document, i.e. a document on which you can for example use xf:setvalue
.
Note that by compatibility with the XSLT document()
and XPath 2.0 doc()
functions, and unlike the instance()
function, xxf:mutable-document()
returns a document node, not a document element.
xxf:serialize()
The xxf:serialize()
function allows you to serialize an XML node to XML, HTML, XHTML or text. For example:
xxf:sort()
The second argument differs from the exf:sort()
function in that it doesn't take a plain string but a literal expression, for example:
Last updated