Generated: October 28, 2003, 14:37:25 Copyright © 2003, Kurt Nørmark The local LAML software home page

Purchase/text Example

This example shows how to transform a linear list of p elements to a nested list of text elements. The example comes from Transformation-by-Example for XML by Shriram Krishnamurthi, Kathryn Gray, and Paul Graunke, PADL 2000, Lecture Notes in Computer Science 1753. It is also present in the paper SXLT: Manipulation Languge for XML by Oleg Kiselyov and Shriram Krishnamurthi, PADL 2003, Lecture Notes in Computer Science 2562. The Lecture Notes in Computer Science volumes are available from Springer Verlag if you have the the appropriate privileges.

Examples and explations of the example is found below the table.

The twist of the example is to introduce comma separation between the paragraphs, 'and' between the two last ones, and a count attribute on outer text element instance.

Example DTD Scheme LAML XML
The purchase DTD purchase.dtd - - -
The text DTD text.dtd - - -
The DTD parsing script - - parse-dtds.laml -
The XML-in-LAML mirroring script - - make-mirrors.laml -
The generated purchase mirror - purchases-mirror.scm - -
The generated text mirror - txt-mirror.scm - -
A simple purchase document and its transformation - purchase-transformation.scm simple-purchase-doc.laml simple-purchase-doc.xml
Another purchase document and its transformation - purchase-transformation.scm purchase-doc.laml purchase-doc.xml

Example of input and output. The simple clause

 <p>4 thinkers</p>

is transformed to

<text count="1">
   4 thinkers

The slightly more complicated input clause

 <p>4 thinkers</p>
 <p>5 tailors</p>
 <p>2 soldiers</p>
 <p>1 spy</p>

is translated to

<text count="4">
   4 thinkers,
      5 tailors,
         2 soldiers
         <text>1 spy</text>

Our conclusions are the following:

For a tutorial discussion of XML-in-LAML (and all the stuff illustrated above) please have a look at the appropriate part of the LAML tutorial .

If your browser will not present files with 'laml', 'scm', or 'dtd' extensions you should disable any special handling of these extensions on your system. In that way they are treated as pure text files.

Transformation example index.