Skip to topic | Skip to bottom
Home

Tesi
Tesi.TallLanguager1.9 - 10 Sep 2007 - 17:16 - LucaFurinitopic end

Start of topic | Skip to actions

Tall language

Namespace

Have we decided once and for all what will be the Tall namespace yet?

In the early examples we made in Bristol, we used http://www.cs.unibo.it/tall, so for the moment I'm using this one.

Schema

It could be a very good idea to define a TallSchema? as soon as possible, so as to be sure that all the files we are working on are consistent with each other.

Tall templates and Tall instances

Our idea is that Tall will be composed of two sub-languages:

  • one for defining reusable templates, describing how to map the content (coming from an XML file) into Tall objects + SVG + FO
  • one for defining instance files, containing both the content and the topological elements and properties

The two sub-languages will be very similar: the main difference is that in a template file, instead of the actual content, the elements have a source attributi with an XPath expression pointing to the content portion that should be included.

A Tall template is transformed via a meta-stylesheet into the actual XSLT stylesheet that must be applied to the content file in order to produce the Tall instance.

tall_languages.jpg

The meta-stylesheet transformation could be embedded into the DDF framework: the data section (in this case, the template) will be transformed into a DDF file having only a structure section, that will be merged with the DDF file holding the real content.

Example of a Tall template

Here is an example of a simple content file:

<iml>
   <p class="offer"><span class="desc">Generic offer #1 </span><span class="price">9.99</span></p>
   <p class="offer"><span class="desc">Generic offer #2 </span><span class="price">4.98</span></p>
   <p class="offer"><span class="desc">Generic offer #3 </span><span class="price">19.99</span></p>
   <p class="offer"><span class="desc">Generic offer #4 </span><span class="price">99.99</span></p>
   <p class="specialoffer">
      <span class="desc">Text of special offer #1</span>
      <span class="price">2.49</span>
      <img href="object.gif"/>
   </p>
   <p class="specialoffer">
      <span class="desc">Text of special offer #2</span>
      <span class="price">24.99</span>
      <img href="otherobject.jpg"/>
   </p>
</iml>

This is a template that maps such an input file into a Tall instance whose inteded media is an A4 sheet of paper.

The template adds a few "static" shapes to the output and indicates where to take the content from and where to put it.

<tall:template 
   xmlns:tall="http://www.unibo.it/~fabio/tall" 
   xmlns:svg="http://www.w3.org/2000/svg" 
   xmlns:fo="http://www.w3.org/1999/XSL/Format">
   <tall:context width="297mm" height="210mm" resolution="300dpi">
      <tall:group layout="star" proximity="close" similarity="width color">
         <!-- a few "static" objects -->
         <tall:object><svg:rect/></tall:object>/>
         <tall:object><svg:circle/></tall:object>
         <!-- sources of dynamic content -->
         <tall:object source="//p[@class='offer']" priority="low">
            <fo:block>
               <fo:inline font-size="10" tall:source="span[@class='desc']"/>
               <fo:inline font-size="10" tall:source="span[@class='price']"/>
            </fo:block>
         </tall:object>
         <tall:object source="//p[@class='specialoffer']" priority="high">
            <svg:circle>
               <svg:text tall:source="span[@class='desc']"/>
            </svg:circle>
         </tall:object>
      </tall:group>
   </tall:group>
</tall:template>

Ouptut of the meta-stylesheet

Here is the output of the meta-stylesheet: the resulting stylesheet will be applied to the content file.

<xsl:stylesheet 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:fo="http://www.w3.org/1999/XSL/Format" 
   xmlns:tall="http://www.unibo.it/~fabio/tall" 
   xmlns:svg="http://www.w3.org/2000/svg" version="1.0">
   <!--Meta-generated stylesheet-->
   <xsl:template match="/">
      <tall:context width="297mm" height="210mm" resolution="300dpi">
   <tall:group layout="star" proximity="close" similarity="width color">
       <tall:object><svg:rect/></tall:object>
            <tall:object><svg:circle/></tall:object>
            <xsl:apply-templates select="//p[@class='offer']"/>
            <xsl:apply-templates select="//p[@class='specialoffer']"/>
         </tall:group>
      </tall:context>
   </xsl:template>
   <xsl:template match="//p[@class='offer']">
      <tall:object priority="low">
         <fo:block>
            <xsl:apply-templates select="span[@class='desc']"/>
            <xsl:apply-templates select="span[@class='price']"/>
         </fo:block>
      </tall:object>
   </xsl:template>
   <xsl:template match="span[@class='desc']">
      <fo:inline font-size="10">
         <xsl:apply-templates/>
      </fo:inline>
   </xsl:template>
   <xsl:template match="span[@class='price']">
      <fo:inline font-size="10">
         <xsl:apply-templates/>
      </fo:inline>
   </xsl:template>
   <xsl:template match="//p[@class='specialoffer']">
      <tall:object priority="high">
         <svg:circle>
            <xsl:apply-templates select="span[@class='desc']"/>
         </svg:circle>
      </tall:object>
   </xsl:template>
   <xsl:template match="//p[@class='specialoffer']/span[@class='desc']">
      <svg:text>
         <xsl:apply-templates/>
      </svg:text>
   </xsl:template>
   <xsl:template match="//p[@class='offer']/span[@class='desc']">
      <fo:inline font-size="10">
         <xsl:apply-templates/>
      </fo:inline>
   </xsl:template>
