Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 59723 invoked from network); 16 Sep 2003 02:42:55 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 16 Sep 2003 02:42:55 -0000 Received: (qmail 96742 invoked by uid 500); 16 Sep 2003 02:42:23 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 96710 invoked by uid 500); 16 Sep 2003 02:42:22 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 96695 invoked from network); 16 Sep 2003 02:42:22 -0000 Received: from unknown (HELO ms-smtp-03.nyroc.rr.com) (24.92.226.153) by daedalus.apache.org with SMTP; 16 Sep 2003 02:42:22 -0000 Received: from dotech.com (roc-66-67-139-126.rochester.rr.com [66.67.139.126]) by ms-smtp-03.nyroc.rr.com (8.12.5/8.12.2) with ESMTP id h8G2gUcT023273 for ; Mon, 15 Sep 2003 22:42:30 -0400 (EDT) Message-ID: <3F66786B.1000009@dotech.com> Date: Mon, 15 Sep 2003 22:41:47 -0400 From: David Kavanagh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: SQLTransformer not committing Inserts References: <65DB394748BED211AA6700A0C9EC283203CF5B3F@aspcbr-mail1.cbr.aspect.com.au> In-Reply-To: <65DB394748BED211AA6700A0C9EC283203CF5B3F@aspcbr-mail1.cbr.aspect.com.au> Content-Type: multipart/mixed; boundary="------------090108040107080000090400" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --------------090108040107080000090400 Content-Type: multipart/alternative; boundary="------------010400070203060900080608" --------------010400070203060900080608 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit This is because when you end a pipeline with the map:redirect, nothing else gets executed. The redirect happens when the pipeline is setup. We've had need for similar pipelines where processing is done, then a redirect is performed. We wrote a redirect transformer that we'd be glad to contribute. It takes a url in XML or as a sitemap parameter. Instead of doing a redirect during setup, it does it when endDocument is called. David PS. coding credits to Daniel McOrmond of D.O.Tech Dean Cording wrote: > I am having some problems with SQLTransformer not commiting inserts > into a database. I am running Cocoon 2.1 and MS SQLServer. > > My pipeline looks like: > > > > > > value="true"/> > > > type="sql"> > value="{global:db-connection}"/> > value="true"/> > > > > > uri="CodeTableList"/> > > > > And CodeAddTest.xsl looks like: > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > xmlns:sql="http://apache.org/cocoon/SQL/2.0"> > > > > > > > > > INSERT INTO Codes (CodeType, CodeValue) > VALUES ('', > '') > > > > > > > > > The values to be inserted are generated from a form and passed in as > request parameters. At the end of the pipeline it redirects to a list > page that shows all of the values in the database. The problem is > that the new values aren't being inserted. If I remove the redirect > (and replace it with a static page for example) then the insert works > fine. > > > Any ideas? > > > Thanks, > > Dean --------------010400070203060900080608 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit This is because when you end a pipeline with the map:redirect, nothing else gets executed. The redirect happens when the pipeline is setup. We've had need for similar pipelines where processing is done, then a redirect is performed. We wrote a redirect transformer that we'd be glad to contribute. It takes a url in XML or as a sitemap parameter. Instead of doing a redirect during setup, it does it when endDocument is called.

David

PS. coding credits to Daniel McOrmond of D.O.Tech

Dean Cording wrote:
I am having some problems with SQLTransformer not commiting inserts into a database.  I am running Cocoon 2.1 and MS SQLServer.
 
My pipeline looks like:
 
               <map:match pattern="CodeCreate-add">
                    <map:generate type="request"/>
                    
                    <map:transform type="xslt" src="CodeAddTest.xsl">
                        <map:parameter name="use-request-parameters" value="true"/>
                    </map:transform>
                   
                    <map:transform type="sql">                              
                        <map:parameter name="use-connection" value="{global:db-connection}"/>
                        <map:parameter name="show-nr-of-rows" value="true"/>
                        <map:parameter name="isupdate" value="true"/>
                    </map:transform>
                   
                    <!-- Redirect back to the table display page -->
                    <map:redirect-to uri="CodeTableList"/>                    
                </map:match>
 
 
And CodeAddTest.xsl looks like:
 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:sql="http://apache.org/cocoon/SQL/2.0">
    <xsl:param name="CodeType"/>
    <xsl:param name="CodeValue"/>
   
    <xsl:template match="/">
                         
    <page>
        <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
            <query> 
                INSERT INTO Codes (CodeType, CodeValue)
                VALUES ('<xsl:value-of select="$CodeType"/>', '<xsl:value-of select="$CodeValue"/>')
            </query>
        </execute-query>
    </page> 
   
    </xsl:template>
   
</xsl:stylesheet>
 
The values to be inserted are generated from a form and passed in as request parameters.  At the end of the pipeline it redirects to a list page that shows all of the values in the database.  The problem is that the new values aren't being inserted.  If I remove the redirect (and replace it with a static page for example) then the insert works fine.
 
 
Any ideas?
 
 
Thanks,
 
Dean
--------------010400070203060900080608-- --------------090108040107080000090400 Content-Type: text/plain; name="RedirectTransformer.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="RedirectTransformer.java" package com.dotech.cocoon.transformation; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.parameters.ParameterException; import org.apache.cocoon.environment.http.HttpResponse; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.transformation.AbstractSAXTransformer; import org.apache.cocoon.ProcessingException; import org.xml.sax.SAXException; import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributesImpl; import java.io.IOException; import java.util.Map; /** * The Redirect Transformer * * redirects the user to another url. You can specify the new url within an xml file * and it can also be specified as a transformer parameter in the sitemap. A redirect url * specified in the xml takes higher precendence than a redirect url specified in the sitemap. * *

* XML Example: *
 * <redirect xmlns="http://dotech.com/redirect/1.0">http://www.dotech.com</redirect>
 * 
* * The url can be either fully qualified or relative. *

* Sitemap Example: *
 * <map:transformer type="redirect">
 * <map:parameter name="redirectURL" value="http://www.dotech.com"/>
 * </map:transformer>
 * 
* * If an url is not specified in either place, this transformer acts as if it didn't exist. The * sitemap execution passes on to the next component. * * @author Daniel McOrmond * @version $Revision: 1.2 $ $Date: 2003/07/22 02:41:34 $ */ public class RedirectTransformer extends AbstractSAXTransformer { public static final String NAMESPACE = "http://dotech.com/redirect/1.0"; private String redirectLocation; public RedirectTransformer() { this.namespaceURI = NAMESPACE; } public void setupTransforming() throws IOException, ProcessingException, SAXException { super.setupTransforming(); redirectLocation = parameters.getParameter("redirectURL", ""); getLogger().debug("redirect URL set from param : "+redirectLocation); } public void endDocument() throws SAXException { if (redirectLocation != null && !redirectLocation.trim().equals("")) { HttpResponse hr = (HttpResponse)response; try { getLogger().debug("about to set redirect on response object : "+redirectLocation); hr.sendRedirect( redirectLocation ); } catch( Exception e ) { getLogger().error( "some error", e ); } response = hr; } } public void startTransformingElement(String uri, String name, String raw, Attributes attr) throws ProcessingException, IOException, SAXException { if( name.toLowerCase().equals("redirect") ) { startTextRecording(); } } public void endTransformingElement(String uri, String name, String raw) throws ProcessingException, IOException, SAXException { if( name.toLowerCase().equals("redirect") ) { redirectLocation = endTextRecording(); getLogger().debug("redirect URL set from xml : "+redirectLocation); } } } //RedirectTransformer --------------090108040107080000090400 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org --------------090108040107080000090400--