in src/main/java/org/apache/maven/doxia/book/services/renderer/DocbookBookRenderer.java [65:154]
public void renderBook( BookContext context )
throws BookDoxiaException
{
BookModel book = context.getBook();
if ( !context.getOutputDirectory().exists() )
{
if ( !context.getOutputDirectory().mkdirs() )
{
throw new BookDoxiaException( "Could not make directory: "
+ context.getOutputDirectory().getAbsolutePath() + "." );
}
}
File bookFile = new File( context.getOutputDirectory(), book.getId() + ".xml" );
Writer fileWriter;
try
{
fileWriter = WriterFactory.newXmlWriter( bookFile );
}
catch ( IOException e )
{
throw new BookDoxiaException( "Error while opening file.", e );
}
// ----------------------------------------------------------------------
// Create the Dockbook File
// ----------------------------------------------------------------------
// TODO: Write out TOC?
DocBookBookSink sink = new DocBookBookSink( fileWriter );
try
{
sink.book();
// TODO: symmetrize bookHead?
if ( StringUtils.isNotEmpty( book.getTitle() ) )
{
sink.bookTitle();
sink.text( book.getTitle() );
sink.bookTitle_();
}
if ( StringUtils.isNotEmpty( book.getDate() ) )
{
sink.bookDate();
sink.text( book.getDate() );
sink.bookDate_();
}
if ( StringUtils.isNotEmpty( book.getAuthor() ) )
{
sink.bookAuthor();
sink.text( book.getAuthor() );
sink.bookAuthor_();
}
sink.bookHead_();
for ( Chapter chapter : book.getChapters() )
{
sink.chapter();
if ( StringUtils.isNotEmpty( chapter.getTitle() ) )
{
sink.chapterTitle();
sink.text( chapter.getTitle() );
sink.chapterTitle_();
}
renderChapter( chapter, context, sink );
sink.chapter_();
}
sink.book_();
}
finally
{
sink.flush();
sink.close();
IOUtil.close( fileWriter );
}
}