Format <remark> in red text in PDF

P4jjb
Posts: 32

Format <remark> in red text in PDF

Tue Jul 16, 2013 6:28 am

Hi Sorin & Radu,

We have two PDF transforms: Draft and Final.
The Draft transform has draft.mode=yes and show.comments=1.
I want text enclosed in <remark> elements to display in red text, so I copied the code from inline.xsl (lines 1207-1213), added to our custom fo.xsl layer, and added the red color attribute:

Code: Select all

  </xsl:template>
    <xsl:template match="d:comment|d:remark">
    <xsl:if test="$show.comments != 0">
      <fo:inline font-style="italic" color="red">
        <xsl:call-template name="inline.charseq"/>
      </fo:inline>
    </xsl:if>
  </xsl:template>


Tested it Friday and it was working fine. Remarks displayed in red text in our Draft PDFs and no remarks displayed in our Final PDFs. I have draft PDFs from Friday and Sunday with the red remark text.

Today it suddenly stopped working and I get the following error.
It's definitely an error caused by the red text customization, because when I comment out that code, I can create a PDF again, with remarks formatted in italic black text.

System ID: C:\00_book_files\depot\main\p4-doc\manuals\p4-git-fusion-admin\xml\p4gf_xibook.xml_xslt
Scenario: 1_Draft PDF: old duplicate July 15 test
XML file: C:\00_book_files\depot\main\p4-doc\manuals\p4-git-fusion-admin\xml\p4gf_xibook.xml
XSL file: C:\Program Files\Oxygen XML Editor 142\frameworks\docbook\xsl\fo\p4-fo.xsl
Engine name: Apache FOP
Severity: error
Description: The process 'Apache FOP' ended with code: 1.
The error was:
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: images/draft.png. (See position 1:-1)
ERROR - Image not found. URI: perforce-logo.svg. (See position 2:-1)
ERROR - Couldn't find hyphenation pattern for lang="en".
ERROR - Image not found. URI: perforce-logo.svg. (No context info available)
ERROR - Exception
net.sf.saxon.trans.XPathException: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:flow"! (See position 2074:-1)
at org.apache.fop.cli.InputHandlerFOP.transformTo(Unknown Source)
at org.apache.fop.cli.InputHandlerFOP.renderTo(Unknown Source)
at org.apache.fop.cli.Main.startFOP(Main.java:177)
at org.apache.fop.cli.Main.main(Main.java:208)
Caused by: net.sf.saxon.trans.XPathException: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:flow"! (See position 2074:-1)
at net.sf.saxon.event.ContentHandlerProxy.handleSAXException(Unknown Source)
at net.sf.saxon.event.ContentHandlerProxy.startContent(Unknown Source)
at net.sf.saxon.event.NamespaceReducer.startContent(NamespaceReducer.java:192)
at net.sf.saxon.event.ReceivingContentHandler.startElement(ReceivingContentHandler.java:344)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(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 net.sf.saxon.event.Sender.sendSAXSource(Sender.java:405)
at net.sf.saxon.event.Sender.send(Sender.java:152)
at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:39)
... 4 more
Caused by: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:flow"! (See position 2074:-1)
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 $Proxy7.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.Flow.validateChildNode(Flow.java:107)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:265)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:175)
... 20 more

---------

