home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="iso-8859-1"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <meta name="GENERATOR" content="amaya 9.0.1, see http://www.w3.org/Amaya/"
- />
- <title>Using the HTML.trans File</title>
- <style type="text/css">
- </style>
- <link href="style.css" rel="stylesheet" type="text/css" />
- </head>
-
- <body xml:lang="en" lang="en">
-
- <table border="0" width="100%" summary="toc">
- <tbody>
- <tr>
- <td><img alt="Amaya"
- src="../../resources/icons/22x22/logo.png" />
- </td>
- <td><p align="right"><a
- href="editing_documents/about_merging_elements.html"
- accesskey="p"><img alt="previous" src="../../resources/icons/misc/left.png" /></a> <a
- href="Changing.html" accesskey="t"><img alt="top"
- src="../../resources/icons/misc/up.png" /></a></p>
- </td>
- </tr>
- </tbody>
- </table>
-
- <div id="page_body">
- <h1>Using the HTML.trans File</h1>
-
- <p>This document is an introduction to the structure transformation mechanism
- provided by <strong>Amaya</strong>. It describes the syntax of the
- transformation language and the way transformations are performed in the
- editor.</p>
-
- <p>The file <code>amaya/HTML.trans</code> contains the description of
- available transformations. This file can be edited during an
- <strong>Amaya</strong> session. It is dynamically parsed when the
- transformation procedure is called by the editor, so new transformations can
- be added during an editing session.</p>
- <hr />
-
- <h2>Syntax of the Amaya transformation language</h2>
-
- <p>Comments begin with<code><strong>!</strong></code>and continue until the
- end of the line.</p>
-
- <p>The file consists of a list of transformation descriptions. Each
- transformation is described by three parts :</p>
- <ul>
- <li>a <em>name</em>terminated by a colon
- <strong><code>:</code></strong></li>
- <li>a <em>source pattern</em> terminated by a semi-colon
- <strong><code>;</code></strong></li>
- <li>and a list of <em>rules</em> between braces <strong><code>{
- }</code></strong> , each rule terminated by a semi-colon
- <strong><code>;</code></strong></li>
- </ul>
-
- <p>The name appears in the <strong>Transform</strong> menu and identifies the
- transformation for the end-user.</p>
-
- <h3>The pattern</h3>
-
- <p>The pattern describes a specific organization of the elements to be
- transformed. It acts as a filter over the HTML dtd. The purpose of the
- pattern is to identify a particular combination of elements to which the
- transformation can be applied. In a pattern it is possible to express
- conditions on sequence of tags, on the content of a tag and on the existence
- and value of attributes.</p>
-
- <p>Formally, a pattern contains HTML tags (possibly with attributes) and some
- composition operators:</p>
-
- <p><strong><code>|</code></strong>for choice</p>
-
- <p><strong><code>,</code></strong>for sibling</p>
-
- <p><strong><code>+</code></strong>for sequence</p>
-
- <p><strong><code>?</code></strong>for option</p>
-
- <p><strong><code>( )</code></strong> for grouping nodes</p>
-
- <p>The braces <code><strong>{</strong></code> <code><strong>}</strong></code>
- define the content of a node.</p>
-
- <p>The symbol <strong><code>*</code></strong> is a token that matches any
- element type.</p>
-
- <p>It is possible to rename a tag by preceding it with a name followed by a
- colon (<strong><code>:</code></strong>).</p>
-
- <p>The tag may have attributes. If no value is given for an attribute, an
- element is matched if the attribute is present. If a value is specified for
- the attribute, an element is matched if the attribute is present and have the
- specified value.</p>
-
- <p><a href="#L235">Examples</a> of patterns are given at the end of the
- document.</p>
-
- <h3>The rules</h3>
-
- <p>A rule expresses how some elements identified in the pattern are
- transformed. A rule has two parts separated by the symbol
- <strong><code>></code></strong>:</p>
- <ul>
- <li>a source tag or a name defined in the pattern,</li>
- <li>a target tag list, giving the tags to be generated, and the place where
- they are inserted when transforming the source element.</li>
- </ul>
-
- <p>The target tag list is itself divided into two parts separated by a colon
- (<strong><code>:</code></strong>):</p>
- <ul>
- <li>the generation location path (identifies the place where new tags have
- to be inserted)</li>
- <li>the list of tags to be generated</li>
- </ul>
-
- <p>The generation location path is searched in the leftmost branch of the
- document tree, starting from the parent of the element matching the highest
- symbol of the pattern.</p>
-
- <p>In the target tag list, the dot symbol (<code><strong>.</strong></code>)
- is used for descending in the tree structure.</p>
-
- <p>If the special token star (<code><strong>*</strong></code>) ends the list
- of tags to be generated, the source element tag is not changed, but it can be
- moved to a different place in the destination.</p>
-
- <p>If the source tag or the name in the left part of a rules is present more
- than once in the pattern, the rule transforms all the elements matching an
- occurrence of the tag in the pattern.</p>
- <hr />
-
- <h2>Transformation process</h2>
-
- <p>When the user chooses the <strong>Transform</strong> command from the
- <strong>Edit</strong> menu, Amaya parses the <code>HTML.trans</code> (or the
- <code>MathML.trans</code>, etc.) file. Then the selected elements are matched
- with the pattern of each transformation. The names of the matched
- transformations are proposed to the user in a pop-up menu.</p>
-
- <p>If several transformations with the same name match the selected elements,
- the higher-level matching transformation is proposed to the user. If several
- transformations match at the same level, the first one declared in the
- <code>HTML.trans</code> file is proposed. As a consequence, it is recommended
- to specify the transformations with specific patterns before the more general
- ones.</p>
-
- <p>Once a transformation has been chosen by the user, the destination
- structure is built according to the rules while selected elements are
- traversed.</p>
-
- <p>Finally, the contents of the source elements (text and pictures, but also
- structured elements) are moved into the produced elements.</p>
-
- <p>This transformation process for HTML documents is fully described in <a
- href="http://opera.inrialpes.fr/opera/papers9696.html"><em>Interactively
- Restructuring HTML Documents</em></a>, a paper presented at the <a
- href="http://www5conf.inria.fr/">5th international WWW conference</a> in
- Paris, May 96, by CΘcile Roisin and StΘphane Bonhomme.</p>
- <hr />
-
- <h2><a name="L235" id="L235">Examples</a></h2>
- <ul>
- <li>The first example merges several consecutive unnumbered lists (UL) into
- an unique list.
- <pre>Merge Lists: (ul{li+})+;
- {
- li > ul:li;
- }</pre>
- <p>The pattern matches a sequence of unnumbered lists (UL), that contain
- a sequence of items (LI).</p>
- <p>The rule expresses that each time an item is encountered when
- traversing the matched elements, a new LI tag is created within an UL.
- When the rule is first applied, the resulting structure is empty, so
- there is no UL element in which the LI can be created. Therefore an UL is
- first created, then the rule can be applied.</p>
- </li>
- <li>The second example transforms a definition list into a table.
- <pre>Table: dl{(dt|dd)+};
- {
- dt > <table border=1>.tbody:tr.td;
- dd > <table border=1>.tbody.tr:td;
- }</pre>
- <p>The pattern matches any Definition List element (dl).</p>
- <p>The rules explain how the table is incrementally built when the
- structure of the selected definition list is traversed :</p>
- <ul>
- <li>Each dt involves the creation of a new row (tr) in the table
- body.</li>
- <li>Each dd involves the creation of a new cell (td) in the last
- existing row of the table.
- <p></p>
- </li>
- </ul>
- </li>
- <li>The third example removes a table element, keeping its content
- unchanged but extracted from the table.
- <pre>Remove Table:
- table{?caption,?(body:*{(tr{(td{(?cell_content:*)+}|
- th{(?cell_content:*)+}
- )})+})+};
- {
- caption>h3;
- cell_content>:*;
- }</pre>
- <p>The pattern matches any table and identifies the content of each cell
- of the table (cell_content).</p>
- <p>The second rule expresses that the contents of each cell have to be
- moved to the place of the original table.</p>
- </li>
- <li>See the file <kbd>amaya/HTML.trans</kbd> for more transformation
- examples.</li>
- </ul>
- </div>
- <hr />
- </body>
- </html>
-