A little correction:
the full path to the error structure I need to populate in case of error is:
/root/upload/page/content/error (/message)

And I have that root template:
  <xsl:template match="/">
     <page>      
         <content>
             <xsl:apply-templates/>
           </content>
     </page>
  </xsl:template>


But the condition to find SQLException in that template is:
<xsl:if test="count(//sql:error[1]) > 0">

So what is a template name I should use, "error"  ? 
 
Thank you,
Oleg.


----- Original Message ----
From: Oleg Konovalov <[EMAIL PROTECTED]>
To: users@cocoon.apache.org
Sent: Thursday, March 30, 2006 3:36:26 PM
Subject: Re: Handling SQL Transformer exceptions

Warrell,

(sorry, was busy with more urgent problems)

No, I don't have mainTemplate XML element, in fact I replaced template name with:
<xsl:template match='sht:Row'>  
Not sure it is right.  What happens if there are SQL Exceptions from SQL Transformer, where do Exceptions go in XML?
which template should be used?.

I tried putting <map:serialize type="xml"/> between SQLTransformer and my SQL checking file - Didn't get anything.

Tried: <map:transform src=""  label="debug1"/> and in URL put ?debug1

Nope, nothing in the browser.

>Then have a look at how the default system stylesheet transforms errors into html. You can find the file at build\ webapp\ stylesheets\ system\ >error2html.xslt
I didn't understand that. I don't have any error2html.xslt.  Please elaborate.

Please help !
 
Thank you in advance,
Oleg.


----- Original Message ----
From: [EMAIL PROTECTED]
To: users@cocoon.apache.org
Sent: Tuesday, March 28, 2006 3:59:48 AM
Subject: Re: Handling SQL Transformer exceptions


As Askild points out you are triggering on an XML element called mainTemplate. If you have not output this from your XSL setup stage prior to the SQLTransform stage you cannot trigger on it.  It might be worth taking some time to 'get your head around' the declarative nature of  XSLT and the way that Cocoon pipelines work.

The best way to do this is have a look at the content of the pipeline at each stage by defining a view. You can pass in a parameter from your URL to make Cocoon halt pipeline processing at any stage and render the pipeline contents back to the browser. This is how most people debug their pipelines and is invaluable during development. If you don't know how to define a view just serialize the output after the SQLTransform as type="xml" and look at the content.

Then have a look at how the default system stylesheet transforms errors into html. You can find the file at build\ webapp\ stylesheets\ system\ error2html.xslt

Hope this helps and you don't abandon Cocoon because it takes a declarative, separation of concerns approach which is orthogonal (at right angles) to the more common imperative one.
Warrell Harries | IT Services, West Sussex County Council | Location: Northleigh House
Office: +44 (0) 1243-756837
| Email: [EMAIL PROTECTED]




Askild Aaberg Olsen <[EMAIL PROTECTED]>

28/03/2006 07:36

Please respond to
users@cocoon.apache.org

To
users@cocoon.apache.org
cc

Subject
Re: Handling SQL Transformer exceptions







Oleg Konovalov wrote:
> Warrell,
>
> So what you are saying is that I can not do SQL exception (or error)
> handling inside that SQL transformer
> and have to do it from outside (and after the transformer itself).
Yes, that's what he says. The stylesheet preparing the SQL have no
knowledge of the actuall call. How could it, since the call has yet to
be made?
> That is a pity, because in the same sql transformer file I have lots
> of column validations
> which call it to show user errors, so it would be very convenient.
>
You can reuse templates in different stylesheets, so it should not be to
much trouble to refactor.
> OK, so here is my new transformer. Please tell me if it looks OK to you.
> Have inserted it right after SQL Trasformer [before presentation screen.]
> Still doesn't work.
> <?xml version='1.0' encoding='UTF-8'?>            <!-- Created to > handle SQLExceptions during DB insert or update -->
> <xsl:stylesheet version='1.0'    
>         xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
>         xmlns:sql="http://apache.org/cocoon/SQL/2.0">
>
> <xsl:output method='xml' indent='yes'/>
>
>
> <xsl:template match="/">
>     <page>      
>         <content>
>             <xsl:apply-templates/>
This says: "Process all element-nodes below root"
>         </content>
>     </page>
> </xsl:template>
>
>
> <xsl:template match='mainTemplate'>
This says: "Match an element node named mainTemplate (<mainTemplate/>)".
Do you have this element in your stream?
>     <xsl:if test="count(//sql:error[1]) > 0">  <!-- Do SQLExceptions > check -->
>         <error>      
>             <message>ERROR: Can not insert/update the record into the
> database (not recorded)</message>          
>         </error>      
>     </xsl:if>
> </xsl:template>
>
> </xsl:stylesheet>
>
>  
> Thank you,
> Oleg.
Hope this helps.

Askild
-

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
This e-mail and any attachments are confidential and intended solely for the persons addressed. If it has come to you in error please reply to advise us but you should not read it, copy it, show it to anyone else nor make any other use of its content.   West Sussex County Council takes steps to ensure e-mails and attachments are virus-free but you should carry out your own checks before opening any attachment.

Reply via email to