cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r168036 - /cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransformer.java
Date Wed, 04 May 2005 01:10:29 GMT
Author: antonio
Date: Tue May  3 18:10:29 2005
New Revision: 168036

URL: http://svn.apache.org/viewcvs?rev=168036&view=rev
Log:
Revert use regexp for checking valid XSLT parameter names

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransformer.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransformer.java?rev=168036&r1=168035&r2=168036&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransformer.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/transformation/TraxTransformer.java Tue May  3
18:10:29 2005
@@ -55,7 +55,6 @@
 import org.apache.excalibur.source.SourceValidity;
 import org.apache.excalibur.xml.xslt.XSLTProcessor;
 import org.apache.excalibur.xml.xslt.XSLTProcessorException;
-import org.apache.regexp.RE;
 
 import org.xml.sax.SAXException;
 
@@ -200,9 +199,6 @@
     /** 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.
      */
@@ -490,7 +486,25 @@
      * Test if the name is a valid parameter name for XSLT
      */
     static boolean isValidXSLTParameterName(String name) {
-        return reValidXSLTParameterName.match(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;
     }
 
     /**



Mime
View raw message