I am attempting to recover from a design error I made last year. Then, from
a raw XML file, I produced a driver file (Listing 3) that was used to output
HTML and PDF files. However, the requirements for the project changed and
that driver file was no longer adequate. Last week on this list, G. Ken
Holman provided me with part of the answer [xsl-list email; subject:
Inlining blocks in FO]. In an attempt to solve the more complex problem, I
produced a new driver file (see Listing 2). I had hoped to apply Ken's
solution for the simpler problem to this more complex one, but was defeated.
What I want is shown in Listing 1. The "Title: citation; citation." comes
from the <Articles> and is there to indicate that once everything is brought
together, I still have to process the <Article> elements in the way that Ken
suggested last week. I know how to format the FO output, what I do not know
is how to process the new driver file to produce the desired output. Clearly
my for-each-groups are not correct. The main templates for my failed code
(the supporting templates are not included, so the code will not run), are
in Listing 4, and its FO PDF output in Listing 5.
Any help or hint gratefully received.
Mark
Listing 1. (Desired FO output)
Abbeys and Monasteries
Title: citation.
Porta Coeli
Title: citation; citation.
St Nicholas. Postal Card
Title: citation.
Strahov
Strahov Madonna
Title: citation.
Listing 2. (New Driver file)
<List>
<Item>
<Heading entry="subject">Abbeys and Monasteries</Heading>
<Article>....</Article> <---- NOTE
</Item>
<Item>
<Heading entry="subject">Abbeys and Monasteries</Heading>
<SubDiv1 scott="4" scott-number="3213" pofis="4"
pofis-number="371">Porta Coeli</SubDiv1>
<Article>....</Article>
<Article>....</Article>
</Item>
<Item>
<Heading entry="subject">Abbeys and Monasteries</Heading>
<SubDiv1>St Nicholas. Postal Card</SubDiv1>
<Article>....</Article>
</Item>
<Item>
<Heading entry="subject">Abbeys and Monasteries</Heading>
<SubDiv1>Strahov</SubDiv1>
<SubDiv2 scott="4" scott-number="2908" pofis="4"
pofis-number="27">Strahov Madonna</SubDiv2>
<Article>....</Article>
</Item>
</List>
Listing 3 (Old Driver File)
<List>
<Item>
<Heading entry="subject">Abbeys and Monasteries</Heading>
<Article>.....</Article>
<SubDiv1 scott="4" scott-number="3213" pofis="4"
pofis-number="371">Porta Coeli</SubDiv1>
<Article>.....</Article>
<Article>.......</Article>
<Heading entry="subject">Abbeys and Monasteries</Heading>
<SubDiv1>St Nicholas. Postal Card</SubDiv1>
<Article>....</Article>
<SubDiv1>Strahov</SubDiv1>
<SubDiv2 scott="4" scott-number="2908" pofis="4"
pofis-number="27">Strahov Madonna</SubDiv2>
<Article>....</Article>
</Item>
</List>
Listing 4 (Failed code)
<xsl:template match="List">
<xsl:for-each-group select="Item"
group-by="Heading,SubDiv1,SubDiv2,SubDiv3">
<xsl:choose>
<xsl:when test="Heading/@entry='author'">
<xsl:call-template name="format-author-heading"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="format-subject-heading"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>
<!-- Format a Subject Heading -->
<xsl:template name="format-subject-heading">
<!-- We have all identical headings
1. Write out the Heading and any catalog info-->
<fo:block xsl:use-attribute-sets="subject-heading">
<xsl:value-of select="Heading"/>
<fo:wrapper xsl:use-attribute-sets="catalog-numbers">
<xsl:call-template name="catalog-name-and-number"/>
</fo:wrapper>
<xsl:for-each-group select="../Article" group-by="Title">
<!--and put all citations in one block-->
<fo:block xsl:use-attribute-sets="article0">
<!--for a given title-->
<fo:wrapper xsl:use-attribute-sets="citation-title">
<xsl:call-template name="format-article-title"/>
</fo:wrapper>
<!--and for each citation-->
<xsl:apply-templates select="current-group()"/>
</fo:block>
</xsl:for-each-group>
</fo:block>
<!-- Next deal with SubDiv1 -->
<xsl:apply-templates select="SubDiv1"/>
</xsl:template>
List 5 (Failed output)
Abbeys and Monasteries
Abbeys and Monasteries
Porta Coeli [Scott Czechoslovakia 3213; POFIS Ceska Republika 371]
Modern postal history. Lubor Kunc. Jul/Aug 2004 p.18.
New issues: Czech Republic. G.M. van Zanten. Jan/Feb 2004 p.34.
Abbeys and Monasteries
St Nicholas. Postal Card
Postal issues of Czechoslovakia and Slovakia with Ukrainian
connections. Andrij D. Solczanyk. Jul/Aug 2000
p.15.
Abbeys and Monasteries
Strahov
1350's art. G.M. van Zanten. Sep/Oct 2004 p.27.
Abbeys and Monasteries
Strahov
1350's art. G.M. van Zanten. Sep/Oct 2004 p.27.