Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DocBook macros?

Tags:

macros

docbook

Is there any way of defining macros (like tex macros o latex defines) in DocBook documents?

DocBook is very verbose, and macros would help a lot. I didn't find them in quickstart tutorials.

If so, could anyone provide a simple example or a link to?

Thanks

like image 492
cibercitizen1 Avatar asked Apr 08 '10 14:04

cibercitizen1


2 Answers

Not sure, if this is exactly what you want / if it full fills your requirements, but I'm thinking of ENTITYs. You can define them at the top (of your XML document, so general XML, nothing DocBook specific). As seen here for the 'doc.release.number' and 'doc.release.date'. But they can also be included through an separate file. As seen in the 3th ENTITY row. Here the SYSTEM means, comming from another file 'entities.ent'.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
    "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

  <!ENTITY  doc.release.number                 "1.0.0.beta-1"       >
  <!ENTITY  doc.release.date                   "April 2010"         >

  <!ENTITY  %   entities  SYSTEM  "entities.ent" >

  %entities;

]>

<!--  This document is based on http://readyset.tigris.org/nonav/templates/userguide.html  -->
<article  lang="en">
  <articleinfo>
    <title>&project.impl.title; - User Manual</title>
    <subtitle></subtitle>
    <date>&project.impl.release.date;</date>
    <copyright>
      <year>doc.release.year</year>
      <holder>Team - &project.impl.title;</holder>
    </copyright>
    <releaseinfo>&doc.release.number;</releaseinfo>
  </articleinfo>

  <section>
    <title>Introduction</title>
    <para>
    The &project.impl.title; has been created to clean up (X)HTML and XML documents as part of 


    </para>
  <section>
</article>

In the document you reference the entities through a starting & and ending ; as in &project.impl.title;

In the file 'entities.ent' you specify the ENTITY elements in a similar way:

<?xml version="1.0" encoding="UTF-8"?>

<!ENTITY  project.impl.title            'Maven Tidy Plug-in'    >
<!ENTITY  project.impl.group-id         'net.sourceforge.docbook-utils.maven-plugin'    >
<!ENTITY  project.impl.artifact-id      'maven-tidy-plugin'     >
<!ENTITY  project.impl.release.number   '1.0.0.beta-1'          >
<!ENTITY  project.impl.release.date     'April 2010'            >
<!ENTITY  project.impl.release.year     '2010'                  >
<!ENTITY  project.impl.url              '../'                   >
<!ENTITY  project.spec.title            ''  >
<!ENTITY  project.spec.release.number   ''  >
<!ENTITY  project.spec.release.date     ''  >
<!ENTITY  doc.release.year              '2010'                  >  
like image 59
Verhagen Avatar answered Sep 29 '22 10:09

Verhagen


Not exactly what you asked for, but perhaps helpful for some of your cases: you can define templates in your wrapper stylesheet where you define fo commands. Some examples:

Code:

<xsl:template match="symbolchar">
  <fo:inline font-family="Symbol">
    <xsl:choose>
      <xsl:when test=".='ge'">&#x2265;</xsl:when>
      <xsl:when test=".='le'">&#x2264;</xsl:when>
      <xsl:when test=".='sqrt'">&#x221A;</xsl:when>
      <xsl:otherwise>?!?</xsl:otherwise>
    </xsl:choose>
  </fo:inline>
</xsl:template>

Usage:

<symbolchar>le</symbolchar>

Code:

<xsl:template match="processing-instruction('linebreak')">
  <fo:block/>
</xsl:template>

Usage:

<?linebreak?>
like image 24
Doc Brown Avatar answered Sep 29 '22 11:09

Doc Brown