Generated: October 28, 2003, 14:37:25 | Copyright © 2003, Kurt Nørmark |
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
<purchase> <p>4 thinkers</p> </purchase>
is transformed to
<text count="1"> 4 thinkers </text>
The slightly more complicated input clause
<purchase> <p>4 thinkers</p> <p>5 tailors</p> <p>2 soldiers</p> <p>1 spy</p> </purchase>
is translated to
<text count="4"> 4 thinkers, <text> 5 tailors, <text> 2 soldiers and <text>1 spy</text> </text> </text> </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.