We tend to think of a table as a sequence of rows (or a seqeunce of columns). As evidence, in HTML and LaTeX, if you are making a table, you build it row by row, and within each row, cell by cell. If there are special features like a cell that spans more than one column or row, you have to give your code for that cell special attention. You could say that we focus on an address first, and then use that to get to cell content. "What is in the 2nd row, 3rd column? Ah, I see."
I'm considering flipping that with xml and xslt somehow. I'd like to put cell content first, and have content lead to address. It would be like looking at a cell somewhere in a table, then moving your eyes left and up to learn that content's address.
I'd like to have xml source that would go something like this:
<table>
<category-type-A id="plants">Plants you eat</category-type-A>
<category-type-A id="fruit" A="plants">Fruit</category-type-A>
<category-type-A id="veg" A="plants">Vegetables</category-type-A>
<category-type-B id="colors">Colors</category-type-B>
<category-type-B id="red" B="colors">Red</category-type-B>
<category-type-B id="green" B="colors">Green</category-type-B>
<cell A="fruit" B="red">Strawberry</cell>
<cell A="veg" B="red">Beet</cell>
<cell A="fruit" B="green">Guava</cell>
<cell A="veg" B="green">Broccoli</cell>
<cell A="fruit;veg" B="red">Tomato</cell>
<cell A="fruit" B="red;green">Apple</cell>
<cell A="fruit">Orange</cell>
</table>
And after translation with xslt, end up with a table in (at a minimum) HTML that looks like this (ignoring styling, just considering cell-divisions and positioning):
Plants you eat
|---------------------|
| Fruit |Vegetables|
|--|---------------------|
|R |Strawberry|Beet |
|e |---------------------|
|d |Tomato |
| |---------------------|
C | |A | |
o | |p | |
l |--|p |----------|
o |G |l |Broccoli |
r |r |e | |
s |e |----------|----------|
|e |Guava |
|n | |
|--|----------|
| |Orange |
|--|----------|
I realize that this would become impossible if there are two many cells that point to too many categories. So let's agree that the xml author wouldn't let things get out of hand.
Has anyone already 'cracked this nut', as far as coming up with xslt for something similar to this? I'm not asking anyone to try to write some xslt for me. I'd like to know educated opinions on whether this is a viable approach toward table-writing in xml.
No comments:
Post a Comment