OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] (sub)section titles rendered as fo:inline for Legal Contracts?


Craeg,

I had a similar problem and did the following.  The caveat is that
this is only lightly tested to date, so it may or may not work in
your situation.  Also, it's far from elegant.  I suspect there are
cleaner ways to do this that I just haven't figured out yet.

The thing that makes this tough is that you need to process the
run-in title and its following paragraph together, but the standard
transforms process section titles in their own fo:block, then in
another place process the following para in its own fo:block.

At a high level, what I did was to process level 3 and higher titles
and the immediately following paragraph together in the section/title
template, instead of letting the paragraph be processed normally.
That processing uses customized templates for the title and the
paragraph, but they are simple customizations (mostly replacing
fo:block with fo:inline).  Then, I created empty templates that
matched the paragraph immediately following the title so it
doesn't get processed in the normal place.

This is based on a solution that Bob Stayton provided to someone
else looking for this capability, but his solution was set up for
sect1, sect2, etc., rather than recursive sections.  Here's a pointer
to that solution.

http://lists.oasis-open.org/archives/docbook-apps/200506/msg00024.html

What I did was extend it to handle both recursive sections and
hard-coded sections.  Be aware that both this solution and mine
work only if the title is followed by a <para>.

Here it is:

All of this was done in a customization layer.

First, I defined an attribute set called inline.para.spacing
for anything that is different from normal.para.spacing.  You
may not need this; I did because I was using a first line text
indent for normal paragraphs, but not for paragraphs after an
inline title:

  <xsl:attribute-set name="inline.para.spacing">
    <!-- whatever attributes you want to set -->
  </xsl:attribute-set>

Second, I customized the section/title template (fo/sections.xsl).
At the very end of that template, there is a call-template
name="section.heading".  I replaced that call with the following,
which calls a new template, inline.section.heading, for the heading,
followed by an apply-templates with mode="inline.para" for the next
paragraph when the level is greater than 2.  Otherwise, the processing
is unchanged:

    <xsl:choose>
      <xsl:when test="$level &gt; 2">
        <fo:block xsl:use-attribute-sets="inline.para.spacing">
          <xsl:call-template name="inline.section.heading">
            <xsl:with-param name="level" select="$level"/>
            <xsl:with-param name="title" select="$title"/>
            <xsl:with-param name="marker" select="$marker"/>
            <xsl:with-param name="titleabbrev" select="$titleabbrev.elem"/>
          </xsl:call-template>
          <xsl:apply-templates select="following-sibling::*[1]"
            mode="inline.para"/>
        </fo:block>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="section.heading">
          <xsl:with-param name="level" select="$level"/>
          <xsl:with-param name="title" select="$title"/>
          <xsl:with-param name="marker" select="$marker"/>
          <xsl:with-param name="titleabbrev" select="$titleabbrev.elem"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>

I then added the following template for para with mode="inline.para":

  <xsl:template match="para" mode="inline.para">
    <fo:inline xsl:use-attribute-sets="normal.para.spacing">
      <xsl:call-template name="anchor"/>
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>

This is identical to the template match="para" in fo/fo.xsl,
except that it uses fo:inline instead of fo:block.

Then I added the following empty templates to avoid getting a
repeat when this section processes its paragraphs.

<xsl:template
  match="section/section/section/para[preceding-sibling::*[1][self::title]]">
</xsl:template>

The following template does the same thing if you're using non-recursive
sections.

<xsl:template match="sect3/para[preceding-sibling::*[1][self::title]]">
</xsl:template>

The magic sauce in these templates is the match, which is taken
from Bob Stayton's example.  Here's his description:

The select="para[preceding-sibling::*[1][self::title]]" attribute translates
to "take a para element, look at its preceding-sibling elements, take the
first one, and use the para only if that first preceding-sibling is a title
element".

Finally, I created the template name="inline.section.heading", which
is identical to the template name="section.heading" in fo/sections.xsl
except that every fo:block is replace with an fo:inline.  Also, this
is the place where you might want to put the asterisks and other
punctuation after your titles.  To save space, I haven't included
that one.

This is hard-coded to make level 3 and higher headings run-in.  It
would be nice to set level with a parameter, but I haven't figured
out how to parameterize the empty para template matches yet.

So, you weren't too far off the mark in saying it will take some
heavy customization (at least it did for me; if someone has a shorter
way to do this, I'd like to hear about it), but it's mostly just
copying things and making a couple of key changes in the middle.

I hope this helps.  If you'd like a copy of the customization layer
this is part of, I'd be glad to send it to you; just drop me a line.

Dick Hamilton

----- Original Message ----- 
From: "Craeg Strong" <cstrong@arielpartners.com>
To: <docbook-apps@lists.oasis-open.org>
Sent: Sunday, December 04, 2005 10:42 PM
Subject: [docbook-apps] (sub)section titles rendered as fo:inline for Legal 
Contracts?


Hello:

I am using Docbook 5.0b1 with Saxon 6.5.5 and RenderX XEP 4.4 to markup
a legal contract (Docbook XML -> FO -> PDF).
I have lots of numbered sections where the titles are inline, for example:


  *_1. At Will Employment_.* I understand and acknowledge that my
  employment with the Company is for an unspecified duration and
  constitutes “at-will” employment.


or


    *_2a) Company Information_.* I agree at all times during the term of
    my employment and thereafter, to hold in strictest confidence, and
    not to use, except for the benefit of the Company, or to disclose to
    any person, firm or corporation without written authorization of the
    Manager of the Company, any Confidential Information of the Company,
    except to the extent required by law or legal process.


It seems that in order to create something like this in my PDF output, I
would have to make some
pretty heavy customizations of <xsl:template match="section"> within
xslt/fo/sections.xsl

To summarize, I would like sections at level 2 to be fo:block, but
sections > level 2 to be fo:inline

Question:

Can anyone think of an easier way to get inline titles? Maybe use an
alternate markup other than section?
Has anyone else tried to use DocBook for legal contracts?

Thanks!

--Craeg

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]