</xsl:stylesheet>

Resulting Tall instance

When we apply the generated stylesheet to the content file, we obtain a Tall instance:

<tall:context 
   xmlns:fo="http://www.w3.org/1999/XSL/Format" 
   xmlns:svg="http://www.w3.org/2000/svg" 
   xmlns:tall="http://www.unibo.it/~fabio/tall"
    width="297mm" height="210mm" resolution="300dpi">
   <tall:group layout="star" proximity="close" similarity="width color">
      <tall:object><svg:rect/></tall:object>
      <tall:object><svg:circle/></tall:object>
      <tall:object priority="low">
         <fo:block>
            <fo:inline font-size="10">Generic offer #1 </fo:inline>
            <fo:inline font-size="10">9.99</fo:inline>
         </fo:block>
      </tall:object>
      <tall:object priority="low">
         <fo:block>
            <fo:inline font-size="10">Generic offer #2 </fo:inline>
            <fo:inline font-size="10">4.98</fo:inline>
         </fo:block>
      </tall:object>
      <tall:object priority="low">
         <fo:block>
            <fo:inline font-size="10">Generic offer #3 </fo:inline>
            <fo:inline font-size="10">19.99</fo:inline>
         </fo:block>
      </tall:object>
      <tall:object priority="low">
         <fo:block>
            <fo:inline font-size="10">Generic offer #4 </fo:inline>
            <fo:inline font-size="10">99.99</fo:inline>
         </fo:block>
      </tall:object>
      <tall:object priority="high">
         <svg:circle>
            <svg:text>Text of special offer #1</svg:text>
         </svg:circle>
      </tall:object>
      <tall:object priority="high">
         <svg:circle>
            <svg:text>Text of special offer #2</svg:text>
         </svg:circle>
      </tall:object>
   </tall:group>
</tall:context>

Syntax proposal

  • topological objects: a very small dictionary of XML elements in the Tall namespace
    • tall:context is the root of the Tall tree, contains information about the output media: width, height and resolution (such allowing different outputs for a computer screen and a sheet of paper having the same size)
    • tall:object encapsulates a piece of content (formatted text, svg shapes, ...) that acts as an atomic object, and allows the definition of per-object topological properties (for example importance)
    • tall:group defines a set of objects bound together by topological relationships
  • topological properties: expressed as CSS statements; altough the set of geometrical properties affected by each topological one could overlap (for example, the width and height of an object could be affected by both its importance and a similarity constraint involving its siblings), at the topological level each property should be completely ortogonal one another
    • similarity: children of the tall:group should create areas that are similar according to the provided list of properties or property shorthands (for example similarity: skin requires areas to be similar according to their presentational characteristics like color, font, border, ...)
    • layout: how the children areas will be arranged in the available space; the property could prescribe either a precise geometry (a 5x3 table, a circle, ...), a more abstract quality (one-dimensional / two-dimensional spatial arrangement, ...), or nothing at all, leaving the engine the task to find a suitable accommodation for each object; three sub-properties allow finer control over specific details of the desired final geometry
      • layout.proximity: states, in abstract or more precise terms, whether the different areas should be placed adjacent one another or kept separate by some span of space
      • layout.alignment: how the content should be aligned with respect to the allocated area
      • layout.order: whether the document order of the Tall instance is relevant and should be preserved by the placement
    • importance: a measure of an object's relevance with respect to its siblings
  • there are a few geometrical properties that could be explicitly set for the topological object:
    • the dimensions of an object could be specified using either width and height, width and aspect-ratio, or even area and aspect-ratio; using just one value it is possible, for example, to specify the aspect ratio of an image without imposing any constraint on its actual size
    • overflow: an element in the tall namespace with precise width and heigth can have overfow: repeat, meaning that other areas with the same dimensions should be created to accommodate the content that cannot be placed in the first one; alternative values are hidden that simply ignores the overflowing portion of content, and grow (which is also the default value for objects with no set width and height) that allows the area to expand (until it reaches the bound of an outer repeatable area)

Layout subproperties

The main component of the layout property controls the "general geometry" of the areas. For example, if layout was set to table(3,4) (or this table layout was judged better than the alternative ones, the output could be:

layout.png

The .alignment component controls the exact placing of the content inside each allocated area. For example if both horizontal and vertical alignment is set to center, we will have:

alignment.png

The .proximity component controls the space between the content area. If we require the presence of a little space, we could have this output:

proximity.png

Finally, the .order component can state that the document order of the objects is not relevant, so that it can be modified in order to create a better output (for example reducing the amount of wasted space):

order.png

New stuff

Jacopo's page: CompleteSyntax
to top


Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Fabio's Wiki? Send feedback