You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Antonio Gallardo <ag...@agssa.net> on 2005/05/04 03:11:35 UTC
Re: svn commit: r165502 -
/cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransforme
r.java
On Mar, 3 de Mayo de 2005, 7:13, Vadim Gritsenko dijo:
> 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?
Reverted.
Best Regards,
Antonio Gallardo