maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r805576 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src: main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
Date Tue, 18 Aug 2009 21:04:24 GMT
Author: vsiveton
Date: Tue Aug 18 21:04:23 2009
New Revision: 805576

URL: http://svn.apache.org/viewvc?rev=805576&view=rev
Log:
DOXIA-359: Xdoc parser doesnt make the difference for <title/>

o added an exception when 2 <title/> are defined in <properties/> and also in
<head/>

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java?rev=805576&r1=805575&r2=805576&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
Tue Aug 18 21:04:23 2009
@@ -69,6 +69,9 @@
     /** Indicates that we're inside &lt;properties&gt; or &lt;head&gt;.*/
     private boolean inHead;
 
+    /** Indicates that &lt;title&gt; was called from &lt;properties&gt; or
&lt;head&gt;.*/
+    private boolean hasTitle;
+
     /** {@inheritDoc} */
     public void parse( Reader source, Sink sink )
         throws ParseException
@@ -94,6 +97,8 @@
         //setIgnorableWhitespace( true );
 
         super.parse( tmp, sink );
+
+        this.hasTitle = false;
     }
 
     /** {@inheritDoc} */
@@ -120,7 +125,13 @@
         }
         else if ( parser.getName().equals( TITLE.toString() ) )
         {
+            if ( hasTitle )
+            {
+                throw new XmlPullParserException( "<title/> should be defined in <properties/>
or in <head/>, "
+                    + "not both." );
+            }
             sink.title( attribs );
+            this.hasTitle = true;
         }
         else if ( parser.getName().equals( AUTHOR_TAG.toString() ) )
         {

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java?rev=805576&r1=805575&r2=805576&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
Tue Aug 18 21:04:23 2009
@@ -189,6 +189,20 @@
         assertEquals( "body", ( (SinkEventElement) it.next() ).getName() );
         assertEquals( "body_", ( (SinkEventElement) it.next() ).getName() );
         assertFalse( it.hasNext() );
+
+        text = "<document>"
+                + "<properties><title>title</title>"
+                + "<author email=\"a@b.c\">John Doe</author></properties>"
+                + "<head><title>title</title></head><body></body></document>";
+        try
+        {
+            parser.parse( text, sink );
+            assertTrue( false );
+        }
+        catch ( ParseException e )
+        {
+            assertTrue( true );
+        }
     }
 
     /** @throws Exception  */



Mime
View raw message