The "Zorba util" functions

1 Introduction

This document defines a genereal set of functions grouped together under "zorba-util" namespace.

1.2 Namespaces

In order to use Zorba util functions, the module "http://www.zorba-xquery.com/zorba/util-functions" has to be included at the beginning of a query. For example

  import module namespace zorba-util = "http://www.zorba-xquery.com/zorba/util-functions";

2 Function Signatures and Descriptions

2.1 Functions using Tidy library

In order to use the functions that require Tidy you have to:

2.1.1 zorba-util:tidy

  declare function tidy($str as xs:string) as xs:string

Summary: Assuming $str contains a "dirty" HTML the function will return a valid XHTML version of the $str.

Error conditions:
If Tidy lib is not able to transform the given string into a valid XHTML, an error is raised XQP0029_TIDY_ERROR (see Appendix A: Error codes).

2.1.2 zorba-util:tdoc

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

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

Error conditions:
If Tidy lib is not able to transform the given string into a valid XHTML, an error is raised XQP0029_TIDY_ERROR (see Appendix A: Error codes).

Appendix A: Error codes

XQP0029_TIDY_ERROR - Error in Tidy library - is returned in case Tidy lib is not able to transform the given string into a valid XHTML.