svn commit: r782910 - /maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java
Author: ltheussl Date: Tue Jun 9 08:21:09 2009 New Revision: 782910 URL: http://svn.apache.org/viewvc?rev=782910&view=rev Log: Remove anchor from ignorables (r782653) Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java?rev=782910&r1=782909&r2=782910&view=diff == --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java (original) +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java Tue Jun 9 08:21:09 2009 @@ -757,8 +757,7 @@ private boolean ignorable( String name ) { -return name.equals( SimplifiedDocbookMarkup.ANCHOR_TAG.toString() ) -|| name.equals( SimplifiedDocbookMarkup.IMAGEOBJECT_TAG.toString() ) +return name.equals( SimplifiedDocbookMarkup.IMAGEOBJECT_TAG.toString() ) || name.equals( SimplifiedDocbookMarkup.PHRASE_TAG.toString() ) || name.equals( SimplifiedDocbookMarkup.TEXTOBJECT_TAG.toString() ); }
svn commit: r782949 - in /maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test: java/org/apache/maven/doxia/docrenderer/DocumentRendererTest.java resources/site/pdf.xml
Author: vsiveton Date: Tue Jun 9 10:48:57 2009 New Revision: 782949 URL: http://svn.apache.org/viewvc?rev=782949&view=rev Log: o more dynamic assert Modified: maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test/java/org/apache/maven/doxia/docrenderer/DocumentRendererTest.java maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test/resources/site/pdf.xml Modified: maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test/java/org/apache/maven/doxia/docrenderer/DocumentRendererTest.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test/java/org/apache/maven/doxia/docrenderer/DocumentRendererTest.java?rev=782949&r1=782948&r2=782949&view=diff == --- maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test/java/org/apache/maven/doxia/docrenderer/DocumentRendererTest.java (original) +++ maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test/java/org/apache/maven/doxia/docrenderer/DocumentRendererTest.java Tue Jun 9 10:48:57 2009 @@ -20,11 +20,14 @@ */ import java.io.File; +import java.util.Iterator; +import java.util.List; import org.apache.maven.doxia.docrenderer.pdf.PdfRenderer; import org.apache.maven.doxia.document.DocumentModel; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.StringUtils; /** * @author mailto:vincent.sive...@gmail.com";>Vincent Siveton @@ -94,21 +97,27 @@ outputDirectory.mkdirs(); docRenderer = (PdfRenderer) lookup( PdfRenderer.ROLE, implementation ); +assertNotNull( docRenderer ); docRenderer.render( siteDirectoryFile, outputDirectory, null ); -assertTrue( new File( outputDirectory, "faq.pdf" ).exists() ); -assertTrue( new File( outputDirectory, "faq.pdf" ).length() > 0 ); -assertTrue( new File( outputDirectory, "index.pdf" ).exists() ); -assertTrue( new File( outputDirectory, "index.pdf" ).length() > 0 ); -assertTrue( new File( outputDirectory, "overview.pdf" ).exists() ); -assertTrue( new File( outputDirectory, "overview.pdf" ).length() > 0 ); -assertTrue( new File( outputDirectory, "resources.pdf" ).exists() ); -assertTrue( new File( outputDirectory, "resources.pdf" ).length() > 0 ); -assertTrue( new File( outputDirectory, "references" + File.separator + "fml-format.pdf" ).exists() ); -assertTrue( new File( outputDirectory, "references" + File.separator + "fml-format.pdf" ).length() > 0 ); -assertTrue( new File( outputDirectory, "references" + File.separator + "xdoc-format.pdf" ).exists() ); -assertTrue( new File( outputDirectory, "references" + File.separator + "xdoc-format.pdf" ).length() > 0 ); +List files = +FileUtils.getFileNames( new File( siteDirectoryFile, "apt" ), "**/*.apt", +FileUtils.getDefaultExcludesAsString(), false ); +files.addAll( FileUtils.getFileNames( new File( siteDirectoryFile, "fml" ), "**/*.fml", + FileUtils.getDefaultExcludesAsString(), false ) ); +files.addAll( FileUtils.getFileNames( new File( siteDirectoryFile, "xdoc" ), "**/*.xml", + FileUtils.getDefaultExcludesAsString(), false ) ); + +for ( Iterator it = files.iterator(); it.hasNext(); ) +{ +String relativeFile = it.next().toString(); +String relativePdf = StringUtils.replace( relativeFile, FileUtils.getExtension( relativeFile ), "pdf" ); +File pdf = new File( outputDirectory, relativePdf ); + +assertTrue( pdf.exists() ); +assertTrue( pdf.length() > 0 ); +} } private void renderAggregatedImpl( String implementation ) @@ -122,12 +131,16 @@ outputDirectory.mkdirs(); docRenderer = (PdfRenderer) lookup( PdfRenderer.ROLE, implementation ); +assertNotNull( docRenderer ); DocumentModel descriptor = docRenderer.readDocumentModel( new File( siteDirectoryFile, "pdf.xml" ) ); assertNotNull( descriptor ); + docRenderer.render( siteDirectoryFile, outputDirectory, descriptor ); -assertTrue( new File( outputDirectory, descriptor.getOutputName() + ".pdf" ).exists() ); -assertTrue( new File( outputDirectory, descriptor.getOutputName() + ".pdf" ).length() > 0 ); +File pdf = new File( outputDirectory, descriptor.getOutputName() + ".pdf" ); + +assertTrue( pdf.exists() ); +assertTrue( pdf.length() > 0 ); } } Modified: maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test/resources/site/pdf.xml URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/test/resources/site/pdf.xml?rev=782949&r1=782948&r2=782949&view=diff =
svn commit: r782952 - /maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java
Author: vsiveton Date: Tue Jun 9 10:52:14 2009 New Revision: 782952 URL: http://svn.apache.org/viewvc?rev=782952&view=rev Log: o delete on exit tmp itext files o use a document builder static field Modified: maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java Modified: maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java?rev=782952&r1=782951&r2=782952&view=diff == --- maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java (original) +++ maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java Tue Jun 9 10:52:14 2009 @@ -35,6 +35,7 @@ import java.util.Locale; import java.util.Map; +import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; @@ -88,9 +89,21 @@ /** The DocumentBuilderFactory. */ private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance(); +/** The DocumentBuilder. */ +private static final DocumentBuilder DOCUMENT_BUILDER; + static { TRANSFORMER_FACTORY.setErrorListener( new DefaultErrorHandler() ); + +try +{ +DOCUMENT_BUILDER = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder(); +} +catch ( ParserConfigurationException e ) +{ +throw new RuntimeException( "Error building document :" + e.getMessage() ); +} } /** {...@inheritdoc} */ @@ -260,17 +273,7 @@ private Document generateDocument( List iTextFiles ) throws DocumentRendererException, IOException { -Document document; - -try -{ -document = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().newDocument(); -} -catch ( ParserConfigurationException e ) -{ -throw new DocumentRendererException( "Error building document :" + e.getMessage() ); -} - +Document document = DOCUMENT_BUILDER.newDocument(); document.appendChild( document.createElement( ElementTags.ITEXT ) ); // Used only to set a root for ( int i = 0; i < iTextFiles.size(); i++ ) @@ -281,16 +284,12 @@ try { -iTextDocument = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().parse( iTextFile ); +iTextDocument = DOCUMENT_BUILDER.parse( iTextFile ); } catch ( SAXException e ) { throw new DocumentRendererException( "SAX Error : " + e.getMessage() ); } -catch ( ParserConfigurationException e ) -{ -throw new DocumentRendererException( "Error parsing configuration : " + e.getMessage() ); -} // Only one chapter per doc Node chapter = iTextDocument.getElementsByTagName( ElementTags.CHAPTER ).item( 0 ); @@ -507,6 +506,7 @@ String outputITextName = key.substring( 0, key.lastIndexOf( "." ) + 1 ) + "xml"; File outputITextFileTmp = new File( outputDirectory, outputITextName ); +outputITextFileTmp.deleteOnExit(); if ( !outputITextFileTmp.getParentFile().exists() ) { outputITextFileTmp.getParentFile().mkdirs(); @@ -563,6 +563,7 @@ { String outputITextName = doc.substring( 0, doc.lastIndexOf( "." ) + 1 ) + "xml"; File outputITextFileTmp = new File( outputDirectory, outputITextName ); +outputITextFileTmp.deleteOnExit(); if ( !outputITextFileTmp.getParentFile().exists() ) { outputITextFileTmp.getParentFile().mkdirs(); @@ -606,7 +607,7 @@ } else { -return new File( f.getAbsolutePath() ).toURL().toString(); +return f.toURL().toString(); } } catch ( MalformedURLException e1 )