net.sf.saxon.trans.XPathException: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:flow"! (See position 2074:-1)
at net.sf.saxon.event.ContentHandlerProxy.handleSAXException(Unknown Source)
at net.sf.saxon.event.ContentHandlerProxy.startContent(Unknown Source)
at net.sf.saxon.event.NamespaceReducer.startContent(NamespaceReducer.java:192)
at net.sf.saxon.event.ReceivingContentHandler.startElement(ReceivingContentHandler.java:344)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(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 net.sf.saxon.event.Sender.sendSAXSource(Sender.java:405)
at net.sf.saxon.event.Sender.send(Sender.java:152)
at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:39)
at org.apache.fop.cli.InputHandlerFOP.transformTo(Unknown Source)
at org.apache.fop.cli.InputHandlerFOP.renderTo(Unknown Source)
at org.apache.fop.cli.Main.startFOP(Main.java:177)
at org.apache.fop.cli.Main.main(Main.java:208)
Caused by: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:flow"! (See position 2074:-1)
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 $Proxy7.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.Flow.validateChildNode(Flow.java:107)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:265)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:175)
... 20 more
---------
org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:flow"! (See position 2074:-1)
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 $Proxy7.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.Flow.validateChildNode(Flow.java:107)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:265)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:175)
at net.sf.saxon.event.ContentHandlerProxy.startContent(Unknown Source)
at net.sf.saxon.event.NamespaceReducer.startContent(NamespaceReducer.java:192)
at net.sf.saxon.event.ReceivingContentHandler.startElement(ReceivingContentHandler.java:344)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(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 net.sf.saxon.event.Sender.sendSAXSource(Sender.java:405)
at net.sf.saxon.event.Sender.send(Sender.java:152)
at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:39)
at org.apache.fop.cli.InputHandlerFOP.transformTo(Unknown Source)
at org.apache.fop.cli.InputHandlerFOP.renderTo(Unknown Source)
at org.apache.fop.cli.Main.startFOP(Main.java:177)
at org.apache.fop.cli.Main.main(Main.java:208)

Start location: 1:0
sorin_ristache
Posts: 4144

Re: Format <remark> in red text in PDF

Tue Jul 16, 2013 11:02 am

Hi,

P4jjb wrote:Today it suddenly stopped working and I get the following error.
It's definitely an error caused by the red text customization, because when I comment out that code, I can create a PDF again, with remarks formatted in italic black text.

Code: Select all

ERROR - Exception
net.sf.saxon.trans.XPathException: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:flow"! (See position 2074:-1)
   at org.apache.fop.cli.InputHandlerFOP.transformTo(Unknown Source)
   at org.apache.fop.cli.InputHandlerFOP.renderTo(Unknown Source)
   at org.apache.fop.cli.Main.startFOP(Main.java:177)
   at org.apache.fop.cli.Main.main(Main.java:208)
Caused by: net.sf.saxon.trans.XPathException: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:flow"! (See position 2074:-1)


I tried your XSLT custom code for remark with both show.comments=1 (the default value) and show.comments=0 but I did not get an error. Can you post here or send us a sample Docbook XML document that ends with that error when transformed to PDF? Probably an invalid fo:flow element is generated in the FO file by the Docbook XSL stylesheets but first we need an XML document for getting the same error.


Regards,
Sorin
P4jjb
Posts: 32

Re: Format <remark> in red text in PDF

Tue Jul 16, 2013 7:39 pm

Thanks, Sorin. I should've stated that I'm still on 14.2.
Did you test this in 14.2, or 15, or both?
Do you need only an *.xml file, or an *.xpr with some *.xml files in it?
sorin_ristache
Posts: 4144

Re: Format <remark> in red text in PDF

Wed Jul 17, 2013 9:29 am

Hi,

It's the same Docbook PDF transformation in both Oxygen 14.2 and 15.0. Please send us your Docbook XML document so that we can get the same error. If you have a main file that includes other modules, for example using XInclude, then send all the modules. I just want to run the PDF transformation and get the same error.


Regards,
Sorin
P4jjb
Posts: 32

Re: Format <remark> in red text in PDF

Sat Jul 20, 2013 3:09 am

Sorin, thanks for your help in identifying that fo:inline should be fo:block.
Here's the final code we're using to highlight the draft <review> elements
in blue bold font with a border.


Code: Select all

  <!-- set off remarks in bold blue font and border -->
    <xsl:template match="d:comment|d:remark">
    <xsl:if test="$show.comments != 0">
      <fo:block font-style="italic" font-weight="bold" color="mediumblue" border="solid"
        border-color="mediumblue" padding="2px">
        <xsl:call-template name="inline.charseq"/>
      </fo:block>
    </xsl:if>
  </xsl:template>

Return to “DocBook”

Who is online

Users browsing this forum: No registered users and 0 guests