Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 29960 invoked from network); 3 May 2005 17:29:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 May 2005 17:29:09 -0000 Received: (qmail 93125 invoked by uid 500); 3 May 2005 16:48:25 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 93022 invoked by uid 500); 3 May 2005 16:48:23 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 92961 invoked by uid 99); 3 May 2005 16:48:22 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from 10.21.96-84.rev.gaoland.net (HELO mail.anyware-tech.com) (84.96.21.10) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 03 May 2005 09:47:56 -0700 Received: from localhost (localhost [127.0.0.1]) by mail.anyware-tech.com (Postfix) with ESMTP id A950C347F6 for ; Tue, 3 May 2005 18:46:03 +0200 (CEST) Received: from mail.anyware-tech.com ([127.0.0.1]) by localhost (trinity [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12096-10 for ; Tue, 3 May 2005 18:46:01 +0200 (CEST) Received: from [10.0.0.27] (poukram.anyware [10.0.0.27]) by mail.anyware-tech.com (Postfix) with ESMTP id 6F4E1347AF for ; Tue, 3 May 2005 18:46:00 +0200 (CEST) Message-ID: <4277AAC7.5080202@apache.org> Date: Tue, 03 May 2005 18:45:59 +0200 From: Sylvain Wallez Organization: Anyware Technologies User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@cocoon.apache.org Subject: Not changing things that work (was Re: svn commit: r165502 - /cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransformer.java) References: <20050501133114.10029.qmail@minotaur.apache.org> <42776B00.5060404@reverycodes.com> In-Reply-To: <42776B00.5060404@reverycodes.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at anyware-tech.com X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Vadim Gritsenko wrote: > antonio@apache.org wrote: > >> >> Use BooleanUtils, use regexp for checking valid XSLT parameter names, >> fix docs. >> >> Modified: >> cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransformer.java >> >> @@ -196,7 +199,10 @@ >> >> /** Exception that might occur during setConsumer */ >> private SAXException exceptionDuringSetConsumer; >> - + >> + /** Check if an expression is a valid XSLT Parameter Name **/ >> + private static final RE reValidXSLTParameterName = new >> RE("^[\\w][\\w\\d\\.-]*"); >> + >> /** >> * Configure this transformer. >> */ > > > From RE Javadoc: > > * \w Matches a "word" character (alphanumeric plus "_") > > \w includes numbers, so this RE is incorrect. > > >> @@ -483,26 +490,7 @@ >> * Test if the name is a valid parameter name for XSLT >> */ >> static boolean isValidXSLTParameterName(String name) { >> - if (name.length() == 0) { >> - return false; >> - } >> - >> - char c = name.charAt(0); >> - if (!(Character.isLetter(c) || c == '_')) { >> - return false; >> - } >> - >> - for (int i = name.length()-1; i > 1; i--) { >> - c = name.charAt(i); >> - if (!(Character.isLetterOrDigit(c) || >> - c == '-' || >> - c == '_' || >> - c == '.')) { >> - return false; >> - } >> - } >> - >> - return true; >> + return reValidXSLTParameterName.match(name); >> } >> >> /** > > > Given that org.apache.regexp.RE uses same test for \w: > > ... > (Character.isLetterOrDigit(c) || c == '_') > ... > > And given that RE has more overhead, I wonder how many times slower > this new test is. What is improved, then? I don't think this snippet > had any bugs in it, and it was faster, so why not leave it as it is? Yes, why? Antonio, we know how much you love commons-lang, but really, why spending your and other's energy to add this additional dependency to existing code that has been running smoothly for years? If it ain't broken, don't fix it! Sylvain -- Sylvain Wallez Anyware Technologies http://apache.org/~sylvain http://anyware-tech.com Apache Software Foundation Member Research & Technology Director