This is a prototype for a common library of XQuery functions, particularly those which depend on the eXist function libraries together with test scripts which demonstrate the application of those functions.
This function is a wrapper for the XSLT2 function analyze-string
Dependency: eXist transform module
Dependency: SAXONXSLT-2 engine
A BandMap is a structure to map a numerical value to one of a set of non-overlapping bands of values and hence to attributes of that band (? is there an established name for this structure which is an ordinal to nominal map?)
A bandMap can be used to model such structures as salary scales, the windspeeds on the Beaufort Scale, honours classification and bulk discounts.
There are a number of ways a bandMap can be implemented - by both min and max for each band with no band sequencing, or by just the max or min of the band with bands in sequence. The later removes the redundancy of matching max and min on adjacent bands. Here I've chosen to represent a band by its minimum value which defines an interval closed at the lower end, open at the upper end. The highest band includes infinity. Values below the lowest limit are mapped to null.
A band is required to have an attribute 'min' castable to xs:decimal, and may have any other attributes or child elements. Bands must be in ascending order of min. Although an XML Schema could go some way to defining a valid bandMap, a better language would be Schematron, but that is not yet integrated into eXist. In this example, the validation is performed by an XQuery function.
Purpose: This function adds comma as thousand separators to a string containing an integer.
Purpose: To demonstrate the use of the eval function.
This solution of Fizz-Buzz was prompted by an item in David Paterson's Blog
This function is a wrapper for the xslt function of the same name
Dependency: eXist transform module
Dependency: SAXONXSLT-2 engine
This function is a wrapper for the xslt function of the same name
Dependency: eXist transform module
Purpose: Functions for conversion from UK OS grid coordinates to lat long plus some support functions.
Conversion formula from the Ordnance Survey guide to coordinate transformations.
Author: Chris Wallace
This function converts an integer to a string with commas as thousands separators.
Purpose: This function computes the Levenstein edit distance between two strings using a dynamic-programming algorithm. Stack limitations means that it is limited to strings of about 20 characters. see Jeni's blog
Purpose: To round a number to a given number of decimal places: needs full testing
Dependancy: eXist math module
This code is part of a Sudoku solver but it is buggy in eXist currently.
This code is part of a Sudoku solver - working .
Converting a string to title case
Purpose: To demonstrate the use a number of util functions.
These functions implement the equivalent Excel functions with a few alterations. fxx:working-days and fxx:networking-days are inverses here but not in Excel.
Chris Wallace June 2007 Blog