OpenLLM-France/wikimedia huggingface dataset:
# Woodturning/Woodturning organisations

Woodturners in many countries have formed organizations for the purposes of education and promotion. This page lists those organizations by country. Only nationwide organizations are listed here; their websites usually list regional chapeters.

## United Kingdom

* Association of Woodturners of Great Britain - dedicated to the advancement and promotion of woodturning,
* British Wood Turners Association - represents the British wood turning industry and promotes the continuing craftsmanship and skill of its members.
* UK Register of Professional Turners - supported by The Worshipful Company of Turners of London, the register is composed of turners who offer a professional service to the public.
# XQuery/Filling Portlets
## Motivation

You want to be able to create reports that work with industry standard portals. These systems have standard div tags with class attributes that are standardized.
For example the searchbox for a page will have the following XHTML:

## Method

We will create a report that is structured as a set of divs with the appropriate class tags. We can then take the URL for this report and add it to the portal management system. Our report will automatically be styled according to the central portal style sheet.
Portal software allows These divs need to be filled by XQueries:
* portal-wrapper
* portal-top
* portal-header
* portal-breadcrumbs
* portal-searchbox
* portal-advanced-search
* portal-footer
* portal-colophon
* portal-personaltools
# XQuery/Flickr GoogleEarth

Flickr photos which are geo-coded can be used to generate a GoogleEarth overlay.
[** API not functional on this server yet **]
Select Photos
The code for the Flickr Api to kml transformation. $flickrKey is my Flickr API key (not shown).
# XQuery/Filtering Words
## Motivation

Sometimes you have a text body and you want to filter out words that are on a given list, often called a stoplist.

## Discussion

The input string is split into words using the tokenize function which accepts two parameters, the string to be parsed and a separator expressed as a regular expression. Here words are separated by one or more spaces. The result is a sequence of words.
This program uses XPath generalized equality to compare the sequence $stopwords/word with the sequence (of one item) $word. This is true if the two sequences have items in common, that is if the stoplist contains the word.

## Alternative coding

You can also use a quantified expression to perform a stopword lookup using the some...satisfies – see XQuery/Quantified Expressions expression such as:
There are other alternatives; the stop words as a sequence of strings, or a long string and use contains or a element in the database.
There are however significant differences in performance. There is a set of tests which show the differences in a number of alternatives. Unit Tests
What these tests reveal is that, on the eXist db platform, both the suggested implementations are far from optimal. Testing against a sequence of strings takes about a fifth of the time to compare with elements. Generalised equality is equally superior to the use of a qualified expression.

## Recommended Practice

It would appear that the preferable approach is:
If the stop words are held as an element, it is better to convert to a sequence of atoms first:
Note that referencing the stop list in the database slightly improved performance.
# XQuery/Fizzbuzz

see for the full set of executable scripts and timing comparisons.
Here's an XQuery solution to the FizzBuzz problem posed in David Patterson's blog.. who wrote an XSLT solution.
Chris Wallace wrote this solution to David's configurable version of the problem:
Execute
The parameterisation of the algorithm was in the original problem as proposed by David Patterson. Simpler solutions are possible if the parameters are fixed.
Here is a solution from Jim Fuller:
Execute
Here is a short and simple solution by Dimitre Novatchev -- note that there isn't any explicit if ... then ... else. (Also, this can be shortened to 3 lines if the $fizz and $buzz variables are eliminated):
Execute
One may notice that the above solution doesn't use any XQuery features that aren't also in XPath -- therefore this is a pure XPath 2.0 solution.
Another solution by Dimitre, which might be faster as it doesn't use any mod operator at all:
Execute
Again, the above solution doesn't use any XQuery features that aren't also in XPath 3.0 -- therefore this is a pure XPath 3.0 solution.
Here is a solution from Dino Fancellu, pure XPath 3.0:
Here is a solution by Benito van der Zander, pure XPath 3.0 without if:
# XQuery/Formatting Numbers
## Motivation

You want an easy way to format numbers by specifying the picture format of the number. So for example if you want to format numbers with a leading dollar sign, commas and two decimal places you would use the following "picture format":
If the input number was 1234 the output would be $1,234.00

