You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Simon Hutchinson <si...@misgl.com> on 2003/11/24 12:06:38 UTC

Handling SAX Exceptions in sitemap

Hi,

Does anyone know if it is possible to handle SAX exceptions thrown by a 
transformer using a error handler defined in a sitemap.

Here is a brief test to explain what I am trying to achieve.

<map:pipeline>
  <map:match pattern="test">
	<map:generate src="fragments/test.xml"/>  		   		 
<map:transform src="xsl/testtrans.xsl"/>	       	        	 
<map:serialize type="xml"/>
  </map:match>
  <map:handle-errors>
  	<map:generate src="fragments/error.xml"/>
	<map:serialize/>				
  </map:handle-errors>
</map:pipeline>


If I rename the file "test.xml" to force a filenotfound exception in the 
generator then the pipeline level error handler is correctly invoked.

However if the generator stage succeeds but then a SAX exception occurs
in the transformer my error handler is not invoked and an
"XML Parsing Error: no element found "
is sent to my browser.


It may be that I am approaching this in the wrong way but is there
any way of defining an error handler that will be invoked despite
where in the pipeline the error occurs. ie can transform errors be 
caught in the sitemap.

Any help would be much appreciated.

Thanks

Si


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


Re: Handling SAX Exceptions in sitemap

Posted by Simon Hutchinson <si...@misgl.com>.
Joerg Heinicke wrote:
> On 24.11.2003 12:06, Simon Hutchinson wrote:
> 
>> Hi,
>>
>> Does anyone know if it is possible to handle SAX exceptions thrown by 
>> a transformer using a error handler defined in a sitemap.
> 
> 
> Yes.
> 
>> Here is a brief test to explain what I am trying to achieve.
>>
>> <map:pipeline>
>>  <map:match pattern="test">
>>     <map:generate src="fragments/test.xml"/>                      
>> <map:transform src="xsl/testtrans.xsl"/>                            
>> <map:serialize type="xml"/>
>>  </map:match>
>>  <map:handle-errors>
>>      <map:generate src="fragments/error.xml"/>
>>     <map:serialize/>                </map:handle-errors>
>> </map:pipeline>
>>
>>
>> If I rename the file "test.xml" to force a filenotfound exception in 
>> the generator then the pipeline level error handler is correctly invoked.
>>
>> However if the generator stage succeeds but then a SAX exception occurs
>> in the transformer my error handler is not invoked and an
>> "XML Parsing Error: no element found "
>> is sent to my browser.
> 
> 
> Really sound like a problem with the file. Can you open it with a 
> browser understanding XML as Mozilla, NS 6/7 or IE 5/6?
> 
>> It may be that I am approaching this in the wrong way but is there
>> any way of defining an error handler that will be invoked despite
>> where in the pipeline the error occurs. ie can transform errors be 
>> caught in the sitemap.
>>
>> Any help would be much appreciated.
> 
> 
> http://cocoon.apache.org/2.1/userdocs/concepts/errorhandling.html
> 
> Joerg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
Thanks for the reply Joerg

It was actually my mistake.
What I thought was a SAX parsing exception was actually Mozilla failing 
to parse badly formed xml.
No exception was being thrown therefore the handler was never initiated.
I have re-wrtten my transformer to rectify the issue.

Thanks again for the assistance all


Si





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


Re: Handling SAX Exceptions in sitemap

Posted by Joerg Heinicke <jh...@virbus.de>.
On 24.11.2003 12:06, Simon Hutchinson wrote:
> Hi,
> 
> Does anyone know if it is possible to handle SAX exceptions thrown by a 
> transformer using a error handler defined in a sitemap.

Yes.

> Here is a brief test to explain what I am trying to achieve.
> 
> <map:pipeline>
>  <map:match pattern="test">
>     <map:generate src="fragments/test.xml"/>                      
> <map:transform src="xsl/testtrans.xsl"/>                            
> <map:serialize type="xml"/>
>  </map:match>
>  <map:handle-errors>
>      <map:generate src="fragments/error.xml"/>
>     <map:serialize/>               
>  </map:handle-errors>
> </map:pipeline>
> 
> 
> If I rename the file "test.xml" to force a filenotfound exception in the 
> generator then the pipeline level error handler is correctly invoked.
> 
> However if the generator stage succeeds but then a SAX exception occurs
> in the transformer my error handler is not invoked and an
> "XML Parsing Error: no element found "
> is sent to my browser.

Really sound like a problem with the file. Can you open it with a 
browser understanding XML as Mozilla, NS 6/7 or IE 5/6?

> It may be that I am approaching this in the wrong way but is there
> any way of defining an error handler that will be invoked despite
> where in the pipeline the error occurs. ie can transform errors be 
> caught in the sitemap.
> 
> Any help would be much appreciated.

http://cocoon.apache.org/2.1/userdocs/concepts/errorhandling.html

Joerg


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


Re: Handling SAX Exceptions in sitemap

Posted by Simon Hutchinson <si...@misgl.com>.
Lionel Crine wrote:
> hi,
> 
> If you're using the common xslt transformer, you should look at the source.
> If the methods don't throw any exception, so you can't catch the 
> exception with the handle-errors.
> If you're using Cocoon 2.1, you can customize the exception.Search the 
> archive.
> 
> Lionel
> 
> 
> At 11:06 24/11/2003 +0000, you wrote:
> 
>> Hi,
>>
>> Does anyone know if it is possible to handle SAX exceptions thrown by 
>> a transformer using a error handler defined in a sitemap.
>>
>> Here is a brief test to explain what I am trying to achieve.
>>
>> <map:pipeline>
>>  <map:match pattern="test">
>>         <map:generate 
>> src="fragments/test.xml"/>                                
>> <map:transform 
>> src="xsl/testtrans.xsl"/>                                
>> <map:serialize type="xml"/>
>>  </map:match>
>>  <map:handle-errors>
>>         <map:generate src="fragments/error.xml"/>
>>         <map:serialize/>
>>  </map:handle-errors>
>> </map:pipeline>
>>
>>
>> If I rename the file "test.xml" to force a filenotfound exception in 
>> the generator then the pipeline level error handler is correctly invoked.
>>
>> However if the generator stage succeeds but then a SAX exception occurs
>> in the transformer my error handler is not invoked and an
>> "XML Parsing Error: no element found "
>> is sent to my browser.
>>
>>
>> It may be that I am approaching this in the wrong way but is there
>> any way of defining an error handler that will be invoked despite
>> where in the pipeline the error occurs. ie can transform errors be 
>> caught in the sitemap.
>>
>> Any help would be much appreciated.
>>
>> Thanks
>>
>> Si
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> Lionel CRINE
> Ingénieur Systèmes documentaires
> Société : 4DConcept
> 22 rue Etienne de Jouy 78353 JOUY EN JOSAS
> Tel : 01.34.58.70.70 Fax : 01.39.58.70.70
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

Thanks for the reply,


I am using cocoon 2.1 could you please be a little more specific about 
what you mean by customising the exception. I have searched the archives
without any real success.



Kind regards




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


Re: Handling SAX Exceptions in sitemap

Posted by Lionel Crine <cr...@4dconcept.fr>.
hi,

If you're using the common xslt transformer, you should look at the source.
If the methods don't throw any exception, so you can't catch the exception 
with the handle-errors.
If you're using Cocoon 2.1, you can customize the exception.Search the archive.

Lionel


At 11:06 24/11/2003 +0000, you wrote:
>Hi,
>
>Does anyone know if it is possible to handle SAX exceptions thrown by a 
>transformer using a error handler defined in a sitemap.
>
>Here is a brief test to explain what I am trying to achieve.
>
><map:pipeline>
>  <map:match pattern="test">
>         <map:generate 
> src="fragments/test.xml"/>                                <map:transform 
> src="xsl/testtrans.xsl"/>                                <map:serialize 
> type="xml"/>
>  </map:match>
>  <map:handle-errors>
>         <map:generate src="fragments/error.xml"/>
>         <map:serialize/>
>  </map:handle-errors>
></map:pipeline>
>
>
>If I rename the file "test.xml" to force a filenotfound exception in the 
>generator then the pipeline level error handler is correctly invoked.
>
>However if the generator stage succeeds but then a SAX exception occurs
>in the transformer my error handler is not invoked and an
>"XML Parsing Error: no element found "
>is sent to my browser.
>
>
>It may be that I am approaching this in the wrong way but is there
>any way of defining an error handler that will be invoked despite
>where in the pipeline the error occurs. ie can transform errors be caught 
>in the sitemap.
>
>Any help would be much appreciated.
>
>Thanks
>
>Si
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org

Lionel CRINE
Ingénieur Systèmes documentaires
Société : 4DConcept
22 rue Etienne de Jouy 78353 JOUY EN JOSAS
Tel : 01.34.58.70.70 Fax : 01.39.58.70.70


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