[Catalyst] HTML::Widget and output into a html table

A. Pagaltzis pagaltzis at gmx.de
Thu Apr 13 13:46:07 CEST 2006

* John Beppu <john.beppu at gmail.com> [2006-04-13 12:55]:
> DISCLAIMER:  I'm an XSLT n00b.

Some quick untested cleanups…

I don’t like the `copy-of`s that are still left, but I’d need to
test it before I could make more tweaks and I’m disinclined right
now. In general, the right way to use XSLT is to have an identity
transform as the default and use `apply-templates` to drive all
changes, so that every part of the result tree is exposed to rule
application. `copy-of` output cannot be transformed any further.



    <xsl:key name="span" match="span" use="@id" />

    <!-- identity transform -->
    <xsl:template match="node()|@*">
            <xsl:apply-templates select="@*|node()" />

    <xsl:template match="form">
            <xsl:apply-templates select="@*" />
            <table width="100%">
                <colgroup span="1" width="15%" />
                <colgroup span="1" width="35%" />
                <colgroup span="1" width="50%" />
                    <xsl:apply-templates select="node()" />

    <xsl:template match="label">
            <td class="label">
                <xsl:apply-templates />
            <td class="value">
                <xsl:apply-templates select="input|textarea|select" />
                <xsl:copy-of select="key( 'span', concat( @for, '_descriptions' ) )" />
                <xsl:copy-of select="key( 'span', concat( @for, '_errors' ) )" />

    <xsl:template match="input[@type='submit']">
            <td class="label"></td>
            <td class="value" colspan="2">
                <xsl:apply-templates />

    I use span elements with class span_label and span_value to
    represent values that I only want to display (and not edit).

    <xsl:template match="span[@class='span_label']">
            <td class="label">
                <xsl:apply-templates />
            <td class="value" colspan="2">
                <xsl:value-of select="key( 'span', concat( @id, '_value' ) )" />

    <!-- drop -->
    <xsl:template match="legend|span[@class='span_value']">


Aristotle Pagaltzis // <http://plasmasturm.org/>

More information about the Catalyst mailing list