Dita2Kirby (2) - Adaption Of The XSL-Template
The difficulties in building a plugin dita2kirby.
Kirby is a file-based CMS. It works with text files. So why not create a DITA-OT plugin that generates txt-files made for Kirby CMS? As a result you can export your content to the web and add a comment function and much more. And most of all: You can customize the design.
Download of the original plugin
The orinal plugin that I want to adopt for an Kirby output is Jarno Elovirta´s plugin net.sourceforge.dita-ot.html. I have downloaded it under https://github.com/dita-ot/dita-ot. After unzipping the zip file I copied the plugin into my plugin folder of my DITA-Open Toolkit.
Like every plugin I had to integrate it.
ant -f integrator.xml
Adopting the plugin´s XSL file
One of the main tasks of the plugin is to create a so-called YAML header like it is used by github pages:
--- # Generated from DITA source layout: base title: "Innovation immer mit Gewinn?" ---
A Kirby site needs the following notation in its header (without asterisk):
Title: Your Title here *---- Text: Your text here
That is a solvable task even for a Technical Writer like me. I changed the file dita2html.xsl of the plugin this way:
<xsl:template match="/"> <xsl:text>Title: </xsl:text> <xsl:apply-templates select="*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]" mode="text-only"/> <xsl:text>
</xsl:text> <xsl:text>Text: </xsl:text> <xsl:apply-templates select="*" mode="chapterBody"/> </xsl:template>
After generating a DITA output with the transtype net.sourceforge.dita-ot.html I got the expected result. Namely the above mentioned typical Kirby header.
I changed the file extension from html into txt and uploaded the file to my Kirby CMS. The outcome was an error page. What went wrong? In my despair I delete the initial HTML-tag
<body> and its corresponding closing tag and uploaded again. Voila - it worked!
I searched for the string
<body> over the whole DITA-OT directory. The string was found in the dita2htmlImpl.xsl of the xhtml plugin. It was a template with a
mode="chapterBody" - just like the second template in the plugin´s file dita2html.xsl. I copied the template from line 4056 and pasted it into my dita2html.xsl file. Afterwards I deleted the
<body>-Tag and a lot more things that I believed I would no longer need it.
My second template within the plugin´s XSL-file now looks like this:
<xsl:template match="*" mode="chapterBody"> <xsl:call-template name="generateBreadcrumbs"/> <xsl:call-template name="gen-user-sidetoc"/> <xsl:apply-templates/> <!-- this will include all things within topic; therefore, --> <!-- title content will appear here by fall-through --> <!-- followed by prolog (but no fall-through is permitted for it) --> <!-- followed by body content, again by fall-through in document order --> <!-- followed by related links --> <!-- followed by child topics by fall-through --> <xsl:call-template name="gen-endnotes"/> <!-- include footnote-endnotes --> <xsl:call-template name="gen-user-footer"/> <!-- include user's XSL running footer here --> <xsl:call-template name="processFTR"/> <!-- Include XHTML footer, if specified --> <xsl:value-of select="$newline"/> </xsl:template>
What happened after uploading to Kirby CMS - see part 3 of this series.