cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j....@t-online.de (Juergen Hermann)
Subject SQL Processor Example
Date Sat, 04 Dec 1999 00:36:18 GMT
Hi!

The following is an XSLT stylesheet that transforms _ANY_ 
SQL Processor source into an XHTML page containing the data
within a table. Field names are automatically used as column
headers.

You might want it to add to the samples...

Ciao, J├╝rgen

--- rowset.xml ----------------------------
<?xml version="1.0" encoding="iso-8859-1"?>

<?cocoon-process type="sql"?>

<?xml-stylesheet href="rowset.page.xhtml.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>

<page>
 <title>ROWSET Example</title>   

 <connectiondefs>
  <connection name="www_odbc">
   <driver>sun.jdbc.odbc.JdbcOdbcDriver</driver>
   <dburl>jdbc:odbc:WWW_CSV</dburl>
   <username></username>
   <password></password>
  </connection>
 </connectiondefs> 
 
 <query connection="www_odbc">
  select * from Phone.csv
 </query>
 
</page>

--- rowset.page.xhtml.xsl ----------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
    ROWSET XSLT Stylesheet
-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/TR/xhtml1/strict">
  <xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
  <!-- PAGE ========================================================-->
  <xsl:template match="page">
    <xsl:processing-instruction name="cocoon-format">type="text/html"</xsl:processing-instruction>
    <xsl:comment>
      XSL <xsl:value-of select="system-property('xsl:version')"/> /
      <xsl:value-of select="system-property('xsl:vendor')"/> 
      (<xsl:value-of select="system-property('xsl:vendor-url')"/>)
    </xsl:comment>
    <html>
      <head>
        <link rel="stylesheet" type="text/css" href="rowset.css"/>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
        <meta http-equiv="Pragma" content="no-cache"/>
        <meta http-equiv="Expires" content="0"/>
        <title>
          <xsl:value-of select="title"/>
        </title>
      </head>
      <body>
        <h1>
          <a name="top">
            <xsl:value-of select="title"/>
          </a>
        </h1>
        <xsl:apply-templates select="ROWSET"/>
      </body>
    </html>
  </xsl:template>
  <!-- ROWSET ======================================================-->
  <xsl:template match="ROWSET">
    <table cellspacing="2" cellpadding="2" border="0" bordercolor="#000000">
      <xsl:apply-templates select="ROW">
        <xsl:sort select="format-number(@ID,'0000')"/>
      </xsl:apply-templates>
    </table>
  </xsl:template>
  <!-- ROW =========================================================-->
  <xsl:template match="ROW">
    <xsl:if test="position() = 1">
      <tr class="header">
        <td class="header">ID</td>
        <xsl:apply-templates mode="header"/>
      </tr>
    </xsl:if>
    <tr class="rowset{position() mod 2}">
      <td align="right"><xsl:value-of select="@ID"/></td>
      <xsl:apply-templates/>
    </tr>
  </xsl:template>
  <!-- ROW/* =======================================================-->
  <xsl:template match="ROW/*" mode="header">
    <td class="header">
      <xsl:value-of select="name()"/>
    </td>
  </xsl:template>
  <xsl:template match="ROW/*">
    <td>
      <xsl:value-of select="."/>
    </td>
  </xsl:template>
</xsl:stylesheet>

--- rowset.css ----------------------------
/*
    Rowset CSS Stylesheet
*/
body {
    background-color:#FFFFFF;
    color:#000000;
    font-family:Helvetica;
    font-size:10pt;
}
h1 {
    font-size:20pt;
}
h2 {
    color:#222222;
    font-size:16pt;
    margin-bottom:6pt;
}
h3 {
    color:#444444;
    font-size:12pt;
    margin-bottom:2pt;
}
ul {
    margin-top:0pt;
}
pre {
    font-family:Lucida Console,Courier New,Courier,monospace;
}
td {
    font-family:Helvetica;
    font-size:10pt;
}
td.header {
    font-style:italic;
}
tr.header {
    background-color:#FFFFCC;
    font-weight:bold;
}
tr.rowset1 {
    background-color:#FFFFF8;
}
tr.rowset0 {
    background-color:#FFFFE8;
}




Mime
View raw message