| <?xml version="1.0"?> |
| <stx:transform xmlns:stx="http://stx.sourceforge.net/2002/ns" |
| xmlns:sql="http://apache.org/cocoon/SQL/2.0" |
| version="1.0"> |
| |
| <stx:template match="sql:rowset"> |
| <html> |
| <head> |
| <title>Table</title> |
| <link href="/styles/main.css" type="text/css" rel="stylesheet"/> |
| </head> |
| <body> |
| <table> |
| <stx:process-children group="list"/> |
| </table> |
| </body> |
| </html> |
| </stx:template> |
| |
| <stx:group name="list"> |
| <stx:buffer name="first-row"/> |
| |
| <!-- Use data from the first row two times, first for header names |
| and then for content --> |
| <stx:template match="sql:row[1]"> |
| <stx:result-buffer name="first-row"> |
| <stx:process-children group="copy"/> |
| </stx:result-buffer> |
| <tr> |
| <stx:process-buffer name="first-row" group="header"/> |
| </tr> |
| <tr> |
| <stx:process-buffer name="first-row"/> |
| </tr> |
| </stx:template> |
| |
| <stx:template match="sql:row"> |
| <tr> |
| <stx:process-children/> |
| </tr> |
| </stx:template> |
| |
| <stx:template match="sql:*"> |
| <td> |
| <stx:value-of select="."/> |
| </td> |
| </stx:template> |
| </stx:group> |
| |
| <!-- Copy everything --> |
| <stx:group name="copy"> |
| <stx:template match="node()"> |
| <stx:copy attributes="@*"> |
| <stx:process-children/> |
| </stx:copy> |
| </stx:template> |
| </stx:group> |
| |
| <!-- Use element names for header --> |
| <stx:group name="header"> |
| <stx:template match="sql:*"> |
| <th> |
| <stx:value-of select="local-name()"/> |
| </th> |
| </stx:template> |
| </stx:group> |
| |
| </stx:transform> |