Content not allowed in prolog error when transforming XML with FO

Here should go questions about transforming XML with XSLT and FOP.
oh-s-jay
Posts: 1
Joined: Thu Jun 26, 2025 12:54 am

Content not allowed in prolog error when transforming XML with FO

Post by oh-s-jay »

I'm hoping that I've just missed something obvious, but I'm kind of running out of ideas - basically, my goal is to transform XML files into pdfs using an XSLT stylesheet which uses the FO syntax. This works fine in the debugger mode (so if I run the debugger, save the output, and apply the transformation to the output) but whenever I try to just click 'apply transformation scenario' on the original xml file it throws up the error code:
org.apache.fop.apps.FOPException: net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException [filename] Content is not allowed in prolog.
My UTF-8 BOM handling preferences are set to "Don't write", the transformation scenario is set up with Saxon PE 11.4 and the built-in Apache FOP processor. I've checked the box to use the XSLT result as input. Both the xml file and the xslt begin with the declaration

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
and as far as I can tell there's no whitespace in front of it. The XSLT sheet also starts with

Code: Select all

<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
and when I run it in the debugger, the output file starts with the proper <fo:> element. So I can't find any reason why there should be content in the prolog, or how to fix it. What am I missing here?