This not my FO document, but is a *standard one* in the examples folder
provided with the fop distribution. I tried removing the enclosing
<fo:wrapper> from the example fo document and it generated a pdf without
problems.
The following patch file seems to fix the ClassCastException and
a pdf rendition of examples/fo/advanced/cid-fonts.fo is seemingly
generated correctly. I ran all the junit-layout tests and they all passed.
--- snip ---
C:/workspace/fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
===================================================================
---
C:/workspace/fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
(revision 497065)
+++
C:/workspace/fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
(working copy)
@@ -69,11 +69,11 @@
int flowBPD = (int) getCurrentPV().getBodyRegion().getBPD();
// currently active LM
- BlockLevelLayoutManager curLM;
+ LayoutManager curLM;
LinkedList returnedList;
LinkedList returnList = new LinkedList();
- while ((curLM = ((BlockLevelLayoutManager) getChildLM())) !=
null) {
+ while ((curLM = getChildLM()) != null) {
if (curLM instanceof InlineLevelLayoutManager) {
log.error("inline area not allowed under flow -
ignoring");
curLM.setFinished(true);
--- snip ---
Please try it out (with and without the patch).
But this doesn't fix the SERERE error messages ... I am still learning
FO and don't understand all the layout stuff yet so I'm a little
hesitant to go in and try and fix this myself. The error output "FOText
w/o Block ancestor" resides in this method in org.apache.fop.fo.FObjMixed.
/**
* Adds accumulated text as one FOText instance, unless
* the one instance's char array contains more than
* Short.MAX_VALUE characters. In the latter case the
* instance is split up into more manageable chunks.
*
* @throws FOPException if there is a problem during processing
*/
protected void flushText() throws FOPException {
if (ft != null) {
FOText lft = ft;
/* make sure nested calls to itself have no effect */
ft = null;
FOText tmpText;
int indexStart = 0;
int indexEnd = (lft.ca.length > Short.MAX_VALUE
? Short.MAX_VALUE : lft.ca.length) - 1;
int charCount = 0;
short tmpSize;
while (charCount < lft.ca.length) {
tmpSize = (short) (indexEnd - indexStart + 1);
charCount += tmpSize;
tmpText = (FOText) lft.clone(this, false);
tmpText.ca = new char[tmpSize];
tmpText.startIndex = 0;
tmpText.endIndex = tmpSize;
System.arraycopy(lft.ca, indexStart,
tmpText.ca, 0, indexEnd - indexStart + 1);
if (getNameId() == FO_BLOCK) {
tmpText.createBlockPointers((org.apache.fop.fo.flow.Block) this);
this.lastFOTextProcessed = tmpText;
} else if (getNameId() != FO_MARKER
&& getNameId() != FO_TITLE
&& getNameId() != FO_BOOKMARK_TITLE) {
FONode fo = parent;
int foNameId = fo.getNameId();
while (foNameId != FO_BLOCK
&& foNameId != FO_MARKER
&& foNameId != FO_TITLE
&& foNameId != FO_BOOKMARK_TITLE
&& foNameId != FO_PAGE_SEQUENCE) {
fo = fo.getParent();
foNameId = fo.getNameId();
}
if (foNameId == FO_BLOCK) {
tmpText.createBlockPointers((org.apache.fop.fo.flow.Block) fo);
((FObjMixed) fo).lastFOTextProcessed = tmpText;
} else if (foNameId == FO_PAGE_SEQUENCE) {
log.error("Could not create block pointers."
+ " FOText w/o Block ancestor.");
}
}
tmpText.endOfNode();
addChildNode(tmpText);
indexStart = indexEnd + 1;
indexEnd = (((lft.ca.length - charCount) < Short.MAX_VALUE)
? lft.ca.length : charCount + Short.MAX_VALUE) - 1;
}
}
}
I think there might be some confusion caused by the fo:wrapper though.
If the enclosing <fo:wrapper> is removed or itself enclosed by a <block>
then the renderer generates the pdf.
Wrapper is a neutral object container and should be allowed where
#PCDATA, %block;, or %inline are (see http://www.w3.org/TR/xsl/#d0e6532).
Adrian.
Andreas L Delmelle wrote:
Hi,
Please check thoroughly if you have stray FOText in your document, for
example text as direct child of the flow...
Your assumption is almost correct, although it doesn't necessarily mean
'text without block parent', but more general:
If no fo:block is found on the ancestor:: axis, then this message appears.
Cheers,
Andreas
Just tried rendering a pdf using examples/fo/advanced/cid-fonts.fo
on the fop latest trunk (0.93) and got the following exception/errors :-
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FObjMixed flushText
SEVERE: Could not create block pointers. FOText w/o Block ancestor.
18-Jan-2007 17:50:27 org.apache.fop.fo.FONode attributeWarning
WARNING: Warning(372/14): fo:table, table-layout="auto" is currently not
supported by FOP
18-Jan-2007 17:50:27 org.apache.fop.cli.Main startFOP
SEVERE: Exception
java.lang.ClassCastException
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:168)
at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
at org.apache.fop.cli.Main.startFOP(Main.java:166)
at org.apache.fop.cli.Main.main(Main.java:197)
---------
java.lang.ClassCastException
at
org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:76)
at
org.apache.fop.layoutmgr.PageSequenceLayoutManager$PageBreaker.getNextKnuthElements(PageSequenceLayoutManager.java:272)
at
org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:554)
at
org.apache.fop.layoutmgr.PageSequenceLayoutManager$PageBreaker.getNextBlockList(PageSequenceLayoutManager.java:264)
at
org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:301)
at
org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:263)
at
org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:157)
at
org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:385)
at
org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:148)
at
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:378)
at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:194)
at
org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1050)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
at
org.apache.xerces.impl.dtd.XMLNSDTDValidator.endNamespaceScope(Unknown
Source)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown
Source)
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:452)
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
at org.apache.fop.cli.Main.startFOP(Main.java:166)
at org.apache.fop.cli.Main.main(Main.java:197)
I have had a look at cid-fonts.fo and couldn't see anything wrong with
the fo (was looking for the SEVERE error which I interpret as a text
child node without a block parent node).
Adrian.