ALBConsults       

Navigate the site: XBRLXSLTXSLXML

Home

  XBRL

  XSLT

  XSL FO

  XML

Case Studies

Numismatic Reference Work

The XML modeled information of the data (see XML aspects) includes weight information for each known specimen of the coin type.

XSLT includes enough math capabilities to calculate the average in a straightforward manner of this set of weights. For the standard deviation the sum of the squares of the weight offset from the average is also easy to compute. Although XSLT 2.0 has a quite rich function library this does not include a square root function, which is needed to compute the standard deviation. One implementation of this function (in XSLT 1.0) as a template is part of the EXSLT library. A popular XSLT 2.0 implementation (Saxon) permits all Java math functions to be easily declared as extension functions.

The set of weights is also used as input to a series of templates that creates an SVG representation of a histogram of the weights. These templates represent some 400 lines of code.

This case study shows the power that XML modeled data and XSLT as a styling language provides. XSL Formatting Objects aspects gives a few additional details on the generation of the final pages.

Generation of a Web-site

XSLT can be used very effectively to generate a web site from one or more XML documents. All the HTML pages in this web site were generated from a single XML file. In this application each HTML "page" is a <page> element with attributes giving a "nice" name and a file name. Advantages in this case include:

  • the "look and feel" of the website is controlled by the XSLT style-sheet; the geometry, whether the HTML pages are nested tables or using frames, constant information on each page: logo and hot links in the graphic at the top and navigation bar on the side
  • cross references targets are automatically updated to point to the correct HTML page by using the file name attribute on the appropriate <page> element
  • keywords in metadata can be "inherited" from "ancestors" in the web page hierarchy"
  • easier to edit for consistency by find and replace in one file

Another case of generating a web site is the creation of a web site of an "inventory" with an "index" page linking to a page for each object in the inventory. A specific example is for the inventory of Thai coins in the British Museum. The information for each coin is in one XML element with attributes specifying the data. For example:

<thmod  nr="BM0167" ru="r4" me="ag" d="b1"
da="(1857)" wt="15.69" altwt="242." altwtunit="grain"
ttc="408.2 p.131" km="Y14"
comm="Struck in England before shipping the dies to Bangkok"
cscan="BM0167O BM0167R BM0167E"
labelcscan="BM0167L BM0167M" inv_nr="57-11-4-2"
donor="Earl of Clarendon" ddate="1857-11"/>

The attributes can be thought of a "fields" in a database or as a set of sub-elements of an element for each coin. In many cases the values are a "short hand" for the information - e.g. "r4" for the ruler "Rama IV". As far as possible the values are enumerated sets to help in validation. The "wt" attribute is used for the weight in grams of the coin. A pair of attributes "altwt" and "altwtunit" give an alternate weight; this information is used to compute the alternate weight in grams. For this specific coin the alternate weight (in grains) was established in 1857 and the coin was re-weighed (in grams) in recent times. Important attributes are "nr", giving a unique identified for the coin, and the "cscan" and "labelcscan" attributes giving the file names of the images for the coin and the label in the tray.

The XSLT style-sheet makes two passes through set of coin elements. The first pass creates an "index" page with references to a page for each coin. The name of the page is taken from the unique "nr" attribute. The second pass creates an HTML page for each coin combining text and the referenced image files. Each of the image files is a link to an enlarged image and "X"es are links to even bigger enlargements.

A sample page for a coin in the inventory (images courtesy of the Trustees of the British Museum):