in src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java [392:442]
private void renderSection( BookContext context, Section section, IndexEntry sectionIndex )
throws BookDoxiaException
{
try
{
Writer writer = WriterFactory.newXmlWriter( new File( context.getOutputDirectory()
+ "/" + section.getId() + ".xml" ) );
SectionXdocBookSink sink = new SectionXdocBookSink( writer, sectionIndex, i18n, context.getLocale() );
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() + "." );
}
Reader reader = null;
try
{
reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() );
doxia.parse( reader, bookFile.getParserId(), sink );
}
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 );
}
finally
{
sink.flush();
sink.close();
IOUtil.close( reader );
IOUtil.close( writer );
}
}
catch ( IOException e )
{
throw new BookDoxiaException( "Error while rendering book.", e );
}
}