groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] A less than trivial indexing problem and an erroneous solution


From: Sigfrid Lundberg, NetLab
Subject: [Groff] A less than trivial indexing problem and an erroneous solution
Date: Thu, 14 Mar 2002 10:43:27 +0100 (CET)

I'm involved in a project where we are cataloging and digitizing our
entire collection of medieval manuscripts (that collection currently
contains 64 items, so it is not very large, but that is another
story).

The cataloging is done in with greatest care and detail [1]. My job is
to prepare a searchable database [2] from these huge documents, but
we've decided to make a paper version of the catalogue available as
well. I reckon that this will be a book of about 600 pages, including
a number indices (titles, authors, geographical names etc).

To do this with XSLT, a number of perl scripts and GROFF seemed
feasible (it still does, but I've run into a problem -- I always
do). Consider the following fragment of XML

----

... also known as <title type="uniform" lang="DAN">
<name type="person" role="owner">Johanne Nielsdatter Munk</name>
s Tidebog</title>.
<p>Former shelfmark: Bibl. Ms. H.L. a/4:to, N:o 4 (Bibl. Meckiana N:o XIX). ...

----

You may inspect the full document [3]. My problem is that there is a
'person' inside a 'title'. My first solution was more troffish, than
XMLish. I won't dwell on that, but the result is broken [4].

The problem is that XSLT is very recursive in its operation, and
things that is returned by the 'name'-match has to be directly
reusable in the 'title'-match, or it won't work. (Well, this is not a
problem, really, it is the beauty of XSLT) So my current idea is
something like this

<xsl:template match="title">
<xsl:text>&nl;.title&nl;</xsl:text>
   <xsl:if test="@type='uniform'">\fI</xsl:if>
   <xsl:apply-templates/>
<xsl:text>&nl;./title&nl;</xsl:text>
</xsl:template>

<xsl:template match="name">
   <xsl:choose>
   <xsl:when test="@type='person'">
      <xsl:text>&nl;.person&nl;</xsl:text>
         <xsl:apply-templates/>
      <xsl:text>&nl;/.person&nl;</xsl:text>
   </xsl:when>
   ... tests for other name types ...
   </xsl:choose>
</xsl:template>


The entity &nl; contains just a line break. and is there for ensuring
that troff macros and requests are printed properly. This piece of
XSLT requires that gtroff macros are defined about as follows

---

.de title
.di tit
..
.de /title
.di
.asciify tit
.write TEST title: \\*[tit] ... \\n[PN]
.tit
..
.de person
.di per
..
.de /person
.di
.asciify per
.write TEST person: \\*[per] ... \\n[PN]
.per
..

---

A test document using them can be found below. It formats correctly, but
the strings \*[tit] and \*[per] are printed empty to the output stream,
and my question is: Why?


Yours

Sigge
(terrible groff list spammer)

___

[1] http://www.cta.dmu.ac.uk/projects/master/index.html
[2] http://laurentius.lub.lu.se/
[3] http://laurentius.lub.lu.se/search/RECORDS/Mh_35.xml
[4] http://laurentius.lub.lu.se/search/bibliography/mh.pdf


--- diversion test ---

.open TEST test.txt
.de title
.di tit
..
.de /title
.di
.asciify tit
.write TEST title: \\*[tit] ... \\n[PN]
.tit
..
.de person
.di per
..
.de /person
.di
.asciify per
.write TEST person: \\*[per] ... \\n[PN]
.per
..
.LP
The
.title
.person
Karen Ludvigsdatter Rosenkrantz
./person
Prayer book
./title
contains a
.title
Book of hours,
./title
and a
.title
Calendar
./title


reply via email to

[Prev in Thread] Current Thread [Next in Thread]