You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Oleg Konovalov <ol...@yahoo.com> on 2006/03/27 15:26:12 UTC
Handling SQL Transformer exceptions
Hi,
I am trying to fix the bug in the Cocoon 2.0 application:
- it is not handling exceptions from SQLTransformer in the GUI,
need to show user an error that Insert failed.
Here is an exception we often get:
ERROR (2006-03-24) 15:29.31:855 [sitemap.transformer.sql] (/myapp) Thread-11/SQLTransformer$Query: Caught a SQLException
java.sql.SQLException: ORA-00001: unique constraint (MBRDEV.UKC_ASSOC_COT) violated
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
Here is a simplified version of my XSL:
<xsl:template match="/">
<page>
<title><xsl:value-of select='$table'/><xsl:text> modification</xsl:text></title>
<content>
<xsl:apply-templates/>
</content>
</page>
</xsl:template>
<xsl:template name='doInsert'>
<xsl:param name='row'/>
<xsl:param name='table'/>
<sql:execute-query>
<sql:query>
<xsl:text>insert into </xsl:text>
<xsl:value-of select='$table'/>
.........
</sql:query>
</sql:execute-query>
<!-- This is the code I added to handle that exception which is supposed to show it to the user -->
<xsl:if test="count(//sql:error[1]) > 0">
<xsl:call-template name='buildErrorMessage'>
<xsl:with-param name='row' select='.'/>
<xsl:with-param name='message'><xsl:text>ERROR: Can not insert the row into the database (not recorded)</xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
....
Am I doing it right and in correct place ("This is the code...") ?
For some reason it doesn't seem to work (maybe that condition is false: "count(//sql:error[1]) > 0" ?)
Sorry for the newbie question. Any help is very appreciated.
Thank you in advance,
Oleg.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Handling SQL Transformer exceptions
Posted by Wa...@westsussex.gov.uk.
Yikes,
I don't use Actions and prefer custom transformers so that the 'pipeline'
model remains relatively straightforward. Consequently, I was assuming
this was a part of a matcher pipeline e.g.
<map:match pattern="query">
<map:generate src="xml/icmap_upload_config.xml"/>
<map:transform src="xml/icmap/convert-icmap.xsl">
<map:parameter name="id" value="id"/>
<map:parameter name="table" value="table"/>
</map:transform>
<map:transform type="sql">
<map:parameter name="use-connection" value="mbrdb"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
Clearly, you have the support job from hell! And it is looking that your
difficulties are beyond the scope of this mailing list. Are you in the UK?
Try producing a test matecer as above and this might get you into the
system such that you have a fighting chance of maintaining it.
Good Luck
Warrell Harries | IT Services, West Sussex County Council | Location:
Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com>
31/03/2006 15:38
Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org
cc
Subject
Re: Handling SQL Transformer exceptions
Warrell/Askild,
No, I don't get anything in the IE browser (it gives me the same screen
with no errors),
regular HTML in the View Source.
Here is a whole act block:
</map:act>
<map:aggregate element="root">
<map:part src="xml/icmap_upload_config.xml"
element="upload"/>
</map:aggregate>
<map:transform type="hssf"/>
<map:transform src="xslt/icmap/convert-icmap.xsl">
<!-- that is where Insert in giving me SQL Exception -->
<map:parameter name="current_user_id"
value="{../userid}"/>
<map:parameter name="table"
value="industry_code_map_table"/>
</map:transform>
<map:transform type="sql">
<map:parameter name="use-connection"
value="mbrdb"/>
</map:transform>
<map:serialize type="xml"/> <!-- for debug
-->
<map:transform
src="xslt/icmap/sql_error_check.xsl" label="debug1"/> <!-- added
SQLException check -->
<!--map:serialize type="xml"/--> <!-- for debug
-->
<map:transform src="xslt/icmap/icmap_admin.xsl"/>
<map:serialize type="html"/>
</map:act>
It is a part of another act.
Also, if I do in the browser:
http://localhost/membership/icmap/sql_error_check?debug1 , getting:
The requested URI "/membership/icmap/sql_error_check" was not found.
although both my new sql_error_check.xsl and convert-icmap.xsl are in the
same directory (membership/xslt/icmap).
Don't understand why I get this error.
Where:
<map:view from-label="debug1" name="debug1">
<map:serialize type="xml"/>
Could you please answer my question regarding Template name from my last
e-mail.
Thank you in advance,
Oleg.
----- Original Message ----
From: Warrell.Harries@westsussex.gov.uk
To: users@cocoon.apache.org
Sent: Friday, March 31, 2006 3:52:14 AM
Subject: Re: Handling SQL Transformer exceptions
Hi Oleg,
>>>>>>>>>>>I tried putting I tried putting <map:serialize type="xml"/>
between SQLTransformer and my SQL checking file - Didn't get anything.
between SQLTransformer and my SQL checking file - Didn't get anything.
In your sitemap pipeline you should try just having three stages :-
1) Set up your sql as the generator,
2) Transform using the SQLTransformer
3) terminate the pipeline with <map:serialize type="xml"/>
If you don't see anything (make sure you use the browser view source) then
something more fundamental is amiss,
Cheers
Warrell Harries | IT Services, West Sussex County Council | Location:
Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com>
31/03/2006 05:51
Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org
cc
Subject
Re: Handling SQL Transformer exceptions
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 <ol...@yahoo.com>
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="xslt/icmap/sql_error_check.xsl" 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: Warrell.Harries@westsussex.gov.uk
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: warrell.harries@westsussex.gov.uk
Askild Aaberg Olsen <as...@xangeli.com>
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
--
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.
--
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.
Re: Handling SQL Transformer exceptions
Posted by Oleg Konovalov <ol...@yahoo.com>.
Warrell/Askild,
No, I don't get anything in the IE browser (it gives me the same screen with no errors),
regular HTML in the View Source.
Here is a whole act block:
</map:act>
<map:aggregate element="root">
<map:part src="xml/icmap_upload_config.xml" element="upload"/>
</map:aggregate>
<map:transform type="hssf"/>
<map:transform src="xslt/icmap/convert-icmap.xsl"> <!-- that is where Insert in giving me SQL Exception -->
<map:parameter name="current_user_id" value="{../userid}"/>
<map:parameter name="table" value="industry_code_map_table"/>
</map:transform>
<map:transform type="sql">
<map:parameter name="use-connection" value="mbrdb"/>
</map:transform>
<map:serialize type="xml"/> <!-- for debug -->
<map:transform src="xslt/icmap/sql_error_check.xsl" label="debug1"/> <!-- added SQLException check -->
<!--map:serialize type="xml"/--> <!-- for debug -->
<map:transform src="xslt/icmap/icmap_admin.xsl"/>
<map:serialize type="html"/>
</map:act>
It is a part of another act.
Also, if I do in the browser: http://localhost/membership/icmap/sql_error_check?debug1 , getting:
The requested URI "/membership/icmap/sql_error_check" was not found.
although both my new sql_error_check.xsl and convert-icmap.xsl are in the same directory (membership/xslt/icmap).
Don't understand why I get this error.
Where:
<map:view from-label="debug1" name="debug1">
<map:serialize type="xml"/>
Could you please answer my question regarding Template name from my last e-mail.
Thank you in advance,
Oleg.
----- Original Message ----
From: Warrell.Harries@westsussex.gov.uk
To: users@cocoon.apache.org
Sent: Friday, March 31, 2006 3:52:14 AM
Subject: Re: Handling SQL Transformer exceptions
Hi Oleg,
>>>>>>>>>>>I tried putting I tried putting <map:serialize type="xml"/> between SQLTransformer and my SQL checking file - Didn't get anything. between SQLTransformer and my SQL checking file - Didn't get anything.
In your sitemap pipeline you should try just having three stages :-
1) Set up your sql as the generator,
2) Transform using the SQLTransformer
3) terminate the pipeline with <map:serialize type="xml"/>
If you don't see anything (make sure you use the browser view source) then something more fundamental is amiss,
Cheers
Warrell Harries | IT Services, West Sussex County Council | Location: Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com> 31/03/2006 05:51 Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org cc
Subject
Re: Handling SQL Transformer exceptions
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 <ol...@yahoo.com>
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="xslt/icmap/sql_error_check.xsl" 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: Warrell.Harries@westsussex.gov.uk
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: warrell.harries@westsussex.gov.uk
Askild Aaberg Olsen <as...@xangeli.com> 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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
--
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.
Re: Handling SQL Transformer exceptions
Posted by Wa...@westsussex.gov.uk.
Hi Oleg,
>>>>>>>>>>>I tried putting I tried putting <map:serialize type="xml"/>
between SQLTransformer and my SQL checking file - Didn't get anything.
between SQLTransformer and my SQL checking file - Didn't get anything.
In your sitemap pipeline you should try just having three stages :-
1) Set up your sql as the generator,
2) Transform using the SQLTransformer
3) terminate the pipeline with <map:serialize type="xml"/>
If you don't see anything (make sure you use the browser view source) then
something more fundamental is amiss,
Cheers
Warrell Harries | IT Services, West Sussex County Council | Location:
Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com>
31/03/2006 05:51
Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org
cc
Subject
Re: Handling SQL Transformer exceptions
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 <ol...@yahoo.com>
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="xslt/icmap/sql_error_check.xsl" 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: Warrell.Harries@westsussex.gov.uk
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: warrell.harries@westsussex.gov.uk
Askild Aaberg Olsen <as...@xangeli.com>
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
--
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.
Re: Handling SQL Transformer exceptions
Posted by Oleg Konovalov <ol...@yahoo.com>.
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 <ol...@yahoo.com>
To: users@cocoon.apache.org
Sent: Thursday, March 30, 2006 3:36:26 PM
Subject: Re: Handling SQL Transformer exceptions
<!-- DIV {margin:0px} -->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="xslt/icmap/sql_error_check.xsl" 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: Warrell.Harries@westsussex.gov.uk
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: warrell.harries@westsussex.gov.uk
Askild Aaberg Olsen <as...@xangeli.com> 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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
Re: Handling SQL Transformer exceptions
Posted by Oleg Konovalov <ol...@yahoo.com>.
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="xslt/icmap/sql_error_check.xsl" 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: Warrell.Harries@westsussex.gov.uk
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: warrell.harries@westsussex.gov.uk
Askild Aaberg Olsen <as...@xangeli.com> 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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
Re: Handling SQL Transformer exceptions
Posted by Wa...@westsussex.gov.uk.
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: warrell.harries@westsussex.gov.uk
Askild Aaberg Olsen <as...@xangeli.com>
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
Re: Handling SQL Transformer exceptions
Posted by Askild Aaberg Olsen <as...@xangeli.com>.
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Handling SQL Transformer exceptions
Posted by Oleg Konovalov <ol...@yahoo.com>.
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).
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.
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/>
</content>
</page>
</xsl:template>
<xsl:template match='mainTemplate'>
<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.
----- Original Message ----
From: Warrell.Harries@westsussex.gov.uk
To: users@cocoon.apache.org
Sent: Monday, March 27, 2006 10:19:10 AM
Subject: Re: Handling SQL Transformer exceptions
Hi Oleg,
Thanks for clearing that up. Have you put that error-handling code in the stage of the pipeline that follows the SQL transform? The XML document after your SQLTrnsformer stage will consist of Error elements so you will have to provide templates for them if you want to handle them. That is, if the XSL that outputs the <sql:query> elements is in query.xsl then the error handling should be in process.xsl
<map:transform src="query.xsl"/>
<map:transform type="sql">
<map:parameter name="use-connection" value="db"/>
</map:transform>
<map:transform src="process.xsl"/>
Of course, you will also provide templates for the <sql:row> elements generated when there are no errors!
Hope this helps
Warrell Harries | IT Services, West Sussex County Council | Location: Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com> 27/03/2006 15:59 Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org cc
Subject
Re: Handling SQL Transformer exceptions
Warrell,
>I don't think that you can call this a 'bug in Cocoon'!
I meant, a bug in my app (DB problem is not shown to the user and not handled, just fails to insert and let user guess what happened).
I use Cocoon 2.0.4, not 2.1. Would it mean any difference for handling SQLTransformer exceptions ?
Thank you,
Oleg.
----- Original Message ----
From: Warrell.Harries@westsussex.gov.uk
To: users@cocoon.apache.org
Sent: Monday, March 27, 2006 8:54:35 AM
Subject: Re: Handling SQL Transformer exceptions
Hi Oleg,
I don't think that you can call this a 'bug in Cocoon'! Do you really mean a Cocoon 2.0 version or just generally version 2 of Cocoon?
It seems you are building a generic DB query tool so I suppose the following is not appropriate but I would argue that this is not the desired way to use the SQLTransformer since the overall Application design should prevent any constraints ever being violated. In my view, such Constraints are fundamental rules that are there to define the parameters of the system and not just as a last line of defence or for the creation of indexes. However, to handle such Processing Exceptions in Cocoon you should take a look at :-
http://cocoon.apache.org/2.1/userdocs/concepts/errorhandling.html
if, of course, you are using Cocoon 2.1.
Hope this helps
Warrell Warrell Harries | IT Services, West Sussex County Council | Location: Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com> 27/03/2006 14:26
Please respond to
users@cocoon.apache.org
To
cocoon list <us...@cocoon.apache.org> cc
Subject
Handling SQL Transformer exceptions
Hi,
I am trying to fix the bug in the Cocoon 2.0 application:
- it is not handling exceptions from SQLTransformer in the GUI,
need to show user an error that Insert failed.
Here is an exception we often get:
ERROR (2006-03-24) 15:29.31:855 [sitemap.transformer.sql] (/myapp) Thread-11/SQLTransformer$Query: Caught a SQLException
java.sql.SQLException: ORA-00001: unique constraint (MBRDEV.UKC_ASSOC_COT) violated
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
Here is a simplified version of my XSL:
<xsl:template match="/">
<page>
<title><xsl:value-of select='$table'/><xsl:text> modification</xsl:text></title>
<content>
<xsl:apply-templates/>
</content>
</page>
</xsl:template>
<xsl:template name='doInsert'>
<xsl:param name='row'/>
<xsl:param name='table'/>
<sql:execute-query>
<sql:query>
<xsl:text>insert into </xsl:text>
<xsl:value-of select='$table'/>
.........
</sql:query>
</sql:execute-query>
<!-- This is the code I added to handle that exception which is supposed to show it to the user -->
<xsl:if test="count(//sql:error[1]) > 0">
<xsl:call-template name='buildErrorMessage'>
<xsl:with-param name='row' select='.'/>
<xsl:with-param name='message'><xsl:text>ERROR: Can not insert the row into the database (not recorded)</xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
....
Am I doing it right and in correct place ("This is the code...") ?
For some reason it doesn't seem to work (maybe that condition is false: "count(//sql:error[1]) > 0" ?)
Sorry for the newbie question. Any help is very appreciated.
Thank you in advance,
Oleg.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
--
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.
Re: Handling SQL Transformer exceptions
Posted by Wa...@westsussex.gov.uk.
Hi Oleg,
Thanks for clearing that up. Have you put that error-handling code in the
stage of the pipeline that follows the SQL transform? The XML document
after your SQLTrnsformer stage will consist of Error elements so you will
have to provide templates for them if you want to handle them. That is, if
the XSL that outputs the <sql:query> elements is in query.xsl then the
error handling should be in process.xsl
<map:transform src="query.xsl"/>
<map:transform type="sql">
<map:parameter name="use-connection" value="db"/>
</map:transform>
<map:transform src="process.xsl"/>
Of course, you will also provide templates for the <sql:row> elements
generated when there are no errors!
Hope this helps
Warrell Harries | IT Services, West Sussex County Council | Location:
Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com>
27/03/2006 15:59
Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org
cc
Subject
Re: Handling SQL Transformer exceptions
Warrell,
>I don't think that you can call this a 'bug in Cocoon'!
I meant, a bug in my app (DB problem is not shown to the user and not
handled, just fails to insert and let user guess what happened).
I use Cocoon 2.0.4, not 2.1. Would it mean any difference for handling
SQLTransformer exceptions ?
Thank you,
Oleg.
----- Original Message ----
From: Warrell.Harries@westsussex.gov.uk
To: users@cocoon.apache.org
Sent: Monday, March 27, 2006 8:54:35 AM
Subject: Re: Handling SQL Transformer exceptions
Hi Oleg,
I don't think that you can call this a 'bug in Cocoon'! Do you really mean
a Cocoon 2.0 version or just generally version 2 of Cocoon?
It seems you are building a generic DB query tool so I suppose the
following is not appropriate but I would argue that this is not the
desired way to use the SQLTransformer since the overall Application design
should prevent any constraints ever being violated. In my view, such
Constraints are fundamental rules that are there to define the parameters
of the system and not just as a last line of defence or for the creation
of indexes. However, to handle such Processing Exceptions in Cocoon you
should take a look at :-
http://cocoon.apache.org/2.1/userdocs/concepts/errorhandling.html
if, of course, you are using Cocoon 2.1.
Hope this helps
Warrell
Warrell Harries | IT Services, West Sussex County Council | Location:
Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com>
27/03/2006 14:26
Please respond to
users@cocoon.apache.org
To
cocoon list <us...@cocoon.apache.org>
cc
Subject
Handling SQL Transformer exceptions
Hi,
I am trying to fix the bug in the Cocoon 2.0 application:
- it is not handling exceptions from SQLTransformer in the GUI,
need to show user an error that Insert failed.
Here is an exception we often get:
ERROR (2006-03-24) 15:29.31:855 [sitemap.transformer.sql] (/myapp)
Thread-11/SQLTransformer$Query: Caught a SQLException
java.sql.SQLException: ORA-00001: unique constraint (MBRDEV.UKC_ASSOC_COT)
violated
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
Here is a simplified version of my XSL:
<xsl:template match="/">
<page>
<title><xsl:value-of select='$table'/><xsl:text>
modification</xsl:text></title>
<content>
<xsl:apply-templates/>
</content>
</page>
</xsl:template>
<xsl:template name='doInsert'>
<xsl:param name='row'/>
<xsl:param name='table'/>
<sql:execute-query>
<sql:query>
<xsl:text>insert into </xsl:text>
<xsl:value-of select='$table'/>
.........
</sql:query>
</sql:execute-query>
<!-- This is the code I added to handle that exception which is
supposed to show it to the user -->
<xsl:if test="count(//sql:error[1]) > 0">
<xsl:call-template name='buildErrorMessage'>
<xsl:with-param name='row' select='.'/>
<xsl:with-param name='message'><xsl:text>ERROR: Can not insert
the row into the database (not recorded)</xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
....
Am I doing it right and in correct place ("This is the code...") ?
For some reason it doesn't seem to work (maybe that condition is false:
"count(//sql:error[1]) > 0" ?)
Sorry for the newbie question. Any help is very appreciated.
Thank you in advance,
Oleg.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
--
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.
Re: Handling SQL Transformer exceptions
Posted by Oleg Konovalov <ol...@yahoo.com>.
Warrell,
>I don't think that you can call this a 'bug in Cocoon'!
I meant, a bug in my app (DB problem is not shown to the user and not handled, just fails to insert and let user guess what happened).
I use Cocoon 2.0.4, not 2.1. Would it mean any difference for handling SQLTransformer exceptions ?
Thank you,
Oleg.
----- Original Message ----
From: Warrell.Harries@westsussex.gov.uk
To: users@cocoon.apache.org
Sent: Monday, March 27, 2006 8:54:35 AM
Subject: Re: Handling SQL Transformer exceptions
Hi Oleg,
I don't think that you can call this a 'bug in Cocoon'! Do you really mean a Cocoon 2.0 version or just generally version 2 of Cocoon?
It seems you are building a generic DB query tool so I suppose the following is not appropriate but I would argue that this is not the desired way to use the SQLTransformer since the overall Application design should prevent any constraints ever being violated. In my view, such Constraints are fundamental rules that are there to define the parameters of the system and not just as a last line of defence or for the creation of indexes. However, to handle such Processing Exceptions in Cocoon you should take a look at :-
http://cocoon.apache.org/2.1/userdocs/concepts/errorhandling.html
if, of course, you are using Cocoon 2.1.
Hope this helps
Warrell
Warrell Harries | IT Services, West Sussex County Council | Location: Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com> 27/03/2006 14:26 Please respond to
users@cocoon.apache.org
To
cocoon list <us...@cocoon.apache.org> cc
Subject
Handling SQL Transformer exceptions
Hi,
I am trying to fix the bug in the Cocoon 2.0 application:
- it is not handling exceptions from SQLTransformer in the GUI,
need to show user an error that Insert failed.
Here is an exception we often get:
ERROR (2006-03-24) 15:29.31:855 [sitemap.transformer.sql] (/myapp) Thread-11/SQLTransformer$Query: Caught a SQLException
java.sql.SQLException: ORA-00001: unique constraint (MBRDEV.UKC_ASSOC_COT) violated
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
Here is a simplified version of my XSL:
<xsl:template match="/">
<page>
<title><xsl:value-of select='$table'/><xsl:text> modification</xsl:text></title>
<content>
<xsl:apply-templates/>
</content>
</page>
</xsl:template>
<xsl:template name='doInsert'>
<xsl:param name='row'/>
<xsl:param name='table'/>
<sql:execute-query>
<sql:query>
<xsl:text>insert into </xsl:text>
<xsl:value-of select='$table'/>
.........
</sql:query>
</sql:execute-query>
<!-- This is the code I added to handle that exception which is supposed to show it to the user -->
<xsl:if test="count(//sql:error[1]) > 0">
<xsl:call-template name='buildErrorMessage'>
<xsl:with-param name='row' select='.'/>
<xsl:with-param name='message'><xsl:text>ERROR: Can not insert the row into the database (not recorded)</xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
....
Am I doing it right and in correct place ("This is the code...") ?
For some reason it doesn't seem to work (maybe that condition is false: "count(//sql:error[1]) > 0" ?)
Sorry for the newbie question. Any help is very appreciated.
Thank you in advance,
Oleg.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.
Re: Handling SQL Transformer exceptions
Posted by Wa...@westsussex.gov.uk.
Hi Oleg,
I don't think that you can call this a 'bug in Cocoon'! Do you really mean
a Cocoon 2.0 version or just generally version 2 of Cocoon?
It seems you are building a generic DB query tool so I suppose the
following is not appropriate but I would argue that this is not the
desired way to use the SQLTransformer since the overall Application design
should prevent any constraints ever being violated. In my view, such
Constraints are fundamental rules that are there to define the parameters
of the system and not just as a last line of defence or for the creation
of indexes. However, to handle such Processing Exceptions in Cocoon you
should take a look at :-
http://cocoon.apache.org/2.1/userdocs/concepts/errorhandling.html
if, of course, you are using Cocoon 2.1.
Hope this helps
Warrell
Warrell Harries | IT Services, West Sussex County Council | Location:
Northleigh House
Office: +44 (0) 1243-756837 | Email: warrell.harries@westsussex.gov.uk
Oleg Konovalov <ol...@yahoo.com>
27/03/2006 14:26
Please respond to
users@cocoon.apache.org
To
cocoon list <us...@cocoon.apache.org>
cc
Subject
Handling SQL Transformer exceptions
Hi,
I am trying to fix the bug in the Cocoon 2.0 application:
- it is not handling exceptions from SQLTransformer in the GUI,
need to show user an error that Insert failed.
Here is an exception we often get:
ERROR (2006-03-24) 15:29.31:855 [sitemap.transformer.sql] (/myapp)
Thread-11/SQLTransformer$Query: Caught a SQLException
java.sql.SQLException: ORA-00001: unique constraint (MBRDEV.UKC_ASSOC_COT)
violated
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
Here is a simplified version of my XSL:
<xsl:template match="/">
<page>
<title><xsl:value-of select='$table'/><xsl:text>
modification</xsl:text></title>
<content>
<xsl:apply-templates/>
</content>
</page>
</xsl:template>
<xsl:template name='doInsert'>
<xsl:param name='row'/>
<xsl:param name='table'/>
<sql:execute-query>
<sql:query>
<xsl:text>insert into </xsl:text>
<xsl:value-of select='$table'/>
.........
</sql:query>
</sql:execute-query>
<!-- This is the code I added to handle that exception which is
supposed to show it to the user -->
<xsl:if test="count(//sql:error[1]) > 0">
<xsl:call-template name='buildErrorMessage'>
<xsl:with-param name='row' select='.'/>
<xsl:with-param name='message'><xsl:text>ERROR: Can not insert
the row into the database (not recorded)</xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
....
Am I doing it right and in correct place ("This is the code...") ?
For some reason it doesn't seem to work (maybe that condition is false:
"count(//sql:error[1]) > 0" ?)
Sorry for the newbie question. Any help is very appreciated.
Thank you in advance,
Oleg.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
--
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.