## Method 1 - XSLT Wrapper

The format-number is a standard function in XSLT 1.0 and XPath 2.0. It is also included in the draft XQuery 1.1 Requirements To use this with eXist we will just write a wrapper to the Saxon XSLT format-number function. To do this you will need to do the following:
* download a copy of the Saxon9B XSLT program from http://prdownloads.sourceforge.net/saxon/saxonb9-1-0-2j.zip
* unzip the package and copy three jar files (saxon9.jar, saxon9-dom.jar and saxon9-xpath.jar) into your your eXist lib/endorsed folder
* comment out the following line in your eXist conf.xml file <transformer class="org.apache.xalan.processor.TransformerFactoryImpl"/>
* un-comment the three lines that enable Saxon to be used as the default XSLT
* restart your eXist server
* add a function that will wrap a simple XSLT. See the example code below.

### Source Code

We will create an XQuery function that takes two arguments. One decimal number and the second a string that specifies the picture format. We will pass these both to a small XSLT stylesheet.

### Usage

The XSLT 1.0 format-number function takes two arguments. The first is a decimal number and the second is a string that represents a picture of the output you desire. The format string is defined in the Java class DecimalFormat
If you want comma-separated values: local:format-number($my-decimal, ',000')
If you want leading dollar signs: local:format-number($my-decimal, '$,000')
The format of negative numbers is specified in a second picture format followed by a comma.
If you want negative numbers to have a minus sign: local:format-number($my-decimal, '0,000.00;-0,000.00')

### Run tests

Run

## Method 2 - XQuery function

Minollo posted an XQuery function in his blog. His code passed a suite of tests.

## Test

Run tests

## Discussion

It is our sincere hope that a future version of XQuery includes the functions to allow the developer to easily format both numeric and date formats.

## Reference

Blog posting on XML Connections blog on format-number written in XQuery
# File Transfer Client

The EXPath File Transfer Client provides a common interface for both FTP and SFTP (SSH).

## Installation

Make sure that the following Jar files have been added to your $EXIST_HOME/lib/extensions:
* expath-ft-client.jar
* jsch-0.1.44.jar
The first jar file is the Java Archive file that contains the XQuery module interfaces. The second jar file is the module that provides the Secure Shell protocol support. See http://www.jcraft.com/jschfor further details.
The following is a temporary link to the File Transfer client interface specification:
http://extxsltforms.sourceforge.net/specs/expath-ft-client/expath-ft-client.html
# XQuery/FTP Client
## Motivation

You would like to interact with a remote FTP server running remotely directly from your XQuery program. You would like to perform operations such as list, get and put files.

## FTP Module Interfaces

The FTP module has the following interfaces:

## Sample Usage

In this example we will open a connection to a remote FTP server, login and list the files.
# United States Postage Meter Stamp Catalog/Sub-group AR-AAF: Stamps used primarily at combined Army and Air Force bases
#### Sub-group AR-AAF: Stamps used primarily at combined Army and Air Force bases

