cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Homayoun Pourheidari" <homayo...@hotmail.com>
Subject SQL output format?
Date Wed, 19 Jul 2000 18:04:10 GMT
Hi,

I'm a new cocoon user and I'm mainly focusing on using it as a way to
create xml files that can connect to a DB (using jdbc), retreive some
data, format it, and return the results back to the client.

It was fairly easy to figure out how to connect to the DB but once I
get my data, I can't quite figure out how to format it.  I only get
the raw results all munged up together and my attempts at creating a
reasonable .xsl that can somehow format it properly don't seem to
work.

So, I was wondering if someone has run into the same type of problems
or whether there are better examples that can show me how to format
the output of the sql queries better.  I've attached what I have got
so far at the end.

Thanks in advance,
---

Here is what I've got:

------------------- foo.xml ----------
<?xml version="1.0"?>

<?cocoon-process type="sql"?>
<!-- <?cocoon-process type="xslt"?> --> I've this commented since it seems 
to
                                      remove the rowset/row tags if I
                                      include it.

<?xml-stylesheet href="db3.xsl" type="text/xsl"?>

<page>

<title>SQL Search Results for 'foo.xml'</title>

<connectiondefs>
<connection name="myconnname">
<driver>oracle.jdbc.driver.OracleDriver</driver>
<dburl>jdbc:oracle:thin:@my_machinename.hp.com:1521:my_repl</dburl>
<username>myuser</username>
<password>mypasswd</password>
</connection>
</connectiondefs>

<tablewrapper/>

<query connection="ora">
select key, value from dummy_table
</query>

</page>

---------------------- foo.xsl ---------------------
<?xml version="1.0"?>

<!-- Written by Stefano Mazzocchi "stefano@apache.org" -->

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="page">
<xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
<html>
  <head>
   <title>
    <xsl:value-of select="title"/>
   </title>
  </head>

   <body bgcolor="#ffffff">
   <xsl:apply-templates/>

  </body>
</html>
</xsl:template>

<xsl:template match="title">
  <h1 align="center">
    <xsl:apply-templates/>
  </h1>
</xsl:template>

<!-- I only use this tag to form a reasonable table -->
<xsl:template match="tablewrapper">
  <table border="1">
    <tr>
      <td> Key</td>
      <td> Value</td>
    </tr>
  <xsl:apply-templates/>
  </table>
</xsl:template>

<xsl:template match="rowset">
  <xsl:apply-templates select="row"/>
</xsl:template>

<xsl:template match="row">
  <tr>
    <td>
      <xsl:value-of select="key"/>
    </td>
    <td>
     <xsl:value-of select="value"/>
    </td>
  </tr>
</xsl:template>


</xsl:stylesheet>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


Mime
View raw message