Stroom has a number of built in custom XSLT functions that can be called from within the XSLTFilter pipeline element. These functions provide additional capabilities and access to data held in Stroom.
Using Stroom XSLT Functions
To use a Stroom custom XSLT function you need to add the xmlns:stroom="stroom" namespace declaration to the XSLT document.
The convention is to use the namespace prefix stroom to make it clear that function calls are to a Stroom built-in function, but
any prefix can be used.
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:stroom="stroom"
xmlns="event-logging:3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...>
The following is an example of calling the hash custom XSLT function to produce a hash of the username value.
<xsl:template match="/record">
<HashedUser>
<xsl:value-of select="stroom:hash(data[@name='username']/@value, 'SHA-256')"/>
</HashedUser>
</xsl:template>
Return Values
XSLT functions can return the following data types:
- Boolean - True/false.
- Date - A date value (
xs:date). - Date-Time - A date and time value (
xs:datetime). - Decimal - A decimal or floating point value (
xs:decimal). - Integer - A number with no decimal part (
xs:integer). - String - A simple string value (
xs:string). - Sequence - Any sequence of nodes or atomic values, e.g. a single node, a list of nodes or a list of strings.
Functions
The following table lists all the Stroom XSLT functions.
| Function | Category |
|---|---|
add-meta()
add-meta()
Adds a metadata key and value to the output destination. Blank keys are ignored.
Click to see more details...
|
Pipeline |
ask-ai()
ask-ai()
Asks a configured chat model a question and returns its reply. The model is resolved by name or UUID;
each call sends a request unless an identical response is cached.
Click to see more details...
|
Other |
bitmap-lookup()
bitmap-lookup()
The bitmap-lookup() function looks up a bitmap key from reference or context data a value (which can be an XML node set) for each set bit position and adds it to the resultant XML. If the look up fails no result will be returned. |
Pipeline |
cidr-to-numeric-ip-range()
cidr-to-numeric-ip-range()
Converts a CIDR IP address range to an array of numeric IP addresses representing the start and end (broadcast) of the range. When storing the result in a variable, ensure you indicate the type as a string array ( |
Network |
classification()
classification()
Returns the display classification of the feed for the data being processed.
Click to see more details...
|
Pipeline |
col-from()
col-from()
Returns the input column where the current record begins. The column can be
Click to see more details...
0. |
Pipeline |
col-to()
col-to()
Returns the input column where the current record ends.
Click to see more details...
|
Pipeline |
cosine-similarity()
cosine-similarity()
Calculates the cosine similarity of two numeric vectors, such as embedding vectors.
The result is between Both vectors must have the same number of elements, otherwise an error is raised.
If either vector has zero magnitude, the function returns |
Other |
current-time()
current-time()
Returns the current system date and time in Stroom’s standard date-time format.
Click to see more details...
|
Date |
current-unixTime()
current-unixTime()
Returns the current system time as milliseconds since the Unix epoch.
Click to see more details...
|
Date |
current-user()
current-user()
Returns the identity of the user Stroom is processing as. This is mainly useful in interactive processing, such as a search. The form of the user’s identity returned is controlled by the optional |
Value |
decode-url()
decode-url()
Decodes a URL-encoded string.
Click to see more details...
|
URI |
dictionary()
dictionary()
Returns the contents of a Dictionary document for use during translation. The dictionary may be identified by name or UUID. The main use for this function is to allow users to abstract the management of a set of keywords from the XSLT so that it is easier for some users to make quick alterations to a dictionary that is used by some XSLT, without the need for the user to understand the complexities of XSLT. |
Pipeline |
encode-url()
encode-url()
URL-encodes a string.
Click to see more details...
|
URI |
feed-attribute()
feed-attribute()
Looks up a metadata value for the current stream part. The key can be
|
Pipeline |
feed-name()
feed-name()
Returns the name of the feed for the data currently being processed.
Click to see more details...
|
Pipeline |
fetch-json()
fetch-json()
Sends an HTTP GET request and converts a JSON response body to XML using
Click to see more details...
json-to-xml(). A 404
response produces an empty sequence. |
Network |
format-date()
format-date()
Parses a date and formats it as a string. A single argument is interpreted as milliseconds since the
Unix epoch; other forms parse an input pattern and may specify input and output time zones.
Click to see more details...
|
Date |
format-dateTime()
format-dateTime()
Formats an XPath date-time value using an optional output pattern and time zone. Without a pattern it
uses Stroom’s standard date-time format; the default time zone is UTC.
Click to see more details...
|
Date |
from-unixTime()
from-unixTime()
Converts milliseconds since the Unix epoch to an XPath date-time value.
Click to see more details...
|
Date |
get()
get()
Reads a value stored under a key by Values are stored against a key name so that multiple values can be stored. These functions can be used for many purposes but are most commonly used to count a number of records that meet certain criteria. The map is in the scope of the current pipeline process so values do not live after the stream
has been processed.
Also, the map will only contain entries that were |
Pipeline |
hash()
hash()
Generates a hash of the supplied value using the named hash algorithm. The SHA-256 algorithm will be used if not supplied. You can optionally supply a salt value to prepend to the hash. |
Conversion |
hex-to-dec()
hex-to-dec()
Converts a hexadecimal value to its decimal representation.
Click to see more details...
|
Conversion |
hex-to-oct()
hex-to-oct()
Converts a hexadecimal value to its octal representation.
Click to see more details...
|
Conversion |
hex-to-string()
hex-to-string()
Decodes hexadecimal bytes to text using the specified character set. Whitespace in the hexadecimal input
is ignored.
Click to see more details...
|
Conversion |
host-address()
host-address()
Resolves a host name to an IP address.
Click to see more details...
|
Network |
host-name()
host-name()
Resolves an IP address to a host name.
Click to see more details...
|
Network |
http-call()
http-call()
Sends an HTTP POST request and returns a
Click to see more details...
stroom-http XML response containing the status, headers
and body. The request body is optional. |
Network |
ip-in-cidr()
ip-in-cidr()
Checks whether an IPv4 address lies within a CIDR range.
Click to see more details...
|
Network |
json-to-xml()
json-to-xml()
Converts JSON text to XML nodes for use in XPath expressions.
Click to see more details...
|
Conversion |
line-from()
line-from()
Returns the input line where the current record begins, counting from
Click to see more details...
1. |
Pipeline |
line-to()
line-to()
Returns the input line where the current record ends.
Click to see more details...
|
Pipeline |
link()
link()
Builds a Markdown-style link for display in a dashboard table.
The optional type suffix controls whether Stroom opens it in a dialog, tab,
browser tab or dashboard.
Click to see more details...
|
String |
log()
log()
The log() function writes a message to the processing log with the specified severity. Severities of INFO, WARN, ERROR and FATAL can be used. Severities of ERROR and FATAL will result in records being omitted from the output if a RecordOutputFilter is used in the pipeline. The counts for RecWarn, RecError will be affected by warnings or errors generated in this way therefore this function is useful for adding business rules to XML output. |
Pipeline |
lookup()
lookup()
Looks up a key in reference or context data and return the matching string or XML.
A map path separated by If the look up fails no result will be returned. |
Pipeline |
manifest()
manifest()
Returns the manifest attributes of the current stream as an XML document
in the If the stream cannot be read, an empty |
Pipeline |
manifest-for-id()
manifest-for-id()
Returns the manifest attributes of the specified stream as an XML document
in the If the stream cannot be read, an empty |
Pipeline |
meta()
meta()
Looks up a metadata value for the current stream part. The key can be
|
Pipeline |
meta-attribute()
meta-attribute()
Reads one attribute from the current stream’s manifest. This opens the manifest from the stream’s
source, unlike
Click to see more details...
meta() which reads metadata for the current part. |
Pipeline |
meta-keys()
meta-keys()
Returns the metadata keys for the current stream part as an array of strings.
Click to see more details...
|
Pipeline |
meta-stream()
meta-stream()
Returns metadata for the current stream and part as an XML document in the If the stream part cannot be read, an empty |
Pipeline |
meta-stream-for-id()
meta-stream-for-id()
Returns metadata for the specified streamId and partNo as an XML document in the
If the stream part cannot be read, an empty |
Pipeline |
numeric-ip()
numeric-ip()
Converts an IP address to a numeric string suitable for range comparisons and reference data lookups.
Click to see more details...
|
Network |
parent-for-id()
parent-for-id()
Returns the parent stream ID of the specified input stream.
Click to see more details...
|
Pipeline |
parent-id()
parent-id()
Returns the parent stream ID of the current input stream.
Click to see more details...
|
Pipeline |
parse-dateTime()
parse-dateTime()
Parses a date string to an XPath date-time value. Without a pattern it expects Stroom’s standard
date-time format; the default time zone is UTC.
Click to see more details...
|
Date |
parse-uri()
parse-uri()
The parse-uri() function takes a Uniform Resource Identifier (URI) in string form and returns
an XML node with a namespace of
Click to see more details...
uri containing the URI’s individual components of authority,
fragment, host, path, port, query, scheme, schemeSpecificPart and userInfo. |
URI |
part-no()
part-no()
Returns the current part number within a multipart input stream, counting from
Click to see more details...
1. |
Pipeline |
pipeline-name()
pipeline-name()
Returns the name of the pipeline currently processing the stream.
Click to see more details...
|
Pipeline |
pointIsInsideXYPolygon()
pointIsInsideXYPolygon()
Tests whether a point is inside a polygon. Useful for determining if a user is inside a physical zone based on their location and the boundary of that zone. The list of values supplied for |
Other |
put()
put()
Stores a string under a key for retrieval by Values are stored against a key name so that multiple values can be stored. These functions can be used for many purposes but are most commonly used to count a number of records that meet certain criteria. The map is in the scope of the current pipeline process so values do not live after the stream
has been processed.
Also, the map will only contain entries that were |
Pipeline |
random()
random()
Generates a random decimal number between 0.0 (inclusive) and 1.0 (exclusive).
Click to see more details...
|
Value |
random-integer()
random-integer()
Generates a random integer between 0 (inclusive) and the upper bound (exclusive).
Click to see more details...
|
Value |
record-no()
record-no()
Returns the current record number within the current stream part, counting from
Click to see more details...
1. |
Pipeline |
search-id()
search-id()
Returns the batch search ID when a pipeline is processing as part of a batch search.
Click to see more details...
|
Pipeline |
send-email()
send-email()
Sends an email using the SMTP server and from address configured in
An email is sent every time the function is called, so calling it for every record will send an email for every record. No email is sent while stepping. Instead an INFO message shows the email that would have been sent. As the function returns an empty sequence, call it somewhere its result is used, e.g.
|
Other |
source()
source()
Returns an XML document in the
Click to see more details...
stroom-meta namespace describing the current source location. |
Pipeline |
source-id()
source-id()
Returns the ID of the current input stream.
Click to see more details...
stream-id() is an alias retained for compatibility. |
Pipeline |
split-document()
split-document()
Splits text into overlapping segments for language-model tokenisation. The segment and overlap sizes are
estimated token counts.
Click to see more details...
|
Other |
stream-id()
stream-id()
Returns the ID of the current input stream.
Click to see more details...
stream-id() is an alias retained for compatibility. |
Pipeline |
to-unixTime()
to-unixTime()
Converts an XPath date-time value to milliseconds since the Unix epoch.
Click to see more details...
|
Date |