* Earliest date seen, 1956.
AR-AAF1.1. Pitney Bowes.
    Type IA4.1 with town marks:
       A. ARMY & AIR FORCE POSTAL SERVICE at top, town, state, 5-digit number and APO and two-, three- or five-digit number at bottom.
       B. As A but with dash (-) instead of ampersand (&) between ARMY and AIR FORCE (ARMY-AIR FORCE POSTAL SERVICE
       C. As A but with SERVICE abbreviated to SVC (ARMY & AIR FORCE POSTAL SVC
    Meter numbers in 100000, 300000 and 800000 series.
    V/F: ≋ 00 :
AR-AAF1.2. Pitney Bowes.
    Type IA4.5 with town mark: ARMY & AIR FORCE POSTAL SVC at top, APO and number at bottom.
    Meter numbers in 388000 and 600000 series plus 170076 also seen.
    V/F: ≋ 00 : (widely spaced colon dots)
NOTE. Found both with and without period after SVC.
AR-AAF2. Pitney Bowes. [RRRR]
    Type IB4 with town mark: ARMY & AIR FORCE POSTAL SERVICE at top, APO 942 at bottom. (211952)
    V/F: . 00
AR-AAF3. Pitney Bowes.
    Type IC4.1 with town mark: ARMY & AIR FORCE POSTAL SVC at top, APO and five-digit number at bottom.
       - APO 96263 (862637)
       - APO 96310 (850089)
       - APO 96312 (818977)
       - APO 96337 (819245)
       - APO 96346 (844970)
    V/F: . 00 (for values over 99 cents: ≋1. 00
AR-AAF4. Postalia (Tele-Norm). [RR]
    Type JA2.1 with town mark: ARMY AND AIR FORCE POSTAL SERVICE at top, 09403 / APO at bottom.
    One meter only: T-N 608 869
    V/F: ≋.00
AR-AAF5. Friden. [RRR]
    Type KB1.1 with town mark: ARMY & AIR FORCE POSTAL SERVICE at top, APO and number at bottom.
       - APO 96262 (030362)
       - APO 96374 (030368, 030567)
    V/F: ≋.00≋
# United States Postage Meter Stamp Catalog/Ink colors and fluorescence

Ink colors and fluorescence
Colors of Inks:
With the introduction of the first multi-denomination meters in 1929, the Post Office Department relaxed the rules regarding meter ink colors. Multi-denomination meters were allowed to print all stamps in the same color. The only exception was that postage below 2¢ in value could not be printed in red.
In practice soon after the 1920s a wide variety of colors were used indiscriminately with red just being the most common.
Each manufacturer has its own particular shades of colors. By manufacturer they are (from most common to least):
Many other color varieties exist. They are caused by the use of non-standard inks and by mixing inks. In a few instances, multi-colored impressions have been produced by applying different colored inks to separate areas of the ink roller.
Fluorescent Inks:
Fluorescent ink has been required for all metered mail in the United States since 1 July 1973. Pitney-Bowes' fluorescent ink often shows up poorly as a salmon pink color. Friden's fluorescent ink is frequently a red-violet color.
# United States Postage Meter Stamp Catalog/Postage meters and mailing machines

Postage Meters and Mailing Machines
Starting in the early 1930s self-contained postage meters came into use. These meters were mostly fed by a hand-crank and included a bed or plate to back the mail piece while being franked. They were cheaper and suitable for low volume mailers. High volume mailers still required high speed mailing machines with detachable meters.
To prevent fraudulent use of postage meters they were required to contain two registers, one ascending and the other descending. The ascending register added the total of all postage generated by the meter. The descending register subtracted the postage generated from the dollar amount pre-paid by or credited to the meter user. The descending register would be re-set and re-sealed every time the meter user purchased more credit. This seal could be broken and replaced only when the meter was returned to the post office for resetting.
Many current meter models will take up to $9,999.99 worth of postage. The descending register indicates the total amount of postage remaining in the machine. When it reaches the maximum value that the meter will print in one stamp (usually $9.99 or $99.99) the meter locks, preventing further use until it is reset at the post office.
The ascending register is accessible only by postal security authorities. Periodically the ascending register is matched to the total credit purchased for the meter. Any discrepancy points to mechanical failure or potential fraud.
# United States Postage Meter Stamp Catalog/Rarity and values

Rarity and Value
* [C] Common to fairly common
* [S] Scarce
* [R] Rare, difficult to find
* [RR] Very rare
* [RRR] Exceptionally rare
* [RRRR] Extremely rare to unique
For those stamps where the availability is unknown a range such as [RR-RRRR] may be used.
These availability factors are estimates based on a 1994 Meter Stamp Society survey of the largest collections known at the time plus our own decades of buying and selling experience.
Dollar values are not provided because they are unreliable and go out of date quickly. For what it's worth, here are my personal estimates of 2016 dollar values for nice examples of items in each category.
       [C] free to $5
       [S] free to $15
       [R] $5 to $35
       [RR] $10 to $75
       [RRR] $20 to $150
       [RRRR] $25 to thousands
Notice both the wide ranges and the overlap. Minor varieties, even if extremely rare do not sell for thousands of dollars, and really fine examples of relatively common items can bring several tens of dollars.
Stamps without an availability factor are nearly always [C] but with some of them I just don't know.
# United States Postage Meter Stamp Catalog/Meter and Permit numbers

Meter and Permit Numbers
All early meter stamps showed both the permit number and the manufacturer's meter number. After 9 May 1929, the permit number was no longer required if the stamp included the meter number. Meter stamps showing a permit number have not been used in decades.
The meter number identities the actual postage meter machine. Meter numbers often have a letter prefix that identities the meter manufacturer. Meter numbers generally run in series. The series often identifies the meter model. The meter number does not necessarily change when the stamp design changes. Different meter stamp design types are known with the same meter number generated before and after the print head was changed.
# XQuery/Getting POST Data
## Motivation

You want to create an XQuery that will access data in the HTTP POST.

## Method

To do this you use the request:get-data XQuery function.

## Discussion

The program above (called echo-post.xq) is a very useful program for testing your web forms. It just takes the data sent to the XQuery service and returns it wrapped in a <post-data> tag.
Sometimes HTTP POST statements put their data in parameters. For example the RichTextEditor CKEdit has multiple text areas that might each contain HTML markup in encoded forms. In this case you can also use the request:get-parameter on HTTP POST data.
After your server gets a POST from a CKEditor client the server will use the following:

## Sample XQuery to Echo Post Data

In the _samples folder you will find several samples of how to use CKEditor. Each of these HTML files has an HTML form with the following line:
The following program can be used as a substitute for the sample_postdata.php file.
sample_postdata.xq

### Viewing URL Encoded Parameters

Standard HTML forms use a data transmission format called URL encoded form data.
URL Encoded data has the following mime-type:
Content-Type="application/x-www-form-urlencoded"
If you have the following form:
Then it will return the following result from the echo-post.xq
# XQuery/Google Chart Sparkline
## Motivation

You want to create an easy-to-use specialized chart using a generic charting service such as Google Charts

## Method

The GoogleChart API creates PNG-format charts from data passed in the URL line.
One use of the service would be to generate a Tufte sparkline. This script uses random data to generate a small sparkline-like graphic. With a bit more work, the additional features such as minimum, maximum and normal bands should be able to be added. A line chart (cht=lc) includes axes but these can be removed by using an undocumented feature in which the chart type is specified as lfi
The script uses function overloading in XQuery which allows two functions to have the same name but different numbers of parameters. The more general function has parameters for the sequence of values and the min and max to be used in scaling the values. The second function (with the same name) accepts only the values and calculates the min and max from the data before calling the more general function to complete the task.
Random Sparkline
# Motivation

You have data stored in a Google Docs spreadsheet. Since Google docs has an RSS feed for their data you can use this service to get well-formed XML about your spreadsheet directly from XQuery.

# Method

You can use the base URL of 'https://spreadsheets.google.com/feeds/list/' to list the data in a public spreadsheet.
you can concat these three strings together and wrap them in an xs:anyURI type to get the document using the httpcleint:get function.

# Example Code

Which returns:

# References

This example was posted on the eXist mailing list in April of 2014 by Dr. Andreas Wagner.
# XQuery/Generating xqDoc-based XQuery Documentation
## Motivation

You want to create high-quality documentation of your XQuery functions and modules.

## Method

xqDoc is a standard for formatting comments in XQuery modules. The eXist system comes with a XQuery module which parses XQuery modules containing comments in this format and generates XML in the xqDoc XML format. This XML can then be transformed into other formats such as HTML, PDF, DocBook or ePub.
eXist-db provides a module xdbm with functions to generate an xqDoc document from an XQuery module.

## Generating the XML

You can generate an xqdoc file from an XQuery module using the xqdm:scan function:
Note that the string must be converted to a data type of anyURI.
Execute this script

## Sample xqDoc Output

The scanner will generate the following XML:

## Known Problems

The parser for the XQuery doc is slightly different than the standard XQuery parser for eXist. In some cases an XQuery that works with eXist will fail under the XQDocs parser.
* old-style variable declarations are still supported in eXist but not by the xqDoc parser
For example the following variable declaration:
is valid in eXist XQuery but this syntax is not valid in xqDoc which only supports the XQuery standard declaration e.g.
* comments must be valid XML text. This is more restrictive than in XQuery. For example < and & must be expressed as &lt; and &amp;
# XQuery/Google Chart Bullet Bar
## Motivation

To display a Bullet Chart to display the current value of a system parameter with its safe and danger ranges.

## Bullet Bars

This is one of the chart types supported by the now deprecated " Google Chart API which constructs the chart from URL parameters.

## Declarative XML Representation

An XML representation of the chart design might be:

### Google Chars Representation

Which, when supplied with a current value, must be transformed into the following URL:

## Sample XQuery Function

This function takes the specification of the chart and the current value, and generates the corresponding Google Chart URL.
Note that the width of the danger, warn and ok bars (red, yellow and green) are expressed as a percentage digit from 0 to 100.

## Generating a bullet bar

Execute
# XQuery/Google Charts
## Motivation

You want a XQuery function to create charts using the Google Chart API service.

## Method

We will create a simple XQuery function that takes the required parameters of a Google Chart (i.e. chart data, size, colors, and labels). It will then construct a URL with the correct values. You can then embed this URL in your XQuery to display the chart.

## URL Encoded Parameters

Google Charts uses URL parameters to encode the values for charts like this one. Here is a clearer rendering of the URL parameters for the chart:

## Source Code

Here is an example function:

## Checking for required parameters

The following adds a fuller set of Google Chart parameters, and gives each parameter a @required attribute:

## Acknowledgments

Fraser Hore and Dmitriy Shabanov posted these examples to the eXist mailing list.

## Resources

Sample XML Schema for checking Google Chart Parameters
# XQuery/Generating Skeleton Typeswitch Transformation Modules
## Motivation

For document types which contain multiple tags, such as TEI or DocBook, it is tedious and error-prone to write this conversion code by hand. We can use XQuery to generate the basic text for an XQuery module.
This article uses the same example as used in Transformation idioms.

## Example

Starting with a simple list of the tags in this document, we can generate a module which performs an identity transform on a document containing these tags.
Here is the XML output and the text XQuery file created by adding the line
to the script.
If we save this script as, say coupid.xqm, we can use it to generate the transformed document:
Generate
We can also check if the identity transformation has retained the full structure of the document:
Compare

## Module design

The generated module looks like this:
The function convert($nodes) contains the typeswitch statement to dispatch the node to one of the tag functions. Each tag function creates an element of that name, copies the attributes and then recursively calls the convert function passing the child nodes. The default action defined in the function convert-default merely copies the node.

## Generation Function

This function generates the code for an XQuery module which performs an identity transformation.
There are two parameters
* tags - a sequence of tags
* config - an XML node containing definitions of the module name, module prefix and module namespace.

## Generating the tags

All tags in the document or corpus need to be handled by the identity transformation, so it would be better to generate the list of tags from the document or corpus itself. The following function returns a sequence of tags in alphabetically order.
and we can modify the calling script:
Generate

## User-defined function template

The module generator function generates a fixed code pattern for each tag. We can allow the user to customize this pattern by using a callback function to generate the code pattern as an alternative to modifying the generator code itself.
The modified function code has the following modifications:
Function signature ;
generating each tag function:
To generate a basic transformation to HTML, with HTML elements being copied while non-HTML elements are converted to div elements with an additional class attribute, we define the function to create the code body, create the function reference and call the convert function:
Generate

### Customising the generator

Another customization of the generator which may be required is to add an additional $options parameter to all signatures and calls. This provides a mechanism for passing configuration parameter around the functions to control the transformation.

## Transforming with XSLT

When the conversion is complex, requiring restructuring, context-dependent transformations and reordering, it is not clear that the XQuery typeswitch approach is better or worse than the XSLT equivalent. For comparison here is the equivalent XSLT.
and XQuery to apply this server-side:
Transform to HTML via XSLT