This document defines a general set of functions grouped together under “zorba-util” namespace, since the same functions are defined by Zorba. The only major difference is that Zorba uses Tidy as HTML cleaner, whereas MXQuery uses Tagsoup. As a result, MXQuery does not support the additional tidy options.
In order to use util functions, the module "" has to be included at the beginning of a query. For example

import module namespace zorba-util = "";

Functions for HTML Cleaning

declare function tidy($str as xs:string) as item()
Summary: Assuming $str contains a “dirty” HTML the function will return an item containing a valid XHTML version of the $str.

 import module namespace

declare function tdoc($uri as xs:string?) as document-node()?

Summary: This function if very similar to fn:doc from XQuery 1.0 and XPath 2.0 Functions and Operators. The only difference is that prior to parsing the document identified by $uri , tdoc transforms the document into a valid XHTML document with the help of TagSoup.

import module namespace

Functions for UUIDs

declare function uuid() as xs:string

Functions for Random Numbers

declare function random() as xs:integer
declare function random($seed as xs:integer) as xs:integer

Summary: Function for generating a random integer.

$seed can be used to set the starting point of the std::rand sequence. If random is called whithin a loop but diffrent numbers are expected as a result this parameter should be set


 import module namespace zu =";
  for $i in (1 to 10)
    return zu:random($i)

If no seed is provided as an argument the same number will be generated every time (when called within the same query)

import module namespace zu = "";
   for $i in (1 to 10)
    return zu:random()