Author: vsiveton Date: Sat Aug 15 12:18:40 2009 New Revision: 804464 URL: http://svn.apache.org/viewvc?rev=804464&view=rev Log: DOXIA-357: NoSuchElementException with a table caption
o improved table caption o updated test case Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java?rev=804464&r1=804463&r2=804464&view=diff ============================================================================== --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java (original) +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java Sat Aug 15 12:18:40 2009 @@ -112,6 +112,9 @@ private XMLWriter tableCaptionXMLWriter = null; + /** The table caption */ + private String tableCaption = null; + /** Map of warn messages with a String as key to describe the error type and a Set as value. * Using to reduce warn messages. */ protected Map warnMessages; @@ -921,14 +924,6 @@ /** {...@inheritdoc} */ public void table_() { - String tableCaption = null; - if ( tableCaptionXMLWriter != null ) - { - tableCaption = tableCaptionWriter.toString(); - tableCaptionXMLWriter = null; - tableCaptionWriter = null; - } - String content = tableContentWriter.toString(); tableContentWriter = null; @@ -986,21 +981,6 @@ /** {...@inheritdoc} */ public void tableRows_() { - String tableCaption = null; - if ( tableCaptionXMLWriter != null ) - { - tableCaption = tableCaptionWriter.toString(); - tableCaptionXMLWriter = null; - tableCaptionWriter = null; - - SinkEventAttributeSet atts = new SinkEventAttributeSet(); - atts.addAttribute( SinkEventAttributes.ALIGN, "center" ); - - paragraph( atts ); - write( tableCaption ); - paragraph_(); - } - this.cellJustif = null; this.isCellJustif = false; writeEndTag( TABLE_BODY_TAG ); @@ -1161,6 +1141,12 @@ /** {...@inheritdoc} */ public void tableCaption_() { + if ( tableCaptionXMLWriter != null ) + { + tableCaption = tableCaptionWriter.toString(); + tableCaptionXMLWriter = null; + tableCaptionWriter = null; + } // <fo:table-caption> is XSL-FO 1.0 standard but not implemented in FOP 0.95 //writeEndTag( TABLE_CAPTION_TAG ); } Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java?rev=804464&r1=804463&r2=804464&view=diff ============================================================================== --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java (original) +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoSinkTest.java Sat Aug 15 12:18:40 2009 @@ -449,11 +449,22 @@ html.append( "</tr>" ).append( EOL ); html.append( "</table>" ).append( EOL ); - StringWriter sw = new StringWriter(); + String fileName = "testTableCaption"; + + // first create fo + FoSink fosink = new FoSink( getTestWriter( fileName ) ); + fosink.beginDocument(); + SinkTestDocument.generateHead( fosink ); + + fosink.body(); XhtmlBaseParser parser = new XhtmlBaseParser(); - Sink sink = createSink( sw ); - parser.parse( new StringReader( html.toString() ), sink ); - sink.close(); - assertTrue( true ); + parser.parse( new StringReader( html.toString() ), fosink ); + fosink.body_(); + + fosink.endDocument(); + fosink.close(); + + // then generate PDF + fo2pdf( fileName ); } }