xsl-list
[Top] [All Lists]

RE: GUI layout mechanism in XSLT

2005-01-05 08:13:17
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(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Ilya Boyandin <ilyabo(_at_)gmail(_dot_)com>
Sent:     Wed, 5 Jan 2005 11:49:39 +0100
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] GUI layout mechanism in XSLT

Hello All!

I'm trying to implement a simple GUI layout mechanism with XSLT
without much success for now. The problem is that the task requires to
produce an output tree, which structure differs significantly from the
original tree, and in which the elements are likely to be presented in
a different order.

Here's the problem description:

The input is a GUI elements tree. Elements are contained in horizontal
or vertical groups. Naturally, groups can contain other groups. For
instance:

<hgroup>
<vgroup>
  <item>A1</item>
  <item>A2</item>
</vgroup>
<vgroup>
  <item>B1</item>
  <item>B2</item>
  <hgroup>
    <item>B3</item>
    <item>C3</item>
  </hgroup>
</vgroup>
</hgroup>

The output must be one plain table (without nested tables!) in which
the elements are layed out the same as in the input tree. So for the
input tree above the output should be something like this:

<table>
<tr>
  <td>A1</td>
  <td colspan="2">B1</td>
</tr>
<tr>
  <td>A2</td>
  <td colspan="2">B2</td>
</tr>
<tr>
  <td> </td>
  <td>B3</td>
  <td>C3</td>
</tr>
</table>

As I am a newbie, I don't see an obvious solution. I'd be very
thankful if somebody could give me a hint or in the worst case make it
clear that the problem cannot be solved with XSLT alone.

Thank you!
Ilya



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>