Author: simonetripodi
Date: Sun Jun 26 21:56:05 2011
New Revision: 1139948

URL: http://svn.apache.org/viewvc?rev=1139948&view=rev
Log:
[DIGESTER-90] xmlrules does not support setNamespaceURI

Added:
    
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/NameSpaceURIRulesBinder.java
   (with props)
    
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNamespaceURIRule.java
   (with props)
    
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Entry.java
   (with props)
    
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Feed.java
   (with props)
    
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/SetNamespaceURITestCase.java
   (with props)
    
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-content.xml
   (with props)
    
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-rules.xml
   (with props)
Modified:
    commons/proper/digester/trunk/RELEASE-NOTES.txt
    commons/proper/digester/trunk/src/changes/changes.xml
    
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
    
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
    
commons/proper/digester/trunk/src/main/resources/org/apache/commons/digester3/xmlrules/digester-rules.dtd
    commons/proper/digester/trunk/src/site/resources/dtds/digester-rules-3.0.dtd

Modified: commons/proper/digester/trunk/RELEASE-NOTES.txt
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/RELEASE-NOTES.txt?rev=1139948&r1=1139947&r2=1139948&view=diff
==============================================================================
--- commons/proper/digester/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/digester/trunk/RELEASE-NOTES.txt Sun Jun 26 21:56:05 2011
@@ -87,6 +87,8 @@ BUGS FROM PREVIOUS RELEASE
 IMPROVEMENTS OVER PREVIOUS RELEASE
 ===================================
 
+ * [DIGESTER-90] xmlrules does not support setNamespaceURI
+
  * [DIGESTER-127] Allow DigesterLoader to accept an instance of a 
preconfigured Digester
 
  * [DIGESTER-131] Allow recursive match in ExtendedBaseRules

Modified: commons/proper/digester/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/changes/changes.xml?rev=1139948&r1=1139947&r2=1139948&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/changes/changes.xml (original)
+++ commons/proper/digester/trunk/src/changes/changes.xml Sun Jun 26 21:56:05 
2011
@@ -26,6 +26,9 @@
     <action dev="simonetripodi" type="fix" issue="DIGESTER-28">
       Default ClassLoader policy unusable in EAR archive
     </action>
+    <action dev="simonetripodi" type="add" issue="DIGESTER-90">
+      xmlrules does not support setNamespaceURI
+    </action>
     <action dev="simonetripodi" type="fix" issue="DIGESTER-103">
       xmlrules does not support NodeCreateRule
     </action>

Modified: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java?rev=1139948&r1=1139947&r2=1139948&view=diff
==============================================================================
--- 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
 (original)
+++ 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
 Sun Jun 26 21:56:05 2011
@@ -75,7 +75,8 @@ public abstract class FromXmlRulesModule
         {
             loadRules();
 
-            XmlRulesModule xmlRulesModule = new XmlRulesModule( rulesBinder(), 
getSystemIds(), rootPath );
+            XmlRulesModule xmlRulesModule = new XmlRulesModule( new 
NameSpaceURIRulesBinder( rulesBinder() ),
+                                                                
getSystemIds(), rootPath );
             Digester digester = newLoader( xmlRulesModule )
                     .register( DIGESTER_PUBLIC_ID, xmlRulesDtdUrl.toString() )
                     .setXIncludeAware( true )

Added: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/NameSpaceURIRulesBinder.java
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/NameSpaceURIRulesBinder.java?rev=1139948&view=auto
==============================================================================
--- 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/NameSpaceURIRulesBinder.java
 (added)
+++ 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/NameSpaceURIRulesBinder.java
 Sun Jun 26 21:56:05 2011
@@ -0,0 +1,102 @@
+package org.apache.commons.digester3.xmlrules;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Stack;
+
+import org.apache.commons.digester3.binder.LinkedRuleBuilder;
+import org.apache.commons.digester3.binder.RulesBinder;
+import org.apache.commons.digester3.binder.RulesModule;
+
+/**
+ * @since 3.0
+ */
+final class NameSpaceURIRulesBinder
+    implements RulesBinder
+{
+
+    // a stack is needed because of includes!!!
+    private final Stack<String> namespaceURIs = new Stack<String>();
+
+    private final RulesBinder wrappedBinder;
+
+    public NameSpaceURIRulesBinder( RulesBinder wrappedBinder )
+    {
+        this.wrappedBinder = wrappedBinder;
+    }
+
+    /**
+     * 
+     * @param namespaceURI
+     */
+    public void addNamespaceURI( String namespaceURI )
+    {
+        namespaceURIs.push( namespaceURI );
+    }
+
+    /**
+     * 
+     */
+    public void removeNamespaceURI()
+    {
+        namespaceURIs.pop();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ClassLoader getContextClassLoader()
+    {
+        return wrappedBinder.getContextClassLoader();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addError( String messagePattern, Object... arguments )
+    {
+        wrappedBinder.addError( messagePattern, arguments );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addError( Throwable t )
+    {
+        wrappedBinder.addError( t );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void install( RulesModule rulesModule )
+    {
+        wrappedBinder.install( rulesModule );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public LinkedRuleBuilder forPattern( String pattern )
+    {
+        return wrappedBinder.forPattern( pattern ).withNamespaceURI( 
namespaceURIs.peek() );
+    }
+
+}

Propchange: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/NameSpaceURIRulesBinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/NameSpaceURIRulesBinder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/NameSpaceURIRulesBinder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNamespaceURIRule.java
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNamespaceURIRule.java?rev=1139948&view=auto
==============================================================================
--- 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNamespaceURIRule.java
 (added)
+++ 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNamespaceURIRule.java
 Sun Jun 26 21:56:05 2011
@@ -0,0 +1,59 @@
+package org.apache.commons.digester3.xmlrules;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.digester3.Rule;
+import org.xml.sax.Attributes;
+
+/**
+ * @since 3.0
+ */
+final class SetNamespaceURIRule
+    extends Rule
+{
+
+    private final NameSpaceURIRulesBinder rulesBinder;
+
+    public SetNamespaceURIRule( NameSpaceURIRulesBinder rulesBinder )
+    {
+        this.rulesBinder = rulesBinder;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void begin( String namespace, String name, Attributes attributes )
+        throws Exception
+    {
+        rulesBinder.addNamespaceURI( attributes.getValue( "namespaceURI" ) );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void end( String namespace, String name )
+        throws Exception
+    {
+        rulesBinder.removeNamespaceURI();
+    }
+
+}

Propchange: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNamespaceURIRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNamespaceURIRule.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNamespaceURIRule.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java?rev=1139948&r1=1139947&r2=1139948&view=diff
==============================================================================
--- 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
 (original)
+++ 
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
 Sun Jun 26 21:56:05 2011
@@ -32,7 +32,7 @@ final class XmlRulesModule
     implements RulesModule
 {
 
-    private final RulesBinder targetRulesBinder;
+    private final NameSpaceURIRulesBinder targetRulesBinder;
 
     private final Set<String> rootSystemIds;
 
@@ -40,7 +40,7 @@ final class XmlRulesModule
 
     private WithMemoryRulesBinder memoryRulesBinder;
 
-    public XmlRulesModule( final RulesBinder targetRulesBinder, Set<String> 
rootSystemIds,
+    public XmlRulesModule( final NameSpaceURIRulesBinder targetRulesBinder, 
Set<String> rootSystemIds,
     /* @Nullable */String rootPath )
     {
         this.targetRulesBinder = targetRulesBinder;
@@ -75,6 +75,8 @@ final class XmlRulesModule
 
         try
         {
+            forPattern( "digester-rules" ).addRule( new SetNamespaceURIRule( 
targetRulesBinder ) );
+
             forPattern( "*/pattern" ).addRule( new PatternRule( patternStack ) 
);
             forPattern( "*/include" ).addRule( new IncludeRule( 
memoryRulesBinder, targetRulesBinder ) );
 

Modified: 
commons/proper/digester/trunk/src/main/resources/org/apache/commons/digester3/xmlrules/digester-rules.dtd
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/resources/org/apache/commons/digester3/xmlrules/digester-rules.dtd?rev=1139948&r1=1139947&r2=1139948&view=diff
==============================================================================
--- 
commons/proper/digester/trunk/src/main/resources/org/apache/commons/digester3/xmlrules/digester-rules.dtd
 (original)
+++ 
commons/proper/digester/trunk/src/main/resources/org/apache/commons/digester3/xmlrules/digester-rules.dtd
 Sun Jun 26 21:56:05 2011
@@ -45,7 +45,8 @@
 
 <!-- digester-rules is the root element. -->
 <!ELEMENT digester-rules (pattern | include | %rule-elements; )*>
-
+<!ATTLIST digester-rules
+    namespaceURI   CDATA #IMPLIED>
 
 <!-- <pattern> defines a matching pattern, or part of a matching pattern. Any
      rule nested in a pattern element prepends its parent's to its pattern.

Modified: 
commons/proper/digester/trunk/src/site/resources/dtds/digester-rules-3.0.dtd
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/site/resources/dtds/digester-rules-3.0.dtd?rev=1139948&r1=1139947&r2=1139948&view=diff
==============================================================================
--- 
commons/proper/digester/trunk/src/site/resources/dtds/digester-rules-3.0.dtd 
(original)
+++ 
commons/proper/digester/trunk/src/site/resources/dtds/digester-rules-3.0.dtd 
Sun Jun 26 21:56:05 2011
@@ -45,7 +45,8 @@
 
 <!-- digester-rules is the root element. -->
 <!ELEMENT digester-rules (pattern | include | %rule-elements; )*>
-
+<!ATTLIST digester-rules
+    namespaceURI   CDATA #IMPLIED>
 
 <!-- <pattern> defines a matching pattern, or part of a matching pattern. Any
      rule nested in a pattern element prepends its parent's to its pattern.

Added: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Entry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Entry.java?rev=1139948&view=auto
==============================================================================
--- 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Entry.java
 (added)
+++ 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Entry.java
 Sun Jun 26 21:56:05 2011
@@ -0,0 +1,95 @@
+package org.apache.commons.digester3.xmlrules;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.net.URL;
+import java.util.Date;
+
+public final class Entry
+{
+
+    private String title;
+
+    private URL link;
+
+    private Date updated;
+
+    private String id;
+
+    private String content;
+
+    public String getTitle()
+    {
+        return title;
+    }
+
+    public void setTitle( String title )
+    {
+        this.title = title;
+    }
+
+    public URL getLink()
+    {
+        return link;
+    }
+
+    public void setLink( URL link )
+    {
+        this.link = link;
+    }
+
+    public Date getUpdated()
+    {
+        return updated;
+    }
+
+    public void setUpdated( Date updated )
+    {
+        this.updated = updated;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    public String getContent()
+    {
+        return content;
+    }
+
+    public void setContent( String content )
+    {
+        this.content = content;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "\n    Entry [title=" + title + ", link=" + link + ", updated=" 
+ updated + ", id=" + id + ", content="
+            + content + "]\n";
+    }
+
+}

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Entry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Entry.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Entry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Feed.java
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Feed.java?rev=1139948&view=auto
==============================================================================
--- 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Feed.java
 (added)
+++ 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Feed.java
 Sun Jun 26 21:56:05 2011
@@ -0,0 +1,109 @@
+package org.apache.commons.digester3.xmlrules;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public final class Feed
+{
+
+    private String title;
+
+    private URL link;
+
+    private Date updated;
+
+    private final List<String> authors = new ArrayList<String>();
+
+    private String id;
+
+    private final List<Entry> entries = new ArrayList<Entry>();
+
+    public String getTitle()
+    {
+        return title;
+    }
+
+    public void setTitle( String title )
+    {
+        this.title = title;
+    }
+
+    public URL getLink()
+    {
+        return link;
+    }
+
+    public void setLink( URL link )
+    {
+        this.link = link;
+    }
+
+    public Date getUpdated()
+    {
+        return updated;
+    }
+
+    public void setUpdated( Date updated )
+    {
+        this.updated = updated;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    public List<String> getAuthors()
+    {
+        return authors;
+    }
+
+    public void addAuthor( String author )
+    {
+        authors.add( author );
+    }
+
+    public List<Entry> getEntries()
+    {
+        return entries;
+    }
+
+    public void addEntry( Entry entry )
+    {
+        entries.add( entry );
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Feed [title=" + title + ", link=" + link + ", updated=" + 
updated + ", authors=" + authors + ", id="
+            + id + ", entries=" + entries + "]";
+    }
+
+}

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Feed.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Feed.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/Feed.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/SetNamespaceURITestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/SetNamespaceURITestCase.java?rev=1139948&view=auto
==============================================================================
--- 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/SetNamespaceURITestCase.java
 (added)
+++ 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/SetNamespaceURITestCase.java
 Sun Jun 26 21:56:05 2011
@@ -0,0 +1,64 @@
+package org.apache.commons.digester3.xmlrules;
+
+import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
+import static org.junit.Assert.*;
+
+import java.net.URL;
+import java.util.Date;
+
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.converters.DateConverter;
+import org.apache.commons.digester3.Digester;
+import org.junit.Test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public final class SetNamespaceURITestCase
+{
+
+    @Test
+    public void atomWithNamespaceParse()
+        throws Exception
+    {
+        // Drive commons-beanutils how to convert dates
+        DateConverter dateConverter = new DateConverter();
+        dateConverter.setPatterns( new String[] { "yyyy-MM-dd'T'HH:mm" } );
+        ConvertUtils.register( dateConverter, Date.class );
+
+        final URL rules = getClass().getResource( "atom-rules.xml" );
+        final URL input = getClass().getResource( "atom-content.xml" );
+
+        Digester digester = newLoader( new FromXmlRulesModule()
+        {
+
+            @Override
+            protected void loadRules()
+            {
+                loadXMLRules( rules );
+            }
+
+        } )
+        .setNamespaceAware( true )
+        .newDigester();
+        Feed feed = digester.parse( input.openStream() );
+        assertNotNull( feed );
+    }
+
+}

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/SetNamespaceURITestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/SetNamespaceURITestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: 
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/xmlrules/SetNamespaceURITestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-content.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-content.xml?rev=1139948&view=auto
==============================================================================
--- 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-content.xml
 (added)
+++ 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-content.xml
 Sun Jun 26 21:56:05 2011
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!--
+    ATOM feed kindly borrowed from Apache Abdera
+    (see 
http://svn.apache.org/repos/asf/abdera/java/trunk/parser/src/test/resources/xmlcontent.xml)
+-->
+<atom:feed xmlns:atom="http://www.w3.org/2005/Atom";>
+
+  <atom:title>Example Feed</atom:title>
+  <atom:link href="http://example.org/"; />
+  <atom:updated>2003-12-13T18:30</atom:updated>
+  <atom:author>
+    <atom:name>John Doe</atom:name>
+  </atom:author>
+  <atom:id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</atom:id>
+
+  <atom:entry>
+    <atom:title>Atom-Powered Robots Run Amok</atom:title>
+    <atom:link href="http://example.org/2003/12/13/atom03"; />
+    <atom:id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</atom:id>
+    <atom:updated>2003-12-13T18:30</atom:updated>
+    <atom:content type="text/plain">this is just a simple test!</atom:content>
+  </atom:entry>
+
+</atom:feed>

Propchange: 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-content.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-content.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-content.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-rules.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-rules.xml?rev=1139948&view=auto
==============================================================================
--- 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-rules.xml
 (added)
+++ 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-rules.xml
 Sun Jun 26 21:56:05 2011
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE digester-rules PUBLIC "-//Apache Commons //DTD digester-rules XML 
V1.0//EN" "http://commons.apache.org/digester/dtds/digester-rules-3.0.dtd";>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+  
+      http://www.apache.org/licenses/LICENSE-2.0
+  
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<digester-rules namespaceURI="http://www.w3.org/2005/Atom";>
+  <pattern value="feed">
+    <object-create-rule classname="org.apache.commons.digester3.xmlrules.Feed" 
/>
+    <bean-property-setter-rule pattern="title" />
+    <bean-property-setter-rule pattern="updated" />
+    <bean-property-setter-rule pattern="id" />
+    <set-properties-rule pattern="link">
+      <alias attr-name="href" prop-name="link" />
+    </set-properties-rule>
+    <call-method-rule pattern="author/name" methodname="addAuthor" 
usingElementBodyAsArgument="true" />
+
+    <pattern value="entry">
+      <object-create-rule 
classname="org.apache.commons.digester3.xmlrules.Entry" />
+      <bean-property-setter-rule pattern="title" />
+      <bean-property-setter-rule pattern="updated" />
+      <bean-property-setter-rule pattern="id" />
+      <set-properties-rule pattern="link">
+        <alias attr-name="href" prop-name="link" />
+      </set-properties-rule>
+      <set-next-rule methodname="addEntry" />
+    </pattern>
+  </pattern>
+</digester-rules>

Propchange: 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-rules.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-rules.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
commons/proper/digester/trunk/src/test/resources/org/apache/commons/digester3/xmlrules/atom-rules.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to