commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skitch...@apache.org
Subject svn commit: r155899 - jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationAction.java
Date Wed, 02 Mar 2005 09:06:25 GMT
Author: skitching
Date: Wed Mar  2 01:06:22 2005
New Revision: 155899

URL: http://svn.apache.org/viewcvs?view=rev&rev=155899
Log:
Ensure attributes with associated namespaces are passed to the
RuleFinder classes.

Modified:
    jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationAction.java

Modified: jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationAction.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationAction.java?view=diff&r1=155898&r2=155899
==============================================================================
--- jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationAction.java
(original)
+++ jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginDeclarationAction.java
Wed Mar  2 01:06:22 2005
@@ -68,19 +68,7 @@
     org.xml.sax.Attributes attributes)
     throws ParseException {
 
-        // copy all the attribute values into a properties object so that
-        // the plugin finder strategies can access the properties later.
-        int nAttrs = attributes.getLength();
-        Properties props = new Properties();
-        for(int i=0; i<nAttrs; ++i) {
-            String key = attributes.getLocalName(i);
-            if ((key == null) || (key.length() == 0)) {
-                key = attributes.getQName(i);
-            }
-            String value = attributes.getValue(i);
-            props.setProperty(key, value);
-        }
-        
+        Properties props = attributesToProperties(attributes);
         try {
             declarePlugin(context, props);
         } catch(PluginInvalidInputException ex) {
@@ -125,6 +113,32 @@
 
         PluginDeclarationScope pds = PluginDeclarationScope.getInstance(context); 
         pds.addDeclaration(newDecl);
+    }
+
+    /**
+     * Copy all the (key,value) pairs in the provided Attributes object into
+     * a java.util.Properties object. If an attribute has an associated
+     * namespace, then the properties key is of form "{namespace}name".
+     */
+    private static Properties attributesToProperties(org.xml.sax.Attributes attrs) {
+        int nAttrs = attrs.getLength();
+        Properties props = new Properties();
+        for(int i=0; i<nAttrs; ++i) {
+            String namespace = attrs.getURI(i);
+
+            String key = attrs.getLocalName(i);
+            if ((key == null) || (key.length() == 0)) {
+                key = attrs.getQName(i);
+            }
+
+            if ((namespace != null) && (namespace.length()>0)) {
+                key = "{" + namespace + "}" + key;
+            }
+            
+            String value = attrs.getValue(i);
+            props.setProperty(key, value);
+        }
+        return props;
     }
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message