DocBook XSL: Wrapping <programlisting> and <screen> in <pre>

DocBook duck logo Today I started looking at using a DocBook XSL customization to wrap <programlisting> and <screen> in <pre>.

What took an inordinate amount of time was not finding <xsl:apply-imports />, but instead realizing I needed to take the namespace into account. Currently this is using the 1.76.1 stylesheets.

<xsl:stylesheet ... xmlns:d="http://docbook.org/ns/docbook" exclude-result-prefixes="d"
... >
 <xsl:template match="d:programlisting">
  <pre><xsl:apply-imports /></pre>
 </xsl:template>
...
</xsl:stylesheet>

Without the d: prefix, I was scratching my head and mumbling under my breath. With the prefix, it just works.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s