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.
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.
See module text
Examples (Labs) from TSQL examples. by Jacob Sebastian. Not sure why Jacob calls them XQuery examples since they are not, but they are a useful set of XML handling problems.
These tests test the Emp data API
Tests of the SQL DDL code generation in the ER tool suite
Tests of the SQL DDL code generation in the ER tool suite
This solution of Fizz-Buzz was prompted by an item in David Paterson's Blog
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
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: Testing various implementations of a lookup table
Author: Chris Wallace
Purpose: Testing various implementations of a lookup table
Each run executes the same loop:
<note>{
(for $s in 1 to 1000
for $step in ("A","B","C","D","E","F","G")
return local:MidiNote(
<pitch>
<step>{$step}</step>
<octave>5</octave>
</pitch>)
)[1]
}
</note>
Author: Chris Wallace
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 Feb 2009 Blog