Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 17810 invoked by uid 500); 7 Feb 2002 13:01:46 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 17788 invoked from network); 7 Feb 2002 13:01:46 -0000 From: "Piroumian, Konstantin" To: cocoon-dev@xml.apache.org Message-ID: <094801c1afd7$942e3450$6150000a@flagship.ru> Subject: [Patch] Character handling in i18n transformer fix Date: Thu, 7 Feb 2002 16:01:37 +0300 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0945_01C1AFF0.B9460470" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0945_01C1AFF0.B9460470 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Hi! I can't access the Bugzilla to submit this patch, seems that the site is down. Can anybody please apply this patch to i18n transformer that fixes chunked character SAX event handling. Thanks to Tommy Santoso for this patch. Best regards, Konstantin Piroumian ------=_NextPart_000_0945_01C1AFF0.B9460470 Content-Type: application/octet-stream; name="i18n.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="i18n.diff" Feb 7 13:20:39 cvs[18320]: dante/client v1.1.10 running=0A= Feb 7 13:20:39 cvs[18320]: socketoptdup(): setsockopt(0, 32): Invalid = argument (errno =3D 22)=0A= Feb 7 13:20:39 cvs[18320]: socketoptdup(): setsockopt(0, 33): Invalid = argument (errno =3D 22)=0A= Index: I18nTransformer.java=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: = /home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/transformation/I1= 8nTransformer.java,v=0A= retrieving revision 1.10=0A= diff -u -u -r1.10 I18nTransformer.java=0A= --- I18nTransformer.java 7 Feb 2002 07:41:24 -0000 1.10=0A= +++ I18nTransformer.java 7 Feb 2002 12:21:00 -0000=0A= @@ -588,6 +588,9 @@=0A= =0A= // Date pattern types map: short, medium, long, full=0A= private static final Map datePatterns;=0A= + =0A= + // String buffer =0A= + private StringBuffer strBuffer;=0A= =0A= static {=0A= // initialize date types set=0A= @@ -899,6 +902,8 @@=0A= throws SAXException {=0A= =0A= debug("Start i18n element: " + name);=0A= + //initialize the string buffer=0A= + strBuffer =3D new StringBuffer();=0A= =0A= if (I18N_TEXT_ELEMENT.equals(name)) {=0A= if (current_state !=3D STATE_OUTSIDE=0A= @@ -1028,40 +1033,11 @@=0A= =0A= private void endI18NElement(String name) throws SAXException {=0A= debug("End i18n element: " + name);=0A= - switch (current_state) {=0A= - case STATE_INSIDE_TEXT:=0A= - endTextElement();=0A= - break;=0A= -=0A= - case STATE_INSIDE_TRANSLATE:=0A= - endTranslateElement();=0A= - break;=0A= -=0A= - case STATE_INSIDE_PARAM:=0A= - endParamElement();=0A= - break;=0A= -=0A= - case STATE_INSIDE_DATE:=0A= - case STATE_INSIDE_DATE_TIME:=0A= - case STATE_INSIDE_TIME:=0A= - endDate_TimeElement();=0A= - break;=0A= -=0A= - case STATE_INSIDE_NUMBER:=0A= - endNumberElement();=0A= - break;=0A= - }=0A= - }=0A= -=0A= - private void i18nCharacters(char[] ch, int start, int len)=0A= - throws SAXException {=0A= -=0A= - String textValue =3D new String(ch, start, len).trim();=0A= - if (textValue =3D=3D null || textValue.length() =3D=3D 0) {=0A= + =0A= + if (strBuffer.length() =3D=3D 0) {=0A= return;=0A= }=0A= -=0A= - debug( "i18n message text =3D '" + textValue + "'" );=0A= + debug( "i18n message text =3D '" + strBuffer.toString() + "'" = );=0A= =0A= switch (current_state) {=0A= case STATE_INSIDE_TEXT:=0A= @@ -1070,39 +1046,46 @@=0A= =0A= // If no translation found and untranslated param is = null=0A= if (translated_text =3D=3D null) {=0A= - translated_text =3D textValue; // use the key=0A= + translated_text =3D strBuffer.toString(); // use = the key=0A= }=0A= =0A= // reset the key holding variable=0A= current_key =3D null;=0A= } else { // use text value as dictionary key=0A= - translated_text =3D getString(textValue, (untranslated = =3D=3D null) ? textValue : untranslated);=0A= + translated_text =3D getString(strBuffer.toString(), = =0A= + (untranslated =3D=3D null) ? strBuffer.toString(): = untranslated);=0A= }=0A= + endTextElement();=0A= break;=0A= =0A= case STATE_INSIDE_TRANSLATE:=0A= // Store text for param substitution (do not translate)=0A= if (substitute_text =3D=3D null) {=0A= - substitute_text =3D textValue;=0A= + substitute_text =3D strBuffer.toString();=0A= }=0A= + endTranslateElement();=0A= break;=0A= =0A= case STATE_INSIDE_PARAM:=0A= // Store translation for param substitution=0A= if (param_value =3D=3D null) {=0A= - param_value =3D textValue;=0A= + param_value =3D strBuffer.toString();=0A= }=0A= + endParamElement();=0A= break;=0A= =0A= case STATE_INSIDE_DATE:=0A= case STATE_INSIDE_DATE_TIME:=0A= case STATE_INSIDE_TIME:=0A= + endDate_TimeElement();=0A= + break;=0A= case STATE_INSIDE_NUMBER:=0A= if (formattingParams.get(I18N_VALUE_ATTRIBUTE) =3D=3D = null) {=0A= - formattingParams.put(I18N_VALUE_ATTRIBUTE, = textValue);=0A= + formattingParams.put(I18N_VALUE_ATTRIBUTE, = strBuffer.toString());=0A= } else {=0A= ; // ignore the text inside of date element=0A= }=0A= + endNumberElement();=0A= break;=0A= =0A= default:=0A= @@ -1112,6 +1095,12 @@=0A= }=0A= }=0A= =0A= + private void i18nCharacters(char[] ch, int start, int len)=0A= + throws SAXException {=0A= + =0A= + strBuffer.append(new String(ch, start, len).trim());=0A= + }=0A= +=0A= // Translate all attributes that are listed in i18n:attr = attribute=0A= private Attributes translateAttributes(String name, Attributes = attr)=0A= throws SAXException {=0A= @@ -1519,6 +1508,7 @@=0A= =0A= factory.release(dictionary);=0A= dictionary =3D null;=0A= + strBuffer =3D null;=0A= }=0A= =0A= public void dispose() {=0A= ------=_NextPart_000_0945_01C1AFF0.B9460470 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org ------=_NextPart_000_0945_01C1AFF0.B9460470--