*/
private void parse( String fullPathDoc, SiteModule module, File outputITextFile )
throws DocumentRendererException, IOException
{
Writer writer = WriterFactory.newXmlWriter( outputITextFile );
ITextSink sink = (ITextSink) new ITextSinkFactory().createSink( writer );
sink.setClassLoader( new URLClassLoader( new URL[] { outputITextFile.getParentFile().toURI().toURL() } ) );
Reader reader = null;
try
{
File f = new File( fullPathDoc );
if ( XmlUtil.isXml( f ) )
{
reader = ReaderFactory.newXmlReader( f );
}
else
{
// TODO Platform dependent?
reader = ReaderFactory.newPlatformReader( f );
}
System.setProperty( "itext.basedir", outputITextFile.getParentFile().getAbsolutePath() );
doxia.parse( reader, module.getParserId(), sink );
}
catch ( ParserNotFoundException e )
{
throw new DocumentRendererException( "Error getting a parser for '"
+ fullPathDoc + "': " + e.getMessage() );
}
catch ( ParseException e )
{
throw new DocumentRendererException( "Error parsing '"
+ fullPathDoc + "': line [" + e.getLineNumber() + "] " + e.getMessage(), e );
}
finally
{
IOUtil.close( reader );
sink.flush();
sink.close();
IOUtil.close( writer );
System.getProperties().remove( "itext.basedir" );
}