Your template HTML has id attributes in the <tr> elements which you use to find the appropriate node in the template.

When you unroll the tree, do you remove this attribute? This would be necessary to get valid XHTML, as no two nodes in an XHTML document can have the same id.

This leads to a more general question of attribute rewriting with this tree-based approach. I'm thinking specifically in terms of using a class attribute instead of putting in HTML-presentation based attributes like BGCOLOR.

I assume it is done in a similar way to the content, in that you just repeat the row with another 'iteraten' id for each new attribute (easier for page designers, perhaps). The alternative is to have a single sample line, and programmatically replace the class value, as per the element content for each node. This approach has the obvious disadvantage that a designer would only see a table with one row.

One final thing to consider with the DWIM unrolling function: we often like to fill-out a table with a single row saying "No records returned" or similar when there are no records. This might be a useful extra argument to the DWIM function.

enough rambling... interesting article


In reply to Re: HTATR II: HTML table generation via DWIM tree rewriting by Anonymous Monk
in thread HTATR II: HTML table generation via DWIM tree rewriting by princepawn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.