RE: [xsl] GUI layout mechanism in XSLT

Subject: RE: [xsl] GUI layout mechanism in XSLT
From: Ilya Boyandin <ilyabo@xxxxxxxxx>
Date: Thu, 6 Jan 2005 16:14:13 +0100
Hello, Charles and All!

Many thanks for looking at this problem!

The production rules are simple enough to be expressed in English, but
not to code with XSL :) In English I would formulate them this way:


1. Each element (item,vgroup,hgroup) occupies so many cells in the
output table as its size (width and height) requires.

2. Child elements of a <hgroup> are placed horizontally one by one in
a "logical" row.

3. Child elements of a <vgroup> are placed vertically one by one in a
"logical" column.

When I say "logical" I mean that in fact a hgroup can occupy more than
one row in the output table as one or more of its child elements can
be larger.


That's it! The only two things we need now are rules to define the
size of an element and a rule to start from:

4.
  a) The sizes of an <item> element are always (1,1)

  b) The width of a <hgroup> is the sum of the widths of all its child
elements. The height of a <hgroup> is the maximum of the heights of
its child elements.

  c) The width of a <vgroup> is the maximum of the widths of its child
elements. The height of a <vgroup> is the sum of the heights of its
child elements.


5. The root <table> element of the output document should be produced
by the root <layout> element of the input document. The <layout>
element lays out its children vertically (in the same way as a
<vgroup> does).

(Sorry, that I forgot to include the <layout> element into the sample
input previously).


If you try to draw the input layout on paper and map out the output
table, these rules should seem quite natural to you.


Note 1. I cannot formulate a rule for producing a new <tr> element,
because this rule depends, I think, on how the input document is
processed. But obviously, a new row must be started when an element,
which exceeds the bounds of a row, is processed.

Producing <tr>s and </tr>s seems to be the most problematic issue in
the whole task, because here it's necessary in many cases to start a
new <tr>, while a vgroup is processed, and _not to generate the
closing tag_ of this <tr> during this vgroup processing, because some
of the elements, which will be processed later, are likely to be
placed in the same row. This seems to be simply impossible to do in a
straightforward way with XSLT.


Note 2. The colspan attribute is needed just to complete a row in the
output table in case if the last element of this row must be placed
not in the last column of the table. But this is not that important:
another possibility would be to generate empty cells at the end of the
row in this case.


I hope this detailed description helps,

Looking forward to hear from you!

Thanks again,
Ilya

> -----Original Message-----
> Date: Wed, 05 Jan 2005 10:13:17 -0500
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> From: cknell@xxxxxxxxxx
> Subject: RE: [xsl] GUI layout mechanism in XSLT
> 
> Production Rules:
> The problem here isn't writing the XSL tranformation, but in correctly defining the rules for producing the output from the 

input.
> 
> These are the production rules that I infer from your source and output samples. Please look them over and confirm, correct, or 

elaborate on them. I have not been able to determine your rule for
producing a new "tr" element. Please explain how you determine

when to produce a new row.
> 
> 1) The "hgroup" that is the immediate child of the document root should produce a "table" element that will be the root element 

of the output document.
> 
> 2) A "vgroup" child of an "hgroup" element indicates a column that will extend over one or more rows of the output table, the 

number being equal to the number of "item" children of the "vgroup" element.
> 
> 3) "item" elements that are children of "vgroup" elements should be transformed into the first "td" element in as many 

succeeding rows in the output table as there are "item" elements.
> 
> 4) "hgroup" elements that are children of "vgroup" elements should be transformed into "td" elements with an attribute of 

"colspan" whose value is the integer equal to the number of child
"item" elements the "hgroup" element has, and the value of the

element should be equal to the value of the first "item" child of the
"hgroup" element. Subsequent "item" children of the "hgroup"

element are to be transformed similarly, but into successive "tr" elements.
> 
> --
> Charles Knell
> cknell@xxxxxxxxxx - email

Current Thread