You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Arnaud Bienvenu <ar...@generasound.com> on 2001/08/08 16:57:13 UTC
esql and UnsupportedEncodingException - patch proposal
With latest CVS Cocoon2, if you specify the encoding attribute within
<esql:get-string> or <esql:get-columns> tags, you have to enclose your tags
inside a try/catch structure because they may throw
java.io.UnsupportedEncodingException.
At the end of this mail you will find a patch to workaround this problem. I
don't know if it's a good or clean job, but it's very useful for me, so I
post it to you.
For example, the tedious
<xsp:logic>
try {
<esql:get-string column="name" encoding="iso-8859-1"/>
} catch (java.io.UnsupportedEncodingException e) {
System.out.prinln("Grumpf");
}
</xsp:logic>
Becomes merely
<esql:get-string column="name" encoding="iso-8859-1"/>
Info : you need to set the encoding so that special characters will be
correctly fetched (i.e. accentuated letters in latin languages)
Index: src/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
===================================================================
RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl,v
retrieving revision 1.5
diff -u -r1.5 xsp.xsl
--- src/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl 2001/07/23 23:33:45 1.5
+++ src/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl 2001/08/08 14:37:14
@@ -37,6 +37,7 @@
import java.io.File;
import java.io.StringReader;
+ import java.io.UnsupportedEncodingException;
//import java.net.*;
import java.util.Date;
import java.util.List;
@@ -98,7 +99,7 @@
/**
* Generate XML data.
*/
- public void generate() throws SAXException {
+ public void generate() throws SAXException, UnsupportedEncodingException {
this.contentHandler.startDocument();
AttributesImpl xspAttr = new AttributesImpl();
--
Arnaud Bienvenu
http://www.generasound.com/
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: esql and UnsupportedEncodingException - patch proposal
Posted by Enke Michael <Mi...@wincor-nixdorf.com>.
Arnaud Bienvenu wrote:
>
> Oops, I found Michael's patch has a drawback : if you apply it and then you
> do not use the encoding attribute (i.e. <esql:get-columns/>), then you have
> an error :
> Exception java.io.UnsupportedEncodingException is never thrown in the body
> of the corresponding try statement.
>
> So finally the solution I posted at the beginning of this thread may be
> better.
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
Yes, thats right, shame on me.
But the solution: Don't catch UnsupportedEncodingException but only
Exception.
Than it is working. Here ones more the patch:
Index:
./src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl
===================================================================
RCS file:
/home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl,v
retrieving revision 1.16
diff -u -r1.16 esql.xsl
---
./src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl
2001/08/06 15:38:57 1.16
+++
./src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl
2001/08/09 15:26:48
@@ -636,6 +636,8 @@
</xsl:otherwise>
</xsl:choose>
} catch (Exception _esql_exception_<xsl:value-of
select="generate-id(.)"/>_2) {}
+ } catch(Exception e) {
+ throw new RuntimeException(e.toString());
}
if (_esql_queries.empty()) {
_esql_query = null;
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: esql and UnsupportedEncodingException - patch proposal
Posted by Arnaud Bienvenu <ar...@generasound.com>.
Oops, I found Michael's patch has a drawback : if you apply it and then you
do not use the encoding attribute (i.e. <esql:get-columns/>), then you have
an error :
Exception java.io.UnsupportedEncodingException is never thrown in the body
of the corresponding try statement.
So finally the solution I posted at the beginning of this thread may be
better.
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: esql and UnsupportedEncodingException - patch proposal
Posted by Arnaud Bienvenu <ar...@generasound.com>.
I applied your patch instead of mine; it is smarter and does the job. Would
some Cocoon Guru apply it to CVS ? What is the procedure to ask for it ?
Don't you like it ?
Here is Michael's patch again (using cocoon's coding style) :
Index: ./src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl
===================================================================
RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl,v
retrieving revision 1.16
diff -u -r1.16 esql.xsl
--- ./src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl 2001/08/06 15:38:57 1.16
+++ ./src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl 2001/08/09 15:26:48
@@ -636,6 +636,8 @@
</xsl:otherwise>
</xsl:choose>
} catch (Exception _esql_exception_<xsl:value-of select="generate-id(.)"/>_2) {}
+ } catch(java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e.toString());
}
if (_esql_queries.empty()) {
_esql_query = null;
--
Arnaud Bienvenu
http://www.generasound.com/
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: esql and UnsupportedEncodingException - patch proposal
Posted by Enke Michael <Mi...@wincor-nixdorf.com>.
Hi,
on tuesday I posted this patch to cocoon-dev,
seems to be equivalent with yours:
================================================================================
Hi,
I'd like to use <esql:get-string column="abc" encoding="UTF-8"/>
but for the encoding we have to catch
java.io.UnsupportedEncodingException
These exception is not catched yet.
Because I have no access to cvs I post the patch as
diff -u esql.xsl.orig esql.xsl
Regards,
Michael
--- esql.xsl.orig Tue Aug 7 16:25:16 2001
+++ esql.xsl Tue Aug 7 16:23:13 2001
@@ -637,6 +637,9 @@
</xsl:choose>
} catch (Exception _esql_exception_<xsl:value-of
select="generate-id(.)"/>_2) {}
}
+ catch(java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e.toString());
+ }
if (_esql_queries.empty()) {
_esql_query = null;
} else {
================================================================================
Arnaud Bienvenu wrote:
>
> With latest CVS Cocoon2, if you specify the encoding attribute within
> <esql:get-string> or <esql:get-columns> tags, you have to enclose your tags
> inside a try/catch structure because they may throw
> java.io.UnsupportedEncodingException.
>
> At the end of this mail you will find a patch to workaround this problem. I
> don't know if it's a good or clean job, but it's very useful for me, so I
> post it to you.
>
> For example, the tedious
> <xsp:logic>
> try {
> <esql:get-string column="name" encoding="iso-8859-1"/>
> } catch (java.io.UnsupportedEncodingException e) {
> System.out.prinln("Grumpf");
> }
> </xsp:logic>
>
> Becomes merely
> <esql:get-string column="name" encoding="iso-8859-1"/>
>
> Info : you need to set the encoding so that special characters will be
> correctly fetched (i.e. accentuated letters in latin languages)
>
> Index: src/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl
> ===================================================================
> RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl,v
> retrieving revision 1.5
> diff -u -r1.5 xsp.xsl
> --- src/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl 2001/07/23 23:33:45 1.5
> +++ src/org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl 2001/08/08 14:37:14
> @@ -37,6 +37,7 @@
>
> import java.io.File;
> import java.io.StringReader;
> + import java.io.UnsupportedEncodingException;
> //import java.net.*;
> import java.util.Date;
> import java.util.List;
> @@ -98,7 +99,7 @@
> /**
> * Generate XML data.
> */
> - public void generate() throws SAXException {
> + public void generate() throws SAXException, UnsupportedEncodingException {
> this.contentHandler.startDocument();
> AttributesImpl xspAttr = new AttributesImpl();
>
> --
> Arnaud Bienvenu
> http://www.generasound.com/
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>