Search code examples
xmlxsltmavendocbook

maven docbook plugin content not allowed in prolog


I am using the maven docbook plugin (com.agilejava.docbkx), and I am using a custom xsl file to override some properties, and it looks like:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:attribute-set name="section.title.properties">
    <xsl:attribute name="font-family">Times</xsl:attribute>
  </xsl:attribute-set>
</xsl:stylesheet>

And I when I run the maven plugin, I get the following error

Embedded error: org.xml.sax.SAXParseException: Content is not allowed in prolog.

I'm running on windows and I have tried creating the file in Notepad, Notepad++, Eclipse and Cygwin all with the error. Does anyone know why?


Solution

  • Once I imported the main docbook stylesheet:

    <xsl:import href="urn:docbkx:stylesheet"/>
    

    Everything worked fine.

    urn:docbkx:stylesheet can be considered as a symbolic link. What urn:docbkx:stylesheet actually will import depends on what customization (html, xhtml, etc.) you specify in your pom.xml. If you want to use xhtml/chunk.xsl customization then first specify the configuration <xhtmlCustomization> in the pom.xml. Then specify it in your XSL by,

    <xsl:import href="urn:docbkx:stylesheet/chunk.xsl"/> 
    

    In this case, the plugin will pick up the chunk.xsl sheet of xhtml stylesheets. Further details, and the complete configurations needed are explained in the How to Use docbkx-tools as Maven DocBook plugin blog post.