cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: ReinhardHorn
Date Sat, 10 Jul 2004 02:23:43 GMT
   Date: 2004-07-09T19:23:43
   Editor: JoergHeinicke <joerg.heinicke@gmx.de>
   Wiki: Cocoon Wiki
   Page: ReinhardHorn
   URL: http://wiki.apache.org/cocoon/ReinhardHorn

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -46,27 +46,27 @@
 [[BR]]
 [[BR]]
 ''band.html''
-{{{ 
-<html>
- <body>
-  <form action="insert">
-   <h4>Please insert a band</h4> 
-   <table>
-    <tr>
-     <td>Number</td>
-     <td><input type="text" name="bands.band_id"/>
-    </tr>
-    <tr>
-     <td>Name</td>
-     <td><input type="text" name="bands.band"/>
-    </tr>
-    <tr>
-     <td><input type="submit" name="action" value="Insert"/>
-    </tr>
-   </table>
-  </form>
- </body>
-</html>
+{{{ 
+<html>
+ <body>
+  <form action="insert">
+   <h4>Please insert a band</h4> 
+   <table>
+    <tr>
+     <td>Number</td>
+     <td><input type="text" name="bands.band_id"/>
+    </tr>
+    <tr>
+     <td>Name</td>
+     <td><input type="text" name="bands.band"/>
+    </tr>
+    <tr>
+     <td><input type="submit" name="action" value="Insert"/>
+    </tr>
+   </table>
+  </form>
+ </body>
+</html>
 }}}
 [[BR]]
 The parameter names of the text fields (bands.band_id, bands.band)will become very important
in the action configuration (see below).  To display the input results I created
@@ -74,56 +74,56 @@
 [[BR]]
 [[BR]] 
 ''bands.xsp''
-{{{<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsp:page language="java"
-  xmlns:xsp="http://apache.org/xsp"
-  xmlns:esql="http://apache.org/cocoon/SQL/v2">
- <page>
-  <esql:connection>
-   <esql:pool>kaffee</esql:pool>
-    <esql:execute-query>
-     <esql:query>SELECT band_id, band FROM bands</esql:query>
-      <esql:results>
-       <bands>
-        <esql:row-results>
-         <band>
-          <esql:get-columns/>
-         </band>
-        </esql:row-results>
-       </bands>
-      </esql:results>
-    </esql:execute-query>
-  </esql:connection>
- </page>
-</xsp:page>
+{{{<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsp:page language="java"
+  xmlns:xsp="http://apache.org/xsp"
+  xmlns:esql="http://apache.org/cocoon/SQL/v2">
+ <page>
+  <esql:connection>
+   <esql:pool>kaffee</esql:pool>
+    <esql:execute-query>
+     <esql:query>SELECT band_id, band FROM bands</esql:query>
+      <esql:results>
+       <bands>
+        <esql:row-results>
+         <band>
+          <esql:get-columns/>
+         </band>
+        </esql:row-results>
+       </bands>
+      </esql:results>
+    </esql:execute-query>
+  </esql:connection>
+ </page>
+</xsp:page>
 }}}
 [[BR]] 
 ''bands.xsl''
-{{{<?xml version="1.0"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-     xmlns:esql="http://apache.org/cocoon/SQL/v2">
- <xsl:template match="bands">
-  <html>
-   <body>
-    <form action="bands" method="get"> 
-     <table border="1">
-       <tr>
-        <th>Band ID</th>
-        <th>Name</th>
-       </tr>
-        <xsl:apply-templates/> 
-     </table>
-    </form>
-   </body>
-  </html>
- </xsl:template>
- <xsl:template match="band">
-   <tr>
-     <td><xsl:value-of select="BAND_ID"/></td>
-     <td><xsl:value-of select="BAND"/></td>
-   </tr>
- </xsl:template>
-</xsl:stylesheet>
+{{{<?xml version="1.0"?>
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+     xmlns:esql="http://apache.org/cocoon/SQL/v2">
+ <xsl:template match="bands">
+  <html>
+   <body>
+    <form action="bands" method="get"> 
+     <table border="1">
+       <tr>
+        <th>Band ID</th>
+        <th>Name</th>
+       </tr>
+        <xsl:apply-templates/> 
+     </table>
+    </form>
+   </body>
+  </html>
+ </xsl:template>
+ <xsl:template match="band">
+   <tr>
+     <td><xsl:value-of select="BAND_ID"/></td>
+     <td><xsl:value-of select="BAND"/></td>
+   </tr>
+ </xsl:template>
+</xsl:stylesheet>
 }}}
 [[BR]]
 Attention: If you don't see any data keep in mind that XML-Tags are case sensitive. 
@@ -135,17 +135,17 @@
 The configuration file maps your database table to your input params in the page.
 [[BR]]
 ''insert.xml''
-{{{
-<?xml version="1.0" encoding="ISO-8859-1"?>
- <bands>
-  <connection>kaffee</connection>
-  <table name="bands">
-   <values>
-    <value name="band_id" type="int"/>
-    <value name="band" type="string"/>
-   </values>
-  </table>
- </bands>
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <bands>
+  <connection>kaffee</connection>
+  <table name="bands">
+   <values>
+    <value name="band_id" type="int"/>
+    <value name="band" type="string"/>
+   </values>
+  </table>
+ </bands>
 }}}
 [[BR]]
 The connection-tag refers to your datasource in the cocoon.xconf file. 
@@ -165,13 +165,13 @@
 [[BR]]
 [[BR]]
 ''sitemap.xmap''
-{{{
-...
-<map:action name="mod-db-add" src="org.apache.cocoon.acting.modular.DatabaseAddAction">
- <descriptor>xml/insert.xml</descriptor>
- <throw-exception>true</throw-exception>
-</map:action>
-...
+{{{
+...
+<map:action name="mod-db-add" src="org.apache.cocoon.acting.modular.DatabaseAddAction">
+ <descriptor>xml/insert.xml</descriptor>
+ <throw-exception>true</throw-exception>
+</map:action>
+...
 }}}
 [[BR]]
 Since Modular Database Actions are not located in Cocoon core package it is necessary to
register them in the sitemap configuration file. The source attribute refers to the corresponding
Java class incapsulating the action. It is important to make a correct entry. Note that the
modular package is a subpackage of the original database action package. There are also delete
and update action classes. You can register those classes in the same manner. We will need
the in the later examples. The descriptor file contains the action configuration described
in the previous step.           
@@ -180,28 +180,28 @@
 [[BR]]
 [[BR]]
 ''sitemap.xmap''
-{{{
-...
-<map:match pattern="insert"> 
- <map:act type="mod-db-add">
-  <map:generate type="serverpages" src="xsp/bands.xsp"/>
-  <map:transform type="xslt" src="xsl/bands.xsl"/>
-  <map:serialize type="html"/>
- </map:act>
-</map:match>
-...
+{{{
+...
+<map:match pattern="insert"> 
+ <map:act type="mod-db-add">
+  <map:generate type="serverpages" src="xsp/bands.xsp"/>
+  <map:transform type="xslt" src="xsl/bands.xsl"/>
+  <map:serialize type="html"/>
+ </map:act>
+</map:match>
+...
 }}}
 [[BR]]
 The database action is executed immediately after the request. If the execution has been
successful the act method of the database action class will return a filled map that contains
the return value or an empty map if the execution has failed. In the letter case actions normally
return the execution to the outer block and the request processing continues. However in this
simple example that is not the case because a missing entry in the band_id input field will
cause an exception to be thrown. 
 
 In a real world example it would be necessary to validate the request parameters before using
the database action. In addition to that there would be an outer block to be executed in case
that the validation fails. Because in this example that is not the case we need exceptionally
a second matcher that maps the HTML page. 
 [[BR]]
-{{{
-...
-<map:match pattern="bands"> 
- <map:read mime-type="text/html" src="html/band.html"/>
-</map:match>
-...
+{{{
+...
+<map:match pattern="bands"> 
+ <map:read mime-type="text/html" src="html/band.html"/>
+</map:match>
+...
 }}}
 [[BR]]     
 ===  Execute the Example ===
@@ -238,20 +238,20 @@
 ===  Configuration of Autoincrement Modules ===
 [[BR]]
 ''cocoon.xconf''
-{{{
-...
-<autoincrement-modules>
-...
- <component-instance class=
-  "org.apache.cocoon.components.modules.database.HsqlIdentityAutoIncrementModule"     
-   logger="core.modules.auto" name="auto"/>
- <component-instance logger="core.modules.auto" 
- name="mysql" class="org.apache.cocoon.components.modules.database.MysqlAutoIncrementModule"/>
- <component-instance logger="core.modules.auto" 
-  name="manual" class="org.apache.cocoon.components.modules.database.ManualAutoIncrementModule"/>
-...
-</autoincrement-modules>
-...
+{{{
+...
+<autoincrement-modules>
+...
+ <component-instance class=
+  "org.apache.cocoon.components.modules.database.HsqlIdentityAutoIncrementModule"     
+   logger="core.modules.auto" name="auto"/>
+ <component-instance logger="core.modules.auto" 
+ name="mysql" class="org.apache.cocoon.components.modules.database.MysqlAutoIncrementModule"/>
+ <component-instance logger="core.modules.auto" 
+  name="manual" class="org.apache.cocoon.components.modules.database.ManualAutoIncrementModule"/>
+...
+</autoincrement-modules>
+...
 }}}
 [[BR]]
 Consider the last entry. The manual autoincrement module is different form the others because
@@ -268,21 +268,21 @@
 [[BR]]
 [[BR]]
 ''insert.xml''
-{{{
-<?xml version="1.0" encoding="ISO-8859-1"?>
- <bands>
-  <connection>kaffee</connection>
-  <table name="bands">
-   <keys>
-     <key name="band_id" type="int" autoincrement="true">
-      <mode name="manual" type="autoincr"/>
-     </key>
-    </keys>
-   <values>
-    <value name="band" type="string"/>
-   </values>
-  </table>
- </bands>
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <bands>
+  <connection>kaffee</connection>
+  <table name="bands">
+   <keys>
+     <key name="band_id" type="int" autoincrement="true">
+      <mode name="manual" type="autoincr"/>
+     </key>
+    </keys>
+   <values>
+    <value name="band" type="string"/>
+   </values>
+  </table>
+ </bands>
 }}}
 [[BR]]
 ===  Changes in the HTML File ===
@@ -291,23 +291,23 @@
 [[BR]]
 [[BR]]
 ''band.html''
-{{{
-<html>
- <body>
-  <form action="insert">
-   <h4>Please insert a Band</h4> 
-   <table>
-    <tr>
-     <td>Name</td>
-     <td><input type="text" name="bands.band"/>
-    </tr>
-    <tr>
-     <td><input type="submit" name="action" value="Insert"/>
-    </tr>
-   </table>
-  </form>
- </body>
-</html>
+{{{
+<html>
+ <body>
+  <form action="insert">
+   <h4>Please insert a Band</h4> 
+   <table>
+    <tr>
+     <td>Name</td>
+     <td><input type="text" name="bands.band"/>
+    </tr>
+    <tr>
+     <td><input type="submit" name="action" value="Insert"/>
+    </tr>
+   </table>
+  </form>
+ </body>
+</html>
 }}}
 [[BR]]
 That's it. Execute the example. If you want to use a different input module, for example
@@ -328,40 +328,40 @@
 [[BR]]
 In this example the updates are made in the XSP/XSL page directly. The stylesheet got a text
field
 for data entries and a submit button to invoke the update action. Attention must be paid
to the
-param names. Indexed params are concatenated by ''tablename.columnname[:*]''. The asterisk
is a token for
+param names. Indexed params are concatenated by ''tablename.columnname[*]''. The asterisk
is a token for
 the row index. As you can see I have parameterized the name of the input fields with the
value of the ID.
 [[BR]]
 [[BR]]
 ''bands.xsl''
-{{{
- <?xml version="1.0"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-     xmlns:esql="http://apache.org/cocoon/SQL/v2">
- <xsl:template match="bands">
-  <html>
-   <body>
-    <form action="bands" method="get"> 
-     <table border="1">
-       <tr>
-        <th>Band ID</th>
-        <th>Name</th>
-       </tr>
-        <xsl:apply-templates/> 
-     </table>
-     <input type="submit" name="action" value="Save"/>
-    </form>
-   </body>
-  </html>
- </xsl:template>
- <xsl:template match="band">
-   <xsl:variable name="band_id" select="BAND_ID"/>
-   <xsl:variable name="band" select="BAND"/>
-   <tr>
-     <td><xsl:value-of select="$band_id"/><input type="hidden" name="bands.band_id[{$band_id}]"
value="{$band_id}"/></td>
-     <td><input type="text" name="bands.band[{$band_id}]" value="{$band}"/></td>
-   </tr>
- </xsl:template>
-</xsl:stylesheet>
+{{{
+ <?xml version="1.0"?>
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+     xmlns:esql="http://apache.org/cocoon/SQL/v2">
+ <xsl:template match="bands">
+  <html>
+   <body>
+    <form action="bands" method="get"> 
+     <table border="1">
+       <tr>
+        <th>Band ID</th>
+        <th>Name</th>
+       </tr>
+        <xsl:apply-templates/> 
+     </table>
+     <input type="submit" name="action" value="Save"/>
+    </form>
+   </body>
+  </html>
+ </xsl:template>
+ <xsl:template match="band">
+   <xsl:variable name="band_id" select="BAND_ID"/>
+   <xsl:variable name="band" select="BAND"/>
+   <tr>
+     <td><xsl:value-of select="$band_id"/><input type="hidden" name="bands.band_id[{$band_id}]"
value="{$band_id}"/></td>
+     <td><input type="text" name="bands.band[{$band_id}]" value="{$band}"/></td>
+   </tr>
+ </xsl:template>
+</xsl:stylesheet>
 }}}  
 [[BR]] 
 ===  The Update Configuration ===
@@ -371,35 +371,35 @@
 fields need a corresponding value of ''slave''. In this case I added a parameter
 tag for the indexed request params. Notice the mode attributes. The name has a
 value of ''request-param'' and a type value of ''all''. This means that the entry
-page is expected to have varying request params with the names ''bands.band_id[:*]''
-and ''bands.band[:*]''. These params contain the key values of the database tables.
+page is expected to have varying request params with the names ''bands.band_id[*]''
+and ''bands.band[*]''. These params contain the key values of the database tables.
 Each row is identified by a primary key value to make sure that the correct datarow
 will be modified. The index represented by the asterisk must contain the ''distinct'' 
 key values of the primary key field. Internally the indexes vary between 0 and rows - 1.

 [[BR]]
 [[BR]]
 ''update.xml''
-{{{
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<bands>
- <connection>kaffee</connection>
- <table name="bands">
-  <keys>
-   <key name="band_id" type="int" set="master">
-    <mode name="request-param" type="all">
-     <parameter>bands.band_id[*]</parameter>
-    </mode>
-   </key>
-  </keys>
-  <values>
-   <value name="band" type="string" set="slave">
-    <mode name="request-param" type="all">
-     <parameter>bands.band[*]</parameter>
-    </mode>
-   </value>
-  </values>
- </table>
-</bands>
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<bands>
+ <connection>kaffee</connection>
+ <table name="bands">
+  <keys>
+   <key name="band_id" type="int" set="master">
+    <mode name="request-param" type="all">
+     <parameter>bands.band_id[*]</parameter>
+    </mode>
+   </key>
+  </keys>
+  <values>
+   <value name="band" type="string" set="slave">
+    <mode name="request-param" type="all">
+     <parameter>bands.band[*]</parameter>
+    </mode>
+   </value>
+  </values>
+ </table>
+</bands>
 }}}  
 [[BR]]
 ===  Register the Update Action ===
@@ -408,13 +408,13 @@
 [[BR]]
 [[BR]]
 ''sitemap.xmap''
-{{{
-...
-<map:action name="mod-db-upd" src="org.apache.cocoon.acting.modular.DatabaseUpdateAction">
- <descriptor>xml/update.xml</descriptor>
- <throw-exception>true</throw-exception>
-</map:action>
-... 
+{{{
+...
+<map:action name="mod-db-upd" src="org.apache.cocoon.acting.modular.DatabaseUpdateAction">
+ <descriptor>xml/update.xml</descriptor>
+ <throw-exception>true</throw-exception>
+</map:action>
+... 
 }}}
 [[BR]]    
 ===  The Matcher ===
@@ -425,19 +425,19 @@
 [[BR]]
 [[BR]]     
 ''sitemap.xmap''
-{{{
-...
-<map:match pattern="bands">
- <map:act type="mod-db-upd">
-  <map:generate type="serverpages" src="xsp/bands.xsp"/>
-  <map:transform type="xslt" src="xsl/bands.xsl"/>
-  <map:serialize type="html"/>
- </map:act>
- <map:generate type="serverpages" src="xsp/bands.xsp"/>
- <map:transform type="xslt" src="xsl/bands.xsl"/>
- <map:serialize type="html"/>
-</map:match>
-...
+{{{
+...
+<map:match pattern="bands">
+ <map:act type="mod-db-upd">
+  <map:generate type="serverpages" src="xsp/bands.xsp"/>
+  <map:transform type="xslt" src="xsl/bands.xsl"/>
+  <map:serialize type="html"/>
+ </map:act>
+ <map:generate type="serverpages" src="xsp/bands.xsp"/>
+ <map:transform type="xslt" src="xsl/bands.xsl"/>
+ <map:serialize type="html"/>
+</map:match>
+...
 }}}   
 [[BR]]
 [[BR]]
@@ -451,35 +451,35 @@
 [[BR]]
 [[BR]]
 ''bands.xsl''
-{{{
-<?xml version="1.0"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-     xmlns:esql="http://apache.org/cocoon/SQL/v2">
- <xsl:template match="bands">
-  <html>
-   <body>
-    <form action="bands" method="get">
-     <table border="1">
-       <tr>
-        <th>Band ID</th>
-        <th>Name</th>
-       </tr>
-        <xsl:apply-templates/> 
-     </table>
-     <input type="submit" name="action" value="Delete"/>
-    </form>
-   </body>
-  </html>
- </xsl:template>
- <xsl:template match="band">
-   <xsl:variable name="band_id" select="BAND_ID"/>
-   <xsl:variable name="band" select="BAND"/>
-   <tr>
-     <td><xsl:value-of select="$band_id"/></td>
-     <td><input type="checkbox" name="bands.band_id[{$band_id}]" value="{$band_id}<xsl:value-of
select="$band"/></input></td>
-   </tr>
- </xsl:template>
-</xsl:stylesheet>
+{{{
+<?xml version="1.0"?>
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+     xmlns:esql="http://apache.org/cocoon/SQL/v2">
+ <xsl:template match="bands">
+  <html>
+   <body>
+    <form action="bands" method="get">
+     <table border="1">
+       <tr>
+        <th>Band ID</th>
+        <th>Name</th>
+       </tr>
+        <xsl:apply-templates/> 
+     </table>
+     <input type="submit" name="action" value="Delete"/>
+    </form>
+   </body>
+  </html>
+ </xsl:template>
+ <xsl:template match="band">
+   <xsl:variable name="band_id" select="BAND_ID"/>
+   <xsl:variable name="band" select="BAND"/>
+   <tr>
+     <td><xsl:value-of select="$band_id"/></td>
+     <td><input type="checkbox" name="bands.band_id[{$band_id}]" value="{$band_id}<xsl:value-of
select="$band"/></input></td>
+   </tr>
+ </xsl:template>
+</xsl:stylesheet>
 }}}
 [[BR]]
 You can use checkboxes to mark the rows to be deleted. The value of the checkbox is set to

@@ -490,20 +490,20 @@
 [[BR]]
 [[BR]]
 ''delete.xml''
-{{{
-<?xml version="1.0" encoding="ISO-8859-1"?>
- <bands>
-  <connection>kaffee</connection>
-  <table name="bands">
-   <keys>
-    <key name="band_id" type="int" set="master">
-     <mode name="request-param" type="all">
-      <parameter>bands.band_id[*]</parameter>
-     </mode>
-    </key>
-   </keys>
-  </table>
- </bands>
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+ <bands>
+  <connection>kaffee</connection>
+  <table name="bands">
+   <keys>
+    <key name="band_id" type="int" set="master">
+     <mode name="request-param" type="all">
+      <parameter>bands.band_id[*]</parameter>
+     </mode>
+    </key>
+   </keys>
+  </table>
+ </bands>
 }}}   
 [[BR]]
 The configuration is a minimal one. In fact you can copy the update configuration and remove
the values tag.
@@ -512,27 +512,27 @@
 [[BR]]
 [[BR]]
 ''sitemap.xmap''
-{{{
-...
-<map:match pattern="bands>
- <map:act type="request">
-  <map:parameter name="parameters" value="true"/> 
-  <map:select type="parameter">
-   <map:parameter name="parameter-selector-test" value="{action}"/>
-   <map:when test="Delete">
-    <map:act type="mod-db-del">
-     <map:generate type="serverpages" src="xsp/bands.xsp"/>
-     <map:transform type="xslt" src="xsl/bands.xsl"/>
-     <map:serialize type="html"/>
-    </map:act>
-   </map:when>
-  </map:select>
- </map:act>
- <map:generate type="serverpages" src="xsp/bands.xsp"/>
- <map:transform type="xslt" src="xsl/bands.xsl"/>
- <map:serialize type="html"/>
-</map:match>
-...
+{{{
+...
+<map:match pattern="bands>
+ <map:act type="request">
+  <map:parameter name="parameters" value="true"/> 
+  <map:select type="parameter">
+   <map:parameter name="parameter-selector-test" value="{action}"/>
+   <map:when test="Delete">
+    <map:act type="mod-db-del">
+     <map:generate type="serverpages" src="xsp/bands.xsp"/>
+     <map:transform type="xslt" src="xsl/bands.xsl"/>
+     <map:serialize type="html"/>
+    </map:act>
+   </map:when>
+  </map:select>
+ </map:act>
+ <map:generate type="serverpages" src="xsp/bands.xsp"/>
+ <map:transform type="xslt" src="xsl/bands.xsl"/>
+ <map:serialize type="html"/>
+</map:match>
+...
 }}}
 [[BR]]
 To prevent a complete deletion of the whole table the delete action is wrapped in a request
action.
@@ -556,75 +556,75 @@
 [[BR]]
 ''bands.xsl''
 [[BR]]
-{{{
-<?xml version="1.0"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                               xmlns:esql="http://apache.org/cocoon/SQL/v2">
- <xsl:param name="action"/>
- <xsl:param name="bands.band_id"/>
- <xsl:param name="bands.band"/>
- <xsl:template match="bands">
-  <html>
-   <body>
-    <h1>Bands</h1>
-    <form name="f" action="update" method="get"> 
-     <table border="1">
-      <xsl:apply-templates/>
-      <xsl:if test="$action='Edit'">
-       <tr>
-        <td>#</td>
-        <td><input type="text" name="bands.band" value=""/></td> 
-        <td><a href="javascript:document.f.submit()">Insert</a>
-            <input type="hidden" name="action" value="Insert"/>
-        </td>
-        <td colspan="2"><a href="update?action=Cancel">Cancel</a>
-        </td>
-       </tr>
-      </xsl:if>
-      </table>
-      <input type="submit" name="action" value="Edit"/>
-    </form>
-   </body>
-  </html>
- </xsl:template>
- <xsl:template match="band">
-   <tr>
-     <xsl:variable name="band" select="band"/>
-     <xsl:variable name="band_id" select="band_id"/>
-     <xsl:choose>
-      <xsl:when test="$action='Select'">
-       <xsl:choose>
-        <xsl:when test="$bands.band_id=$band_id">
-         <td>
-          <xsl:value-of select="$band_id"/></td>
-         <td><input type="text" name="bands.band" value="{$band}"/>
-             <input type="hidden" name="bands.band_id" value="{$band_id}"/>
-         </td>
-         <td><a href="javascript:document.f.submit()">Update</a></td>
-         <td><a href="update?action=Cancel">Cancel</a>
-             <input type="hidden" name="action" value="Update"/>
-         </td>
-        </xsl:when>
-        <xsl:otherwise>
-         <td><xsl:value-of select="$band_id"/></td>
-         <td><xsl:value-of select="$band"/></td>
-         <td><a href="update?action=Delete&amp;bands.band_id={$band_id}">Delete</a></td>
-         <td><a href="update?action=Select&amp;bands.band_id={$band_id}">Select</a></td>
-        </xsl:otherwise>
-       </xsl:choose>
-      </xsl:when>
-      <xsl:otherwise>
-       <td>
-        <xsl:value-of select="$band_id"/>
-       </td>
-       <td><xsl:value-of select="$band"/></td>
-         <td><a href="update?action=Delete&amp;bands.band_id={$band_id}">Delete</a></td>
-         <td><a href="update?action=Select&amp;bands.band_id={$band_id}">Select</a></td>
-      </xsl:otherwise>
-    </xsl:choose>
-   </tr>
- </xsl:template>
-</xsl:stylesheet>
+{{{
+<?xml version="1.0"?>
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                               xmlns:esql="http://apache.org/cocoon/SQL/v2">
+ <xsl:param name="action"/>
+ <xsl:param name="bands.band_id"/>
+ <xsl:param name="bands.band"/>
+ <xsl:template match="bands">
+  <html>
+   <body>
+    <h1>Bands</h1>
+    <form name="f" action="update" method="get"> 
+     <table border="1">
+      <xsl:apply-templates/>
+      <xsl:if test="$action='Edit'">
+       <tr>
+        <td>#</td>
+        <td><input type="text" name="bands.band" value=""/></td> 
+        <td><a href="javascript:document.f.submit()">Insert</a>
+            <input type="hidden" name="action" value="Insert"/>
+        </td>
+        <td colspan="2"><a href="update?action=Cancel">Cancel</a>
+        </td>
+       </tr>
+      </xsl:if>
+      </table>
+      <input type="submit" name="action" value="Edit"/>
+    </form>
+   </body>
+  </html>
+ </xsl:template>
+ <xsl:template match="band">
+   <tr>
+     <xsl:variable name="band" select="band"/>
+     <xsl:variable name="band_id" select="band_id"/>
+     <xsl:choose>
+      <xsl:when test="$action='Select'">
+       <xsl:choose>
+        <xsl:when test="$bands.band_id=$band_id">
+         <td>
+          <xsl:value-of select="$band_id"/></td>
+         <td><input type="text" name="bands.band" value="{$band}"/>
+             <input type="hidden" name="bands.band_id" value="{$band_id}"/>
+         </td>
+         <td><a href="javascript:document.f.submit()">Update</a></td>
+         <td><a href="update?action=Cancel">Cancel</a>
+             <input type="hidden" name="action" value="Update"/>
+         </td>
+        </xsl:when>
+        <xsl:otherwise>
+         <td><xsl:value-of select="$band_id"/></td>
+         <td><xsl:value-of select="$band"/></td>
+         <td><a href="update?action=Delete&amp;bands.band_id={$band_id}">Delete</a></td>
+         <td><a href="update?action=Select&amp;bands.band_id={$band_id}">Select</a></td>
+        </xsl:otherwise>
+       </xsl:choose>
+      </xsl:when>
+      <xsl:otherwise>
+       <td>
+        <xsl:value-of select="$band_id"/>
+       </td>
+       <td><xsl:value-of select="$band"/></td>
+         <td><a href="update?action=Delete&amp;bands.band_id={$band_id}">Delete</a></td>
+         <td><a href="update?action=Select&amp;bands.band_id={$band_id}">Select</a></td>
+      </xsl:otherwise>
+    </xsl:choose>
+   </tr>
+ </xsl:template>
+</xsl:stylesheet>
 }}}
 [[BR]]
 ===  2. The Configuration ===
@@ -634,21 +634,21 @@
 [[BR]]
 [[BR]]
 ''insert.xml''
-{{{
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<bands>
- <connection>kaffee</connection>
- <table name="bands">
-  <keys>
-   <key name="band_id" type="int" autoincrement="true">
-    <mode name="mysql" type="autoincr"/>
-   </key>
-  </keys>
-  <values>
-   <value name="band" type="string"/>
-  </values>
- </table>
-</bands>
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<bands>
+ <connection>kaffee</connection>
+ <table name="bands">
+  <keys>
+   <key name="band_id" type="int" autoincrement="true">
+    <mode name="mysql" type="autoincr"/>
+   </key>
+  </keys>
+  <values>
+   <value name="band" type="string"/>
+  </values>
+ </table>
+</bands>
 }}} 
 [[BR]]
 The update configuration is similar to the above update example. This time
@@ -656,27 +656,27 @@
 [[BR]]
 [[BR]]
 ''update.xml''
-{{{
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<bands>
- <connection>kaffee</connection>
- <table name="bands">
-  <keys>
-   <key name="band_id" type="int">
-    <mode name="request-param" type="request">
-     <parameter>bands.band_id</parameter>
-    </mode>
-   </key>
-  </keys>
-  <values>
-   <value name="band" type="string">
-    <mode name="request-param" type="request">
-     <parameter>bands.band</parameter>
-    </mode>
-   </value>
-  </values>
- </table>
-</bands>
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<bands>
+ <connection>kaffee</connection>
+ <table name="bands">
+  <keys>
+   <key name="band_id" type="int">
+    <mode name="request-param" type="request">
+     <parameter>bands.band_id</parameter>
+    </mode>
+   </key>
+  </keys>
+  <values>
+   <value name="band" type="string">
+    <mode name="request-param" type="request">
+     <parameter>bands.band</parameter>
+    </mode>
+   </value>
+  </values>
+ </table>
+</bands>
 }}} 
 [[BR]]
 The delete configuration uses the band.band_id param to determine the primary key value of
the 
@@ -684,20 +684,20 @@
 [[BR]]
 [[BR]]
 ''delete.xml''
-{{{
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<bands>
- <connection>kaffee</connection>
- <table name="bands">
-  <keys>
-   <key name="band_id" type="int">
-    <mode name="request-param" type="request">
-     <parameter>bands.band_id</parameter>
-    </mode>
-   </key>
-  </keys>
- </table>
-</bands>  
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<bands>
+ <connection>kaffee</connection>
+ <table name="bands">
+  <keys>
+   <key name="band_id" type="int">
+    <mode name="request-param" type="request">
+     <parameter>bands.band_id</parameter>
+    </mode>
+   </key>
+  </keys>
+ </table>
+</bands>  
 }}}
 [[BR]]
 The database action are wrapped in a request action to control the user selection. Depending
on 
@@ -707,47 +707,47 @@
 [[BR]]
 [[BR]]
 ''sitemap.xmap''
-{{{
-<map:match pattern="update"> 
-  <map:act type="request">
-   <map:parameter name="parameters" value="true"/> 
-   <map:select type="parameter"> 
-    <map:parameter name="parameter-selector-test" value="{action}"/>
-     <map:when test="Update">
-      <map:act type="mod-db-upd">
-        <map:generate type="serverpages" src="xsp/bands.xsp"/>
-        <map:transform type="xslt" src="xsl/bands.xsl">
-         <map:parameter name="use-request-parameters" value="true"/>
-        </map:transform>
-       <map:serialize type="html"/>
-      </map:act>
-     </map:when>
-     <map:when test="Delete">
-      <map:act type="mod-db-del">
-       <map:generate type="serverpages" src="xsp/bands.xsp"/>
-       <map:transform type="xslt" src="xsl/bands.xsl">
-        <map:parameter name="use-request-parameters" value="true"/>
-       </map:transform>
-       <map:serialize type="html"/>
-      </map:act>
-     </map:when>
-     <map:when test="Insert">
-      <map:act type="mod-db-add">
-       <map:generate type="serverpages" src="xsp/bands.xsp"/>
-       <map:transform type="xslt" src="xsl/bands.xsl">
-        <map:parameter name="use-request-parameters" value="true"/>
-       </map:transform>
-       <map:serialize type="html"/>
-      </map:act>
-     </map:when>
-   </map:select>
-  </map:act>
-   <map:generate type="serverpages" src="xsp/bands.xsp"/>
-    <map:transform type="xslt" src="xsl/bands.xsl">
-     <map:parameter name="use-request-parameters" value="true"/>
-    </map:transform>
-   <map:serialize type="html"/>
-  </map:match>
+{{{
+<map:match pattern="update"> 
+  <map:act type="request">
+   <map:parameter name="parameters" value="true"/> 
+   <map:select type="parameter"> 
+    <map:parameter name="parameter-selector-test" value="{action}"/>
+     <map:when test="Update">
+      <map:act type="mod-db-upd">
+        <map:generate type="serverpages" src="xsp/bands.xsp"/>
+        <map:transform type="xslt" src="xsl/bands.xsl">
+         <map:parameter name="use-request-parameters" value="true"/>
+        </map:transform>
+       <map:serialize type="html"/>
+      </map:act>
+     </map:when>
+     <map:when test="Delete">
+      <map:act type="mod-db-del">
+       <map:generate type="serverpages" src="xsp/bands.xsp"/>
+       <map:transform type="xslt" src="xsl/bands.xsl">
+        <map:parameter name="use-request-parameters" value="true"/>
+       </map:transform>
+       <map:serialize type="html"/>
+      </map:act>
+     </map:when>
+     <map:when test="Insert">
+      <map:act type="mod-db-add">
+       <map:generate type="serverpages" src="xsp/bands.xsp"/>
+       <map:transform type="xslt" src="xsl/bands.xsl">
+        <map:parameter name="use-request-parameters" value="true"/>
+       </map:transform>
+       <map:serialize type="html"/>
+      </map:act>
+     </map:when>
+   </map:select>
+  </map:act>
+   <map:generate type="serverpages" src="xsp/bands.xsp"/>
+    <map:transform type="xslt" src="xsl/bands.xsl">
+     <map:parameter name="use-request-parameters" value="true"/>
+    </map:transform>
+   <map:serialize type="html"/>
+  </map:match>
 }}}
 [[BR]]
 [[BR]]

Mime
View raw message