in src/main/java/org/apache/maven/doxia/book/services/renderer/XHtmlBookRenderer.java [64:132]
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() + ".xhtml" );
Writer fileWriter;
try
{
fileWriter = new FileWriter( bookFile );
}
catch ( IOException e )
{
throw new BookDoxiaException( "Error while opening file.", e );
}
XhtmlBookSink sink = new XhtmlBookSink( fileWriter,
new RenderingContext( context.getOutputDirectory(), bookFile.getAbsolutePath() ) );
try
{
sink.bookHead();
sink.bookTitle();
sink.text( context.getBook().getTitle() );
sink.bookTitle_();
sink.bookAuthor();
sink.text( context.getBook().getAuthor() );
sink.bookAuthor_();
sink.bookDate();
sink.text( context.getBook().getDate() );
sink.bookDate_();
sink.bookHead_();
sink.bookBody();
int chapterNumber = 1;
for ( Chapter chapter : book.getChapters() )
{
sink.sectionTitle();
sink.text( Integer.toString( chapterNumber ) + ". " + chapter.getTitle() );
sink.sectionTitle_();
renderChapter( sink, chapter, context );
chapterNumber++;
}
sink.bookBody_();
}
finally
{
sink.flush();
sink.close();
IOUtil.close( fileWriter );
}
}