You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by tr...@apache.org on 2006/07/11 16:43:36 UTC

svn commit: r420875 - in /maven/doxia/trunk: ./ doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/ doxia-sandbox/ doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/ doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxi...

Author: trygvis
Date: Tue Jul 11 07:43:35 2006
New Revision: 420875

URL: http://svn.apache.org/viewvc?rev=420875&view=rev
Log:
o Adding a Xdoc sink so it's possible to include the content directly in a
  generated site.
o Changed the Doxia book Maven plugin to use the target/generated-site
  directory for output as default.
o Implementing the Indexing service. This should be changed in the future to
  just be a step in a pre-processing step of all the documents before rendering
  them.
o Fixing the Xdoc so that it would write out the <xxxsection> start elements.

Added:
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookIndex.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/IndexEntry.java
      - copied, changed from r420511, maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/TOCEntry.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexerTest.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/BookIo.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/XdocBookSink.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/context/
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/context/IndexEntryTest.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/services/
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/services/indexer/
    maven/doxia/trunk/doxia-sandbox/pom.xml
Removed:
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/TOCEntry.java
Modified:
    maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
    maven/doxia/trunk/doxia-sandbox/   (props changed)
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexingSink.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/DefaultBookIndexer.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/BookRendererTest.java
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-1.apt
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-2.apt
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-3.apt
    maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-4.apt
    maven/doxia/trunk/doxia-sandbox/doxia-editor/pom.xml
    maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/pom.xml
    maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java
    maven/doxia/trunk/pom.xml

Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java (original)
+++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java Tue Jul 11 07:43:35 2006
@@ -29,18 +29,17 @@
  *
  * @author <a href="mailto:james@jamestaylor.org">James Taylor</a>
  * @version $Id:XdocSink.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
- * @componentx
  */
 public class XdocSink
     extends SinkAdapter
 {
-    private static final String EOL = System.getProperty( "line.separator" );
+    protected static final String EOL = System.getProperty( "line.separator" );
 
-    private LineBreaker out;
+    protected LineBreaker out;
 
-    private StringBuffer buffer = new StringBuffer();
+    protected StringBuffer buffer = new StringBuffer();
 
-    private boolean headFlag;
+    protected boolean headFlag;
 
     private int itemFlag;
 
@@ -141,57 +140,72 @@
 
     public void section1()
     {
-        section = "section";
+        markup( "<section name=\"" );
     }
 
-    public void section2()
+    public void sectionTitle1_()
     {
-        section = "subsection";
+        markup( "\">" );
     }
 
-    public void section3()
+    public void section1_()
     {
-        section = "subsection";
+        markup( "</section>" );
     }
 
-    public void section4()
+    public void section2()
     {
-        section = "subsection";
+        markup( "<subsection name=\"" );
     }
 
-    public void section5()
+    public void sectionTitle2_()
     {
-        section = "subsection";
+        sectionTitle1_();
     }
 
-    public void sectionTitle()
+    public void section2_()
     {
-        markup( "<" + section + " name=\"" );
+        markup( "</subsection>" );
     }
 
-    public void sectionTitle_()
+    public void section3()
     {
-        markup( "\">" );
+        markup( "<subsection name=\"" );
     }
 
-    public void section1_()
+    public void sectionTitle3_()
     {
-        markup( "</section>" );
+        sectionTitle1_();
     }
 
-    public void section2_()
+    public void section3_()
     {
         markup( "</subsection>" );
     }
 
-    public void section3_()
+    public void section4()
     {
-        markup( "</subsection>" );
+        markup( "<subsection name=\"" );
+    }
+
+    public void sectionTitle4_()
+    {
+        sectionTitle1_();
     }
 
     public void section4_()
     {
         markup( "</subsection>" );
+    }
+
+    public void section5()
+    {
+        markup( "<subsection name=\"" );
+    }
+
+    public void sectionTitle5_()
+    {
+        sectionTitle1_();
     }
 
     public void section5_()

Propchange: maven/doxia/trunk/doxia-sandbox/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 11 07:43:35 2006
@@ -0,0 +1,8 @@
+target
+*~
+*.log
+.classpath
+.project
+*.ipr
+*.iws
+*.iml

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java Tue Jul 11 07:43:35 2006
@@ -1,26 +1,18 @@
 package org.apache.maven.doxia.book;
 
 import org.apache.maven.doxia.book.context.BookContext;
-import org.apache.maven.doxia.book.context.TOCEntry;
+import org.apache.maven.doxia.book.context.IndexEntry;
 import org.apache.maven.doxia.book.model.Book;
-import org.apache.maven.doxia.book.model.io.xpp3.BookXpp3Reader;
 import org.apache.maven.doxia.book.services.indexer.BookIndexer;
+import org.apache.maven.doxia.book.services.io.BookIo;
 import org.apache.maven.doxia.book.services.renderer.BookRenderer;
 import org.apache.maven.doxia.book.services.validation.BookValidator;
 import org.apache.maven.doxia.book.services.validation.ValidationResult;
-import org.apache.maven.doxia.site.module.SiteModule;
-import org.apache.maven.doxia.site.module.manager.SiteModuleManager;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeMap;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -34,6 +26,11 @@
     /**
      * @plexus.requirement
      */
+    private BookIo bookIo;
+
+    /**
+     * @plexus.requirement
+     */
     private BookValidator bookValidator;
 
     /**
@@ -46,11 +43,6 @@
      */
     private Map bookRenderers;
 
-    /**
-     * @plexus.requirement
-     */
-    private SiteModuleManager siteModuleManager;
-
     // ----------------------------------------------------------------------
     // BookDoxia Implementation
     // ----------------------------------------------------------------------
@@ -58,20 +50,7 @@
     public void renderBook( File bookDescriptor, String bookRendererId, List files, File outputDirectory )
         throws BookDoxiaException
     {
-        Book book;
-
-        try
-        {
-            book = new BookXpp3Reader().read( new FileReader( bookDescriptor ), true );
-        }
-        catch ( IOException e )
-        {
-            throw new BookDoxiaException( "Error while reading book descriptor.", e );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new BookDoxiaException( "Error while reading book descriptor.", e );
-        }
+        Book book = bookIo.readBook( bookDescriptor );
 
         // ----------------------------------------------------------------------
         //
@@ -94,52 +73,11 @@
 
         context.setOutputDirectory( outputDirectory );
 
-        context.setRootTOCEntry( new TOCEntry() );
-
-        // ----------------------------------------------------------------------
+        // -----------------------------------------------------------------------
         //
-        // ----------------------------------------------------------------------
-
-        Collection siteModules = siteModuleManager.getSiteModules();
-
-        for ( Iterator it = siteModules.iterator(); it.hasNext(); )
-        {
-            SiteModule siteModule = (SiteModule) it.next();
-
-            String extension = siteModule.getExtension();
-
-            for ( Iterator j = files.iterator(); j.hasNext(); )
-            {
-                File file = (File) j.next();
-
-                String name = file.getName();
-
-                if ( name.endsWith( extension ) )
-                {
-                    name = name.substring( 0, name.length() - siteModule.getExtension().length() - 1 );
-
-                    BookContext.BookFile bookFile = new BookContext.BookFile( file, siteModule.getParserId() );
+        // -----------------------------------------------------------------------
 
-                    context.getFiles().put( name, bookFile );
-                }
-            }
-        }
-
-        if ( getLogger().isDebugEnabled() )
-        {
-            getLogger().debug( "Dumping document <-> id mapping:" );
-
-            Map map = new TreeMap( context.getFiles() );
-
-            for ( Iterator it = map.entrySet().iterator(); it.hasNext(); )
-            {
-                Map.Entry entry = (Map.Entry) it.next();
-
-                BookContext.BookFile file = (BookContext.BookFile) entry.getValue();
-
-                getLogger().debug( " " + entry.getKey() + "=" + file.getFile() + ", parser: " + file.getParserId() );
-            }
-        }
+        bookIo.loadFiles( context, files );
 
         // ----------------------------------------------------------------------
         // Generate indexes

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java Tue Jul 11 07:43:35 2006
@@ -2,7 +2,6 @@
 
 import org.apache.maven.doxia.book.model.Book;
 
-import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
 import java.io.File;
@@ -19,7 +18,7 @@
 
     private File outputDirectory;
 
-    private TOCEntry rootTOCEntry;
+    private BookIndex index;
 
     // ----------------------------------------------------------------------
     //
@@ -87,13 +86,13 @@
         this.outputDirectory = outputDirectory;
     }
 
-    public TOCEntry getRootTOCEntry()
+    public BookIndex getIndex()
     {
-        return rootTOCEntry;
+        return index;
     }
 
-    public void setRootTOCEntry( TOCEntry rootTOCEntry )
+    public void setIndex( BookIndex index )
     {
-        this.rootTOCEntry = rootTOCEntry;
+        this.index = index;
     }
 }

Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookIndex.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookIndex.java?rev=420875&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookIndex.java (added)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookIndex.java Tue Jul 11 07:43:35 2006
@@ -0,0 +1,14 @@
+package org.apache.maven.doxia.book.context;
+
+/**
+ * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class BookIndex
+    extends IndexEntry
+{
+    public BookIndex()
+    {
+        super( "book" );
+    }
+}

Copied: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/IndexEntry.java (from r420511, maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/TOCEntry.java)
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/IndexEntry.java?p2=maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/IndexEntry.java&p1=maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/TOCEntry.java&r1=420511&r2=420875&rev=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/TOCEntry.java (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/context/IndexEntry.java Tue Jul 11 07:43:35 2006
@@ -1,28 +1,59 @@
 package org.apache.maven.doxia.book.context;
 
+import org.codehaus.plexus.util.StringUtils;
+
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Collections;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
  */
-public class TOCEntry
+public class IndexEntry
 {
-    private String sectionId;
+    private IndexEntry parent;
+
+    private String id;
 
     private String title;
 
-    private List childEntries;
+    private List childEntries = new ArrayList();
+
+    private static final String EOL = System.getProperty( "line.separator" );
 
-    public String getSectionId()
+    public IndexEntry( String id )
     {
-        return sectionId;
+        this.id = id;
     }
 
-    public void setSectionId( String sectionId )
+    public IndexEntry( IndexEntry parent, String id )
     {
-        this.sectionId = sectionId;
+        if ( parent == null )
+        {
+            throw new NullPointerException( "parent cannot be null." );
+        }
+
+        if ( id == null )
+        {
+            throw new NullPointerException( "parent cannot be null." );
+        }
+
+        this.parent = parent;
+        this.id = id;
+
+        parent.childEntries.add( this );
+    }
+
+    public IndexEntry getParent()
+    {
+        return parent;
+    }
+
+    public String getId()
+    {
+        return id;
     }
 
     public String getTitle()
@@ -37,16 +68,128 @@
 
     public List getChildEntries()
     {
+        return Collections.unmodifiableList( childEntries );
+    }
+
+    public void setChildEntries( List childEntries )
+    {
         if ( childEntries == null )
         {
             childEntries = new ArrayList();
         }
 
-        return childEntries;
+        this.childEntries = childEntries;
     }
 
-    public void setChildEntries( List childEntries )
+    // -----------------------------------------------------------------------
+    // Utils
+    // -----------------------------------------------------------------------
+
+    public IndexEntry getNextEntry()
     {
-        this.childEntries = childEntries;
+        if ( parent == null )
+        {
+            return null;
+        }
+
+        List entries = parent.getChildEntries();
+
+        int index = entries.indexOf( this );
+
+        if ( index + 1 >= entries.size() )
+        {
+            return null;
+        }
+
+        return (IndexEntry) entries.get( index + 1 );
+    }
+
+    public IndexEntry getPrevEntry()
+    {
+        if ( parent == null )
+        {
+            return null;
+        }
+
+        List entries = parent.getChildEntries();
+
+        int index = entries.indexOf( this );
+
+        if ( index == 0 )
+        {
+            return null;
+        }
+
+        return (IndexEntry) entries.get( index - 1 );
+    }
+
+    public IndexEntry getFirstEntry()
+    {
+        List entries = getChildEntries();
+
+        if ( entries.size() == 0 )
+        {
+            return null;
+        }
+        else
+        {
+            return (IndexEntry) entries.get( 0 );
+        }
+    }
+
+    public IndexEntry getRootEntry()
+    {
+        List entries = getChildEntries();
+
+        if ( entries.size() == 0 )
+        {
+            return null;
+        }
+        else if ( entries.size() > 1 )
+        {
+            throw new RuntimeException( "This index has more than one root entry" );
+        }
+        else
+        {
+            return (IndexEntry) entries.get( 0 );
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    // Object Overrides
+    // -----------------------------------------------------------------------
+
+    public String toString()
+    {
+        return toString( 0 );
+    }
+
+    public String toString( int depth )
+    {
+        StringBuffer message = new StringBuffer();
+
+        message.append( "Id: " ).append( id );
+
+        if ( StringUtils.isNotEmpty( title ) )
+        {
+            message.append( ", title: " ).append( title );
+        }
+
+        message.append( EOL );
+
+        String indent = "";
+
+        for( int i = 0; i < depth; i++ ) {
+            indent += " ";
+        }
+
+        for ( Iterator it = getChildEntries().iterator(); it.hasNext(); )
+        {
+            IndexEntry entry = (IndexEntry) it.next();
+
+            message.append( indent ).append( entry.toString( depth + 1 ) );
+        }
+
+        return message.toString();
     }
 }

Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexerTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexerTest.java?rev=420875&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexerTest.java (added)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexerTest.java Tue Jul 11 07:43:35 2006
@@ -0,0 +1,98 @@
+package org.apache.maven.doxia.book.services.indexer;
+
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.apache.maven.doxia.book.services.io.BookIo;
+import org.apache.maven.doxia.book.model.Book;
+import org.apache.maven.doxia.book.context.BookContext;
+import org.apache.maven.doxia.book.context.IndexEntry;
+
+/**
+ * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class BookIndexerTest
+    extends PlexusTestCase
+{
+    public void testBasic()
+        throws Exception
+    {
+        BookIo io = (BookIo) lookup( BookIo.ROLE );
+
+        BookIndexer indexer = (BookIndexer) lookup( BookIndexer.ROLE );
+
+        Book book = io.readBook( getTestFile( "src/test/resources/book-1.xml" ) );
+
+        BookContext context = new BookContext();
+
+        io.loadFiles( context, FileUtils.getFiles( getTestFile( "src/test/resources/book-1" ), "*.apt", "" ) );
+
+        indexer.indexBook( book, context );
+
+        IndexEntry root = context.getIndex();
+
+        assertNotNull( root );
+
+        assertEquals( 2, root.getChildEntries().size() );
+
+        IndexEntry c1 = assertIndexEntry( root, 0, "Chapter 1", "chapter-1", 2 );
+
+        // -----------------------------------------------------------------------
+        // Section 1
+        // -----------------------------------------------------------------------
+
+        IndexEntry s1 = assertIndexEntry( c1, 0, "Section 1", "section-1", 5 );
+
+        IndexEntry ss1 = assertIndexEntry( s1, 0, "Subsection 1", "subsection_1", 1 );
+
+        assertIndexEntry( ss1, 0, "Subsubsection 1", "subsubsection_1", 0 );
+
+        assertIndexEntry( s1, 1, "Subsection 2", "subsection_2", 0 );
+
+        assertIndexEntry( s1, 2, "Subsection 3", "subsection_3", 0 );
+
+        assertIndexEntry( s1, 3, "Subsection 4", "subsection_4", 0 );
+
+        // -----------------------------------------------------------------------
+        // Section 2
+        // -----------------------------------------------------------------------
+
+        IndexEntry s2 = assertIndexEntry( c1, 1, "Section 2", "section-2", 1 );
+
+        assertIndexEntry( s2, 0, "Section 1.10.32 of \"de Finibus Bonorum et Malorum\", written by Cicero in 45 BC",
+                          "section_1.10.32_of_\"de_finibus_bonorum_et_malorum\",_written_by_cicero_in_45_bc", 0 );
+
+        // -----------------------------------------------------------------------
+        // Chapter 2
+        // -----------------------------------------------------------------------
+
+        IndexEntry c2 = assertIndexEntry( root, 1, "Chapter 2", "chapter-2", 2 );
+
+        IndexEntry s3 = assertIndexEntry( c2, 0, "Section 3", "section-3", 1 );
+
+        assertIndexEntry( s3, 0, "1914 translation by H. Rackham", "1914_translation_by_h._rackham", 0 );
+
+        IndexEntry s4 = assertIndexEntry( c2, 1, "Section 4", "section-4", 1 );
+
+        assertIndexEntry( s4, 0, "Section 1.10.33 of \"de Finibus Bonorum et Malorum\", written by Cicero in 45 BC",
+                          "section_1.10.33_of_\"de_finibus_bonorum_et_malorum\",_written_by_cicero_in_45_bc", 0 );
+    }
+
+    private IndexEntry assertIndexEntry( IndexEntry parent, int childIndex, String title, String id, int childCount )
+    {
+        assertTrue( "parent: " + parent.getId() +  ", " +
+            "required count: " + childCount + ", " +
+            "actual count: " + parent.getChildEntries().size(),
+                    childIndex < parent.getChildEntries().size() );
+
+        IndexEntry indexEntry = (IndexEntry) parent.getChildEntries().get( childIndex );
+
+        assertEquals( title, indexEntry.getTitle() );
+
+        assertEquals( id, indexEntry.getId() );
+
+        assertEquals( childCount, indexEntry.getChildEntries().size() );
+
+        return indexEntry;
+    }
+}

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexingSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexingSink.java?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexingSink.java (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/BookIndexingSink.java Tue Jul 11 07:43:35 2006
@@ -1,11 +1,10 @@
 package org.apache.maven.doxia.book.services.indexer;
 
 import org.apache.maven.doxia.sink.SinkAdapter;
-import org.apache.maven.doxia.book.context.BookContext;
-import org.apache.maven.doxia.book.context.TOCEntry;
-import org.apache.maven.doxia.book.BookDoxiaException;
+import org.apache.maven.doxia.book.context.IndexEntry;
 
 import java.util.List;
+import java.util.Stack;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -22,6 +21,7 @@
     private final static int TYPE_DEFINED_TERM = 6;
     private final static int TYPE_FIGURE = 7;
     private final static int TYPE_TABLE = 8;
+    private final static int TITLE = 9;
 
     private int type;
 
@@ -29,91 +29,149 @@
     //
     // ----------------------------------------------------------------------
 
-    private BookContext bookContext;
+    private String title;
 
-    public BookIndexingSink( BookContext bookContext )
+    private Stack stack = new Stack();
+
+    public BookIndexingSink( IndexEntry sectionEntry )
+    {
+        stack.push( sectionEntry );
+    }
+
+    public String getTitle()
     {
-        this.bookContext = bookContext;
+        return title;
     }
 
     // ----------------------------------------------------------------------
     // Sink Overrides
     // ----------------------------------------------------------------------
 
-    public void sectionTitle1_()
+    public void title()
+    {
+        super.title();
+
+        type = TITLE;
+    }
+
+    public void sectionTitle1()
     {
         type = TYPE_SECTION_1;
     }
 
-    public void sectionTitle2_()
+    public void section1_()
+    {
+        pop();
+    }
+
+    public void sectionTitle2()
     {
         type = TYPE_SECTION_2;
     }
 
-    public void sectionTitle3_()
+    public void section2_()
+    {
+        pop();
+    }
+
+    public void sectionTitle3()
     {
         type = TYPE_SECTION_3;
     }
 
-    public void sectionTitle4_()
+    public void section3_()
     {
-        type = TYPE_SECTION_4;
+        pop();
     }
 
-    public void sectionTitle5_()
+    public void sectionTitle4()
     {
-        type = TYPE_SECTION_5;
+        type = TYPE_SECTION_4;
     }
 
-    public void definedTerm_()
+    public void section4_()
     {
-        type = TYPE_DEFINED_TERM;
+        pop();
     }
 
-    public void figureCaption_()
+    public void sectionTitle5()
     {
-        type = TYPE_FIGURE;
+        type = TYPE_SECTION_5;
     }
 
-    public void tableCaption_()
+    public void section5_()
     {
-        type = TYPE_TABLE;
+        pop();
     }
 
+//    public void definedTerm()
+//    {
+//        type = TYPE_DEFINED_TERM;
+//    }
+//
+//    public void figureCaption()
+//    {
+//        type = TYPE_FIGURE;
+//    }
+//
+//    public void tableCaption()
+//    {
+//        type = TYPE_TABLE;
+//    }
+
     public void text( String text )
     {
-        if ( bookContext == null )
-        {
-            throw new RuntimeException( new BookDoxiaException( "The book context has to be set first." ) );
-        }
-
-        TOCEntry entry = new TOCEntry();
-        entry.setTitle( text );
+        IndexEntry entry;
 
         switch( type )
         {
-            case TYPE_SECTION_1: addSection( 0, entry ); break;
-            case TYPE_SECTION_2: addSection( 1, entry ); break;
-            case TYPE_SECTION_3: addSection( 2, entry ); break;
-            case TYPE_SECTION_4: addSection( 3, entry ); break;
-            case TYPE_SECTION_5: addSection( 4, entry ); break;
+            case TITLE:
+                this.title = text;
+                break;
+            case TYPE_SECTION_1:
+            case TYPE_SECTION_2:
+            case TYPE_SECTION_3:
+            case TYPE_SECTION_4:
+            case TYPE_SECTION_5:
+                // -----------------------------------------------------------------------
+                // Sanitize the id. The most important step is to remove any blanks
+                // -----------------------------------------------------------------------
+
+                String id = text.toLowerCase().replace( ' ', '_' );
+
+                // -----------------------------------------------------------------------
+                //
+                // -----------------------------------------------------------------------
+
+                entry = new IndexEntry( peek(), id );
+
+                entry.setTitle( text );
+
+                push( entry );
+                break;
+            // Dunno how to handle these yet
             case TYPE_DEFINED_TERM:
             case TYPE_FIGURE:
             case TYPE_TABLE:
         }
+
+        type = 0;
     }
 
-    private void addSection( int depth, TOCEntry entry )
+    public void push( IndexEntry entry )
     {
-        TOCEntry parent = bookContext.getRootTOCEntry();
-
-        for ( int i = 0; i < depth; i++ )
-        {
-            List entries = parent.getChildEntries();
+//        System.out.println(  "push: " + entry.getId() );
+        stack.push( entry );
+    }
 
-            parent = (TOCEntry) entries.get( entries.size() - 1 );
-        }
+    public void pop()
+    {
+//        System.out.println(  "pop: " + peek().getId() );
+        stack.pop();
+    }
 
-        parent.getChildEntries().add( entry );
+    public IndexEntry peek()
+    {
+        return (IndexEntry) stack.peek();
     }
 }

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/DefaultBookIndexer.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/DefaultBookIndexer.java?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/DefaultBookIndexer.java (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/indexer/DefaultBookIndexer.java Tue Jul 11 07:43:35 2006
@@ -1,6 +1,8 @@
 package org.apache.maven.doxia.book.services.indexer;
 
 import org.apache.maven.doxia.book.context.BookContext;
+import org.apache.maven.doxia.book.context.IndexEntry;
+import org.apache.maven.doxia.book.context.BookIndex;
 import org.apache.maven.doxia.book.model.Book;
 import org.apache.maven.doxia.book.model.Chapter;
 import org.apache.maven.doxia.book.model.Section;
@@ -36,32 +38,38 @@
     public void indexBook( Book book, BookContext bookContext )
         throws BookDoxiaException
     {
-        BookIndexingSink sink = new BookIndexingSink( bookContext );
+        BookIndex index = new BookIndex();
 
         for ( Iterator it = book.getChapters().iterator(); it.hasNext(); )
         {
             Chapter chapter = (Chapter) it.next();
 
-            indexChapter( bookContext, chapter, sink );
+            indexChapter( bookContext, index, chapter );
         }
+
+        bookContext.setIndex( index );
     }
 
     // ----------------------------------------------------------------------
     // Private
     // ----------------------------------------------------------------------
 
-    private void indexChapter( BookContext bookContext, Chapter chapter, BookIndexingSink sink )
+    private void indexChapter( BookContext context, IndexEntry bookEntry, Chapter chapter )
         throws BookDoxiaException
     {
+        IndexEntry chapterEntry = new IndexEntry( bookEntry, chapter.getId( ) );
+
+        chapterEntry.setTitle( chapter.getTitle() );
+
         for ( Iterator it = chapter.getSections().iterator(); it.hasNext(); )
         {
             Section section = (Section) it.next();
 
-            indexSection( bookContext, section, sink );
+            indexSection( context, chapterEntry, section );
         }
     }
 
-    private void indexSection( BookContext bookContext, Section section, BookIndexingSink sink )
+    private void indexSection( BookContext bookContext, IndexEntry chapterEntry, Section section )
         throws BookDoxiaException
     {
         BookContext.BookFile bookFile = (BookContext.BookFile) bookContext.getFiles().get( section.getId() );
@@ -75,6 +83,10 @@
         //
         // ----------------------------------------------------------------------
 
+        IndexEntry sectionEntry = new IndexEntry( chapterEntry, section.getId() );
+
+        BookIndexingSink sink = new BookIndexingSink( sectionEntry );
+
         try
         {
             doxia.parse( new FileReader( bookFile.getFile() ), bookFile.getParserId(), sink );
@@ -91,5 +103,7 @@
         {
             throw new BookDoxiaException( "Could not find document: " + bookFile.getFile().getAbsolutePath() + ".", e );
         }
+
+        sectionEntry.setTitle( sink.getTitle() );
     }
 }

Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/BookIo.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/BookIo.java?rev=420875&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/BookIo.java (added)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/BookIo.java Tue Jul 11 07:43:35 2006
@@ -0,0 +1,22 @@
+package org.apache.maven.doxia.book.services.io;
+
+import org.apache.maven.doxia.book.model.Book;
+import org.apache.maven.doxia.book.BookDoxiaException;
+import org.apache.maven.doxia.book.context.BookContext;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public interface BookIo
+{
+    String ROLE = BookIo.class.getName();
+
+    Book readBook( File bookDescriptor )
+        throws BookDoxiaException;
+
+    void loadFiles( BookContext context, List files );
+}

Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java?rev=420875&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java (added)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java Tue Jul 11 07:43:35 2006
@@ -0,0 +1,104 @@
+package org.apache.maven.doxia.book.services.io;
+
+import org.apache.maven.doxia.book.model.io.xpp3.BookXpp3Reader;
+import org.apache.maven.doxia.book.model.Book;
+import org.apache.maven.doxia.book.BookDoxiaException;
+import org.apache.maven.doxia.book.context.BookContext;
+import org.apache.maven.doxia.site.module.SiteModule;
+import org.apache.maven.doxia.site.module.manager.SiteModuleManager;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.List;
+
+/**
+ * @plexus.component
+ *
+ * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class DefaultBookIo
+    extends AbstractLogEnabled
+    implements BookIo
+{
+    /**
+     * @plexus.requirement
+     */
+    private SiteModuleManager siteModuleManager;
+
+    // -----------------------------------------------------------------------
+    // DefaultBookIo Implementation
+    // -----------------------------------------------------------------------
+
+    public Book readBook( File bookDescriptor )
+        throws BookDoxiaException
+    {
+        try
+        {
+            return new BookXpp3Reader().read( new FileReader( bookDescriptor ), true );
+        }
+        catch ( IOException e )
+        {
+            throw new BookDoxiaException( "Error while reading book descriptor.", e );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new BookDoxiaException( "Error while reading book descriptor.", e );
+        }
+    }
+
+    public void loadFiles( BookContext context, List files )
+    {
+        // ----------------------------------------------------------------------
+        // Find all the files, map the file names to ids
+        // ----------------------------------------------------------------------
+
+        Collection siteModules = siteModuleManager.getSiteModules();
+
+        for ( Iterator it = siteModules.iterator(); it.hasNext(); )
+        {
+            SiteModule siteModule = (SiteModule) it.next();
+
+            String extension = siteModule.getExtension();
+
+            for ( Iterator j = files.iterator(); j.hasNext(); )
+            {
+                File file = (File) j.next();
+
+                String name = file.getName();
+
+                if ( name.endsWith( extension ) )
+                {
+                    name = name.substring( 0, name.length() - siteModule.getExtension().length() - 1 );
+
+                    BookContext.BookFile bookFile = new BookContext.BookFile( file, siteModule.getParserId() );
+
+                    context.getFiles().put( name, bookFile );
+                }
+            }
+        }
+
+        if ( getLogger().isDebugEnabled() )
+        {
+            getLogger().debug( "Dumping document <-> id mapping:" );
+
+            Map map = new TreeMap( context.getFiles() );
+
+            for ( Iterator it = map.entrySet().iterator(); it.hasNext(); )
+            {
+                Map.Entry entry = (Map.Entry) it.next();
+
+                BookContext.BookFile file = (BookContext.BookFile) entry.getValue();
+
+                getLogger().debug( " " + entry.getKey() + "=" + file.getFile() + ", parser: " + file.getParserId() );
+            }
+        }
+    }
+}

Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java?rev=420875&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java (added)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java Tue Jul 11 07:43:35 2006
@@ -0,0 +1,141 @@
+package org.apache.maven.doxia.book.services.renderer;
+
+import org.apache.maven.doxia.Doxia;
+import org.apache.maven.doxia.book.BookDoxiaException;
+import org.apache.maven.doxia.book.context.BookContext;
+import org.apache.maven.doxia.book.context.IndexEntry;
+import org.apache.maven.doxia.book.model.Book;
+import org.apache.maven.doxia.book.model.Chapter;
+import org.apache.maven.doxia.book.model.Section;
+import org.apache.maven.doxia.book.services.renderer.xdoc.XdocBookSink;
+import org.apache.maven.doxia.editor.io.DebugSink;
+import org.apache.maven.doxia.editor.io.PipelineSink;
+import org.apache.maven.doxia.parser.ParseException;
+import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
+import org.apache.maven.doxia.sink.Sink;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ * @plexus.component role-hint="xdoc"
+ */
+public class XdocBookRenderer
+    extends AbstractLogEnabled
+    implements BookRenderer
+{
+    /**
+     * @plexus.requirement
+     */
+    private Doxia doxia;
+
+    // ----------------------------------------------------------------------
+    // BookRenderer Implementation
+    // ----------------------------------------------------------------------
+
+    public void renderBook( BookContext context )
+        throws BookDoxiaException
+    {
+        Book book = context.getBook();
+
+        if ( !context.getOutputDirectory().exists() )
+        {
+            if ( !context.getOutputDirectory().mkdirs() )
+            {
+                throw new BookDoxiaException(
+                    "Could not make directory: " + context.getOutputDirectory().getAbsolutePath() + "." );
+            }
+        }
+
+        // -----------------------------------------------------------------------
+        //
+        // -----------------------------------------------------------------------
+
+        renderBook( book, context );
+    }
+
+    // -----------------------------------------------------------------------
+    // Private
+    // -----------------------------------------------------------------------
+
+    private void renderBook( Book book, BookContext context )
+        throws BookDoxiaException
+    {
+        Iterator ii = context.getIndex().getChildEntries().iterator();
+
+        for ( Iterator it = book.getChapters().iterator(); it.hasNext(); )
+        {
+            Chapter chapter = (Chapter) it.next();
+
+            renderChapter( chapter, context, (IndexEntry) ii.next() );
+        }
+    }
+
+    private void renderChapter( Chapter chapter, BookContext context, IndexEntry chapterIndex )
+        throws BookDoxiaException
+    {
+        Iterator ii = chapterIndex.getChildEntries().iterator();
+
+        for ( Iterator it = chapter.getSections().iterator(); it.hasNext(); )
+        {
+            Section section = (Section) it.next();
+
+            renderSection( context, section, (IndexEntry) ii.next() );
+        }
+    }
+
+    private void renderSection( BookContext context, Section section, IndexEntry sectionIndex )
+        throws BookDoxiaException
+    {
+        try
+        {
+            FileWriter writer = new FileWriter( context.getOutputDirectory() + "/" + section.getId() + ".xml" );
+
+            XdocBookSink sink = new XdocBookSink( writer, sectionIndex );
+
+            BookContext.BookFile bookFile = (BookContext.BookFile) context.getFiles().get( section.getId() );
+
+            if ( bookFile == null )
+            {
+                throw new BookDoxiaException(
+                    "No document that matches section with id=" + section.getId() + "." );
+            }
+
+            List pipeline = new ArrayList();
+            pipeline.add( DebugSink.newInstance() );
+            pipeline.add( sink );
+            Sink pipelineSink = PipelineSink.newInstance( pipeline );
+
+            try
+            {
+                doxia.parse( new FileReader( bookFile.getFile() ), bookFile.getParserId(), pipelineSink );
+            }
+            catch ( ParserNotFoundException e )
+            {
+                throw new BookDoxiaException( "Parser not found: " + bookFile.getParserId() + ".", e );
+            }
+            catch ( ParseException e )
+            {
+                throw new BookDoxiaException(
+                    "Error while parsing document: " + bookFile.getFile().getAbsolutePath() + ".", e );
+            }
+            catch ( FileNotFoundException e )
+            {
+                throw new BookDoxiaException(
+                    "Could not find document: " + bookFile.getFile().getAbsolutePath() + ".", e );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new BookDoxiaException( "Error while rendering book.", e );
+        }
+    }
+}

Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/XdocBookSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/XdocBookSink.java?rev=420875&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/XdocBookSink.java (added)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/XdocBookSink.java Tue Jul 11 07:43:35 2006
@@ -0,0 +1,148 @@
+package org.apache.maven.doxia.book.services.renderer.xdoc;
+
+import org.apache.maven.doxia.module.xdoc.XdocSink;
+import org.apache.maven.doxia.book.context.IndexEntry;
+
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class XdocBookSink
+    extends XdocSink
+{
+    private IndexEntry indexEntry;
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    public XdocBookSink( Writer out, IndexEntry indexEntry )
+    {
+        super( out );
+
+        this.indexEntry = indexEntry;
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    public void head()
+    {
+        resetState();
+
+        headFlag = true;
+
+        markup( "<?xml version=\"1.0\" ?>" + EOL );
+
+        markup( "<document>" + EOL );
+
+        markup( "<properties>" + EOL );
+
+    }
+
+    public void head_()
+    {
+        headFlag = false;
+
+        markup( "</properties>" + EOL );
+    }
+
+    public void author_()
+    {
+        if ( buffer.length() > 0 )
+        {
+            markup( "<author>" );
+            content( buffer.toString() );
+            markup( "</author>" + EOL );
+            buffer = new StringBuffer();
+        }
+    }
+
+    public void date_()
+    {
+    }
+
+    public void body()
+    {
+        markup( "<body>" + EOL );
+
+        markup( "<table width=\"100%\" align=\"center\">" + EOL );
+        markup( "<tr>" + EOL );
+
+        // -----------------------------------------------------------------------
+        // Prev
+        // -----------------------------------------------------------------------
+
+        IndexEntry prevEntry = indexEntry.getPrevEntry();
+
+        String string;
+
+        if ( prevEntry != null )
+        {
+            string = "Previous: <a href='" + prevEntry.getId() + ".html'>" + prevEntry.getTitle() + "</a>";
+        }
+        else
+        {
+            string = "&lt;first section&gt;";
+        }
+
+        markup( "<td><div align='left'>" + string + "</div></td>" + EOL );
+
+        // -----------------------------------------------------------------------
+        // Parent
+        // -----------------------------------------------------------------------
+
+        IndexEntry parent = indexEntry.getParent();
+
+        markup( "<td><div align='center'>Up: <a href='" + parent.getId() + ".html'>" + parent.getTitle() + "</a></div></td>" + EOL );
+
+        // -----------------------------------------------------------------------
+        //
+        // -----------------------------------------------------------------------
+
+        IndexEntry nextEntry = indexEntry.getNextEntry();
+
+        if ( nextEntry != null )
+        {
+            string = "Next: <a href='" + nextEntry.getId() + ".html'>" + nextEntry.getTitle() + "</a>";
+        }
+        else
+        {
+            string = "&lt;last section&gt;";
+        }
+
+        markup( "<td><div align='right'>" + string + "</div></td>" + EOL );
+
+        // -----------------------------------------------------------------------
+        //
+        // -----------------------------------------------------------------------
+
+        markup( "</tr>" + EOL );
+        markup( "</table>" + EOL );
+    }
+
+    public void body_()
+    {
+        markup( "</body>" + EOL );
+
+        markup( "</document>" + EOL );
+
+        out.flush();
+
+        resetState();
+    }
+
+    public void title_()
+    {
+        if ( buffer.length() > 0 )
+        {
+            markup( "<title>" );
+            content( "Book " + buffer.toString() );
+            markup( "</title>" + EOL );
+            buffer = new StringBuffer();
+        }
+    }
+}

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/BookRendererTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/BookRendererTest.java?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/BookRendererTest.java (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/BookRendererTest.java Tue Jul 11 07:43:35 2006
@@ -20,12 +20,10 @@
 
         File book1 = getTestFile( "src/test/resources/book-1.xml" );
 
-        File itextOutput = getTestFile( "target/book-1-itext" );
-        File xhtmlOutput = getTestFile( "target/book-1-xhtml" );
-
         List files = FileUtils.getFiles( getTestFile( "src/test/resources/book-1" ), "**/*.apt, **/*.xml", "" );
 
-        doxia.renderBook( book1, "itext", files, itextOutput );
-//        doxia.renderBook( book1, "xhtml", files, xhtmlOutput );
+//        doxia.renderBook( book1, "itext", files, getTestFile( "target/book-1-itext" ) );
+//        doxia.renderBook( book1, "xhtml", files, getTestFile( "target/book-1-xhtml" ) );
+        doxia.renderBook( book1, "xdoc", files, getTestFile( "target/book-1-xdoc" ) );
     }
 }

Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/context/IndexEntryTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/context/IndexEntryTest.java?rev=420875&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/context/IndexEntryTest.java (added)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/java/org/apache/maven/doxia/book/context/IndexEntryTest.java Tue Jul 11 07:43:35 2006
@@ -0,0 +1,50 @@
+package org.apache.maven.doxia.book.context;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class IndexEntryTest
+    extends TestCase
+{
+    public void testIndexEntry()
+    {
+        IndexEntry root = new IndexEntry( null );
+
+        assertIndexEntry( root, null, 0, null, null );
+
+        // -----------------------------------------------------------------------
+        // Chapter 1
+        // -----------------------------------------------------------------------
+
+        IndexEntry chapter1 = new IndexEntry( root, "chapter-1" );
+
+        assertIndexEntry( root, null, 1, null, null );
+
+        assertIndexEntry( chapter1, root, 0, null, null );
+
+        // -----------------------------------------------------------------------
+        // Chapter 2
+        // -----------------------------------------------------------------------
+
+        IndexEntry chapter2 = new IndexEntry( root, "chapter-2" );
+
+        assertIndexEntry( root, null, 2, null, null );
+
+        assertIndexEntry( chapter1, root, 0, null, chapter2 );
+        assertIndexEntry( chapter2, root, 0, chapter1, null );
+    }
+
+    private void assertIndexEntry( IndexEntry entry, IndexEntry parent, int childCount, IndexEntry prevEntry, IndexEntry nextEntry )
+    {
+        assertEquals( parent, entry.getParent() );
+
+        assertEquals( childCount, entry.getChildEntries().size() );
+
+        assertEquals( prevEntry, entry.getPrevEntry() );
+
+        assertEquals( nextEntry, entry.getNextEntry() );
+    }
+}

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-1.apt
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-1.apt?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-1.apt (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-1.apt Tue Jul 11 07:43:35 2006
@@ -4,7 +4,7 @@
  Trygve
  -----
 
-Paragraph 1
+Subsection 1
 
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec sagittis malesuada nisi. Aliquam orci eros, vestibulum
  eu, placerat et, pretium sed, nisi. Proin consequat. Praesent faucibus sem id arcu hendrerit nonummy. Aliquam blandit
@@ -13,7 +13,14 @@
  sit amet, purus. Fusce erat. Proin ullamcorper imperdiet est. Morbi sit amet dui. Fusce bibendum auctor augue. Sed leo
  sapien, vehicula ac, nonummy id, cursus at, nulla. Ut sed purus.
 
-Paragraph 2
+* Subsubsection 1
+
+ Suspendisse sagittis metus nec leo. Suspendisse velit. Phasellus ipsum dolor, porttitor ut1, varius id, scelerisque
+ vel, ligula. Aliquam tempor sem in pede tincidunt nonummy. Vestibulum et nulla. Nunc et dolor a risus porttitor tem
+ pus. Sed felis arcu, consectetuer non, imperdiet sollicitudin, ullamcorper vitae, nulla. Vestibulum ante ipsum primis
+ in faucibus.
+
+Subsection 2
 
  Duis eget libero aliquet quam ultrices malesuada. Donec molestie dignissim nunc. Curabitur turpis. Suspendisse a nibh
  ut elit vulputate ultrices. Etiam nulla erat, nonummy vel, fringilla at, scelerisque non, ante. Suspendisse adipiscing
@@ -22,7 +29,7 @@
  urna in nisi sagittis facilisis. Cras nibh. Aliquam purus. Donec convallis congue libero. Nulla feugiat. Nulla massa
  libero, consectetuer ac, aliquet ac, consequat eu, purus. Pellentesque eleifend pretium augue.
 
-Paragraph 3
+Subsection 3
 
  Integer auctor, nisi ut convallis imperdiet, ligula diam sollicitudin dolor, porttitor mattis urna sapien at velit.
  Fusce vestibulum, neque nec malesuada tempor, tortor nisi accumsan purus, quis faucibus metus elit ac urna. Aliquam
@@ -31,7 +38,7 @@
  Nulla sed leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Fusce
  suscipit. Sed sit amet diam ac ante tincidunt ornare. Sed sodales vestibulum quam. Fusce accumsan. Ut ut mi.
 
-Paragraph 4
+Subsection 4
 
  Maecenas tincidunt lobortis nunc. Phasellus euismod diam sit amet felis. Donec lorem metus, vulputate vitae, ornare
  vel, molestie sit amet, pede. In erat velit, adipiscing sed, varius in, interdum cursus, enim. Quisque dolor ante,
@@ -43,7 +50,7 @@
  fringilla. Suspendisse vel nibh. Sed sit amet lacus quis massa tincidunt elementum. Ut ut augue vitae ligula dapibus
  aliquam.
 
-Paragraph 5
+Subsection 5
 
  Fusce non eros non lectus venenatis bibendum. Nullam pharetra. Nunc commodo pede et metus. Pellentesque habitant morbi
  tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum imperdiet nisl nec nulla. Morbi congue

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-2.apt
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-2.apt?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-2.apt (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-2.apt Tue Jul 11 07:43:35 2006
@@ -1,3 +1,9 @@
+ -----
+ Section 2
+ -----
+ Trygve
+ -----
+
 Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC
 
  Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam,

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-3.apt
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-3.apt?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-3.apt (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-3.apt Tue Jul 11 07:43:35 2006
@@ -1,3 +1,9 @@
+ -----
+ Section 3
+ -----
+ Trygve
+ -----
+
 1914 translation by H. Rackham
 
  But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will

Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-4.apt
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-4.apt?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-4.apt (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/test/resources/book-1/section-4.apt Tue Jul 11 07:43:35 2006
@@ -1,3 +1,9 @@
+ -----
+ Section 4
+ -----
+ Trygve
+ -----
+
 Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC
 
  At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque

Modified: maven/doxia/trunk/doxia-sandbox/doxia-editor/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-editor/pom.xml?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-editor/pom.xml (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-editor/pom.xml Tue Jul 11 07:43:35 2006
@@ -7,6 +7,7 @@
   </parent>
   <artifactId>doxia-editor</artifactId>
   <version>1.0-alpha-1-SNAPSHOT</version>
+  <name>Doxia Swing Editor</name>
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>

Modified: maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/pom.xml?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/pom.xml (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/pom.xml Tue Jul 11 07:43:35 2006
@@ -16,6 +16,16 @@
       <version>2.0</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven.reporting</groupId>
+      <artifactId>maven-reporting-api</artifactId>
+      <version>2.0.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.reporting</groupId>
+      <artifactId>maven-reporting-impl</artifactId>
+      <version>2.0.2</version>
+    </dependency>
+    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>doxia-book</artifactId>
       <version>1.0-alpha-1-SNAPSHOT</version>

Modified: maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java (original)
+++ maven/doxia/trunk/doxia-sandbox/doxia-maven-plugin/src/main/java/org/apache/maven/doxia/plugin/DoxiaRenderBooksMojo.java Tue Jul 11 07:43:35 2006
@@ -39,7 +39,8 @@
     private File basedir;
 
     /**
-     * @parameter expression="${project.reporting.outputDirectory}"
+     * @p-arameter expression="${project.reporting.outputDirectory}"
+     * @parameter expression="${project.build.directory}/generated-site"
      */
     private File outputDirectory;
 

Added: maven/doxia/trunk/doxia-sandbox/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/pom.xml?rev=420875&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-sandbox/pom.xml (added)
+++ maven/doxia/trunk/doxia-sandbox/pom.xml Tue Jul 11 07:43:35 2006
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>doxia</artifactId>
+    <groupId>org.apache.maven.doxia</groupId>
+    <version>1.0-alpha-9-SNAPSHOT</version>
+  </parent>
+  <artifactId>doxia-sandbox</artifactId>
+  <name>Doxia Sandbox</name>
+  <packaging>pom</packaging>
+  <modules>
+    <module>doxia-book</module>
+    <module>doxia-editor</module>
+    <module>doxia-maven-plugin</module>
+  </modules>
+</project>

Modified: maven/doxia/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/pom.xml?rev=420875&r1=420874&r2=420875&view=diff
==============================================================================
--- maven/doxia/trunk/pom.xml (original)
+++ maven/doxia/trunk/pom.xml Tue Jul 11 07:43:35 2006
@@ -62,6 +62,7 @@
     <module>doxia-site-renderer</module>
     <module>doxia-decoration-model</module>
     <module>doxia-modules</module>
+    <module>doxia-sandbox</module>
   </modules>
   <distributionManagement>
     <site>