Conversion Functions

Functions for converting a value from one form to another, e.g. hexToString.

hash

hash(value, [algorithm], [salt])➡String

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.

Function Arguments:

Param Type Mandatory Default Value Allowed Values Multiple Min Count Description
value String - - - The value to hash.
algorithm String SHA-256 MD5, SHA, SHA-224, SHA-256, SHA-384, SHA-512 - The name of the hash algorithm to use.
salt String - - - The salt to use as input to the hashing function. The salt will be hashed first followed by the value.

Return Value:

Type Description
String The hash of the value

hex-to-dec

hex-to-dec(hex)➡String

Converts a hexadecimal value to its decimal representation.

Function Arguments:

Param Type Mandatory Default Value Allowed Values Multiple Min Count Description
hex String - - - The hexadecimal value to convert.

Return Value:

Type Description
String The decimal representation, or an empty sequence if conversion fails.

hex-to-oct

hex-to-oct(hex)➡String

Converts a hexadecimal value to its octal representation.

Function Arguments:

Param Type Mandatory Default Value Allowed Values Multiple Min Count Description
hex String - - - The hexadecimal value to convert.

Return Value:

Type Description
String The octal representation, or an empty sequence if conversion fails.

hex-to-string

hex-to-string(hex, charset)➡String

Decodes hexadecimal bytes to text using the specified character set. Whitespace in the hexadecimal input is ignored.

Function Arguments:

Param Type Mandatory Default Value Allowed Values Multiple Min Count Description
hex String - - - The hexadecimal bytes to decode.
charset String - - - The character set name, such as UTF-8.

Return Value:

Type Description
String The decoded text, or an empty sequence if decoding fails.

Example

XSLT:

<string><xsl:value-of select="stroom:hex-to-string('74 65 73 74 69 6e 67 20 31 32 33', 'UTF-8')" /></string>

XML:

<string>testing 123</string>

json-to-xml

json-to-xml(json)➡Sequence

Converts JSON text to XML nodes for use in XPath expressions.

Function Arguments:

Param Type Mandatory Default Value Allowed Values Multiple Min Count Description
json String - - - The JSON text to convert.

Return Value:

Type Description
Sequence The XML representation of the JSON value.