You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stefano Mazzocchi <st...@apache.org> on 2000/07/20 20:17:35 UTC

Re: XML is not a panacea and other sensible observations

Randall Parker wrote:
> 
> As we build toward the next big computer standards panacea craze with XML at its foundation as the magic bullet that will eliminate the
> need for much computer programming and other fanciful dreams it is beneficial to the effective and clear operation of the mind to have
> certain basic truths pointed out. Read this:
> 
> http://www.interlog.com/~gray/markup-abuse.html

Randall,

thanks much for pointing this to me, I hope the XMLHack editors find
this as interesting and worth made known as I think it is.

I would like to comment just one sentence (the last one):

> Equating "the standard solution of a problem" with 
> "finding an XML encoding for the problem" is just a mistake. 

Indeed, but we must not forget that XML is just another form of encoding
and the amount of information passing thru is exactly the same. XMill
proves that you can compress XML better than BZIP if you tune the
compressor for XML syntax... and venture saying that you can achieve
even better results if you tune the compressor for a specific XMLSchema.

Sometimes just the fact that you don't have to write your own parser
it's a reason valid enough to turn your encoding into XML... but I
totally agree that this must be carefully evaluated on each case.

Anyway, this is just another version of the "Golden Hammer" antipattern
and it works for everything ranging from editors to operating systems
from applications to programming languages from protocols to
architectures.

When you have a hammer in your hand, everything starts to look as a
nail. :)

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: Formatting SQL output in Cocoon?

Posted by "M. Homayoun Pourheidari" <ho...@hp.com>.
Hello again,

I updated my IE browser version to the latest (ie 5.5) and things
started working like a charm (I had a pretty old IE viewer ...)  I'm
attaching my xml and xsl files at the end since I know many new comers
would like to see an example like this one that does some simple sql
formatting.

Thanks,
H.

--- sql.xml ---
<?xml version="1.0"?>
<?cocoon-process type="sql"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="sql.xsl" type="text/xsl"?>

<page>
  <title>SQL Search Results for 'dbtest.xml'</title>
  <connectiondefs>
    <connection name="ora">
      <driver>MyDriver</driver>
      <dburl>MyDBUrl</dburl>
      <username>MyUsername</username>
      <password>MyPasswd</password>
    </connection>
  </connectiondefs>

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

</page>

--- sql.xsl ---

<?xml version="1.0"?>
<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>

  <xsl:template match="ROWSET">
    <table border="1">
      <tr>
        <td>KEY FIELD</td>
        <td>VALUE FIELD</td>
      </tr>
      <tr>
        <xsl:for-each select="ROW">
            <td><xsl:value-of select="KEY"/></td>
            <td><xsl:value-of select="VALUE"/></td>
        </xsl:for-each>
      </tr>
     </table>
  </xsl:template>

</xsl:stylesheet>



Re: Formatting SQL output in Cocoon?

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 20 Jul 2000, M. Homayoun Pourheidari wrote:

> Hello,
> 
> I'm having some interesting problems trying to use cocoon to query a
> database and then try to format the results from the database.  I'm
> sure this has come up in this list before but I can't see anyone
> providing a direct answer to how to correctly resolve this situation.  
> Hence I'm posting this message...

XML is case sensitive.

- donald


Formatting SQL output in Cocoon?

Posted by "M. Homayoun Pourheidari" <ho...@hp.com>.
Hello,

I'm having some interesting problems trying to use cocoon to query a database and then try to format the results from the database.  I'm sure
this has come up in this list before but I can't see anyone providing a direct answer to how to correctly resolve this situation.  Hence I'm
posting this message...

I have a table called dummy in my database that has two fields, key and value.  Currently, there is one record in the database with the
values foo and bar.

I have an xml file that queries the database using JDBC:
---- ORIG.XML ---

     <?xml version="1.0"?>
     <?cocoon-process type="sql"?>
     <!-- <?cocoon-process type="xslt"?> -->
     <?xml-stylesheet href="orig.xsl" type="text/xsl"?>
     <page>
      <title>SQL Search Results for 'dbtest.xml'</title>
      <connectiondefs>
       <connection name="ora">
        <driver>MyDriverStuff</driver>
        <dburl>jMyDBUrlStuff</dburl>
        <username>MyUser</username>
        <password>MyPasswd</password>
       </connection>
      </connectiondefs>

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

     </page>

This XML produces the following XML source:
--- DERIVED1.XML ---

     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
     <!-- <?cocoon-process type="xslt"?> -->
     <?xml-stylesheet href="db5.xsl" type="text/xsl"?>
     <page>
      <title>SQL Search Results for 'dbtest.xml'</title>
      <ROWSET><ROW id="0"><KEY>foo</KEY><VALUE>bar</VALUE></ROW></ROWSET>

     </page>
     <!-- This page was served in 172 milliseconds by Cocoon 1.7.4 -->

     However, The only thing I see in my browser window are the results of my query -->  foobar

     I do have rules in my xsl file that should handle the formatting of the ROWSET, ROW, KEY, and VALUE tags but I don't get any
     formatting.  I believe this is because I don't have any "XSLT" processors defined in my original XML file (ORIG.XML) (The SQL processor
     does not understand doesn't seem to be able to process my XML/XSL tag directives).  Am I correct in this assumption?

     So, I uncomment the processor-type line for XSLT and I get the following XML file produced:
     ---- DERIVED2.XML ---

     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
     <html><head><title>SQL Search Results for 'dbtest.xml'</title></head><body bgcolor="#ffffff">
      <h1 align="center">SQL Search Results for 'dbtest.xml'</h1>
      foobar

     </body></html>
     <!-- This page was served in 109 milliseconds by Cocoon 1.7.4 -->

     I can now see the title line "SQL Search Results for 'dbtest.xml'" followed by the same "foobar" value but as you can see in
     DERIVED2.XML, I've lost my ROWSET, ROW, and other database related tags.

     So, the question is: how do I use the two processors (sql and xslt) but at the same time be able to nicely format the output of my query
     into some sort of a meaningful table output?

     For sanity check, I will include my XSL file here:
     --- ORIG.XSL ---

     <?xml version="1.0"?>
     <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>
       <xsl:template match="rowset">
         <xsl:apply-templates select="row"/>
       </xsl:template>
       <xsl:template match="row">
         <tr>
           <td> Key is:
             <xsl:value-of select="key"/>
           </td>
           <td> Value is:
             <xsl:value-of select="value"/>
           </td>
         </tr>
       </xsl:template>
     </xsl:stylesheet>

     Regards,
     H.