cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <l...@keeper2k1.fsnet.co.uk>
Subject Applying custom style sheets before logicsheets [HELP!]
Date Sat, 15 Dec 2001 20:34:37 GMT
Hi,

This question may seem very simple, but bear with me as I am quite new to cocoon.

I am using Cocoon 2.  I have an XSP page [testdb.xsp], and want to pass this through a stylesheet
[testdb.xsl], then apply the built-in cocoon 2 logic sheets [particularly the esql], apply
a xml to html stylesheet and then serialize as html.  What do I have to do to make this work?

I have started by placing using esql from the testdb.xsp directly - this works as expected.
 Trouble is, I want the SQL queries to be "generated" by the testdb.xsl stylesheet, so removing
the esql from testdb.xsp and making the testdb.xsl generate them instead does not "execute"
them - they stay as <esql:...> even in the outputted html.

I have tried many things, such as adding/removing the esql namespace from the start of the
original xsp document, the xsp generated from testdb.xsl, etc, the files below are what are
"known" to not work.  I think it is just something very simple that I am missing...

Here is the relevant part of the sitemap:
   <map:match pattern="testdb">
     <map:generate type="serverpages" src="testdb.xsp"/>
     <map:transform src="testdb.xsl"/> 
     <map:transform src="table.xsl"/> 
     <map:transform src="stylesheets/dynamic-page2html.xsl"/> 
     <map:serialize/>
   </map:match>

testdb.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>


<xsl:stylesheet
    version="1.0"
    xmlns:xsp="http://apache.org/xsp"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsp-request="http://apache.org/xsp/request/2.0"
    xmlns:esql="http://apache.org/cocoon/SQL/v2"
>

<xsl:template match="/">
  <xsp:page>
    <xsl:apply-templates/>
  </xsp:page>
</xsl:template>

  <xsl:template match="data-display">
    <esql:connection>
      <esql:pool>personnel</esql:pool>
      <esql:execute-query>
        <xsl:apply-templates select="query"/>
        <xsl:apply-templates select="display"/>
      </esql:execute-query>
    </esql:connection>
  </xsl:template>


  <xsl:template match="query">
        <esql:query>
	  <xsl:value-of select="."/>
	</esql:query>
  </xsl:template>

  <xsl:template match="display">
    <esql:results>
      <xsl:apply-templates/>
    </esql:results>
  </xsl:template>

  <xsl:template match="display-table">
    <br/>
    <table>
      <header>
        <xsl:for-each select="column">
          <cell>
  	    <text>
	      <xsl:value-of select="title"/>
	   </text>
          </cell>
        </xsl:for-each>
      </header>

      <!-- header finished, now the data -->

      <body>
        <esql:row-results>
          <row>
            <xsl:for-each select="column">
    	      <cell>
	        <!-- make a reference to the action here -->
		<action>
                  <xsl:value-of select="action/@name"/> <xsl:value-of select="action/@key"/>
		</action>
	        <text>
                  <xsl:value-of select="data/@source"/>
		  <xsl:value-of select="text"/>
		</text>
	      </cell>
	    </xsl:for-each>
          </row>
        </esql:row-results>
      </body>
    </table>
  </xsl:template>

  <xsl:template match="@*|node()" priority="-1">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

testdb.xsp:
<?xml version="1.0"?>

<xsp:page language="java"
  xmlns:xsp="http://apache.org/xsp"
  >
  <page>
    <title>Test</title>

    <data-display>
      <query>SELECT uid, userid, password FROM users</query>
      <display>
        <display-table>
          <column>
	    <title>Username</title>
	    <data source="userid"/>
	  </column>
	  <column>
	    <title>Password</title>
	    <action name="view" key="uid"/>
	    <data source="password"/>
	  </column>
	  <column>
            <title></title>
	    <action name="delete" key="uid"/>
	    <text>delete</text>
	  </column>
        </display-table>
      </display>
    </data-display>
  </page>
</xsp:page>

thanks for any help,





_______________________________________________________________________
Never pay another Internet phone bill!
Freeserve AnyTime, for all the Internet access you want, day and night, only £12.99 per month.
Sign-up at http://www.freeserve.com/time/anytime



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message