Hi all,
I'm trying to create some documentation using Asciidoctor which works pretty okay. However, now I want to transform the document into PDF, and using the following command, I turn it into XML: asciidoctor -b docbook -d book basic_struture.adoc After that, I do a ./fopub basic_structure.xml, and I'm greeted with an error: org.apache.fop.fo.ValidationException: "fo:block" is not a valid child of "fo:root"! (No context info available) at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38) at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:58) at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175) at com.sun.proxy.$Proxy4.invalidChild(Unknown Source) at org.apache.fop.fo.FONode.invalidChildError(FONode.java:561) at org.apache.fop.fo.FONode.invalidChildError(FONode.java:537) at org.apache.fop.fo.pagination.Root.validateChildNode(Root.java:159) at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:265) at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:175) at org.apache.xml.serializer.ToXMLSAXHandler.closeStartTag(ToXMLSAXHandler.java:205) at org.apache.xml.serializer.ToSAXHandler.flushPending(ToSAXHandler.java:291) at org.apache.xml.serializer.ToXMLSAXHandler.startPrefixMapping(ToXMLSAXHandler.java:349) at org.apache.xml.serializer.ToXMLSAXHandler.startPrefixMapping(ToXMLSAXHandler.java:319) at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:623) Any suggestions? Thanks! Erik basic_struture.adocbasic_struture.xml |
Administrator
|
Erik, I've run into this problem a couple times myself. It usually traces back to a validation error in the DocBook, specifically regarding preamble content (i.e., content that comes before a level-0 or level-1 section).
The fopub script does not run the DTD validator on the generated DocBook, which is why you see a cryptic XML-FO error instead of a clearer DTD validation error. I suppose we could enable DTD validation to the fopub script (if the option is not already there...I can't recall). My recommendation in general is to run a validator on the DocBook generated by Asciidoctor before running it through fopub. You can run the validator using: $ xmllint --valid --noout basic_structure.xml
In your case, you have a warning before the first part, chapter or section. element book: validity error : Element book content does not follow the DTD, expecting ((title , subtitle? , titleabbrev?)? , bookinfo? , (dedication | toc | lot | glossary | bibliography | preface | chapter | reference | part | article | appendix | index | setindex | colophon)*), got (bookinfo warning chapter )
</book> This is not permitted by DocBook and, in turn, generates by XML FO. In your case, you can solve the problem by simply nesting the warning in a chapter title. ```asciidoc == Author Notes [WARNING] ==== Grails currently does not work correctly with Java 8. If you are using Mac, you can switch to Java 7 by executing the following command:
[source] export JAVA_HOME=$(/usr/libexec/java_home -v 1.7) ==== [[setup-instructions-for-grails]] == Grails Basics
``` NOTE: I strongly recommend using single-line section titles instead of the underline variant. It's somewhat rare to get validation errors in DocBook content generated from AsciiDoc, with the exception of section content. That's because DocBook is most sensitive to the high-level structural elements (i.e., the section structure).
For reference, I'll cite another example that I've run into. When using the book doctype, level-0 sections are treated as parts. In DocBook, any content in a part that precedes the first level-1 section (a chapter) must be a paragraph with the style "partintro" or content wrapped in a open block with the style "partintro".
Here's an example of non-validating content (inside the fenced code): ```asciidoc = Document Title :doctype: book
= First Part intro content more intro content == First Chapter chapter content ``` Here's a revised version of that content that does validate: ```asciidoc = Document Title :doctype: book = First Part
[partintro] -- intro content more intro content -- == First Chapter chapter content ``` Notice I've enveloped the content after the "First Part" section in an open block with the style "partintro". This would also make a good FAQ, though I'm thinking that perhaps Asciidoctor could recognize the intent and automatically generate the correct DocBook output (I may have already implemented that feature for Asciidoctor 1.5.0).
I hope that helps clear things up! -Dan On Tue, Jun 10, 2014 at 11:35 AM, bodiam [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi all, Dan Allen | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |