Re: [xsl] Creating an Index Page that references multiple page numbers using XSLT/FOP . Final output is PDF

Subject: Re: [xsl] Creating an Index Page that references multiple page numbers using XSLT/FOP . Final output is PDF
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 15 Jan 2012 07:19:53 -0500
At 2012-01-14 19:31 -0600, Jesse Schaaf wrote:
I am creating a PDF using an XML output to produce a publication that
has a drug list and an index page that references every drug by page
number on the drug list.
I have the drug list created and can produce the PDF however the Index
page has me stumped.

The XMLS Schema looks something like this:
<Root>
<MEDDDRUG>
<MEDDDRUGN>This text shows up on the Drug List</MEDDDRUGN>
<MEDDTIER></MEDDTIER>
<MEDDBD> </MEDDBD>
<MEDDPA></MEDDPA>
<MEDDQL></MEDDQL>
<MEDDST></MEDDST>
<MEDDINDEX>This text shows up on the Index Page</MEDDINDEX>
</MEDDRUG>
</Root>

The Drug lists is pretty simple. All it does is list out all drug names
in the <MEDDDRUGN> tag in a column format. The Index page should list
out all drug names found in the <MEDDINDEX> tag and reference pages that
the drug name shows up on the drug list. For Example, Lets say
Allopurinal shows up on the drug list 3 times(on pages 2,4,10). Then the
index should look something like:

*A*
Allopurinal
.............................................................. 2,4,10
Other A drugs .........................................................
#,#,,,

*B*
Other B drugs..........................................................#,#,,
.
.
*Z*
Other Z
drugs...........................................................#,#,,

The basics are straightforward.


Replace the "2,4,10" and "#,#,#" with <index-page-citation-list> in order to aggregate and arbitrate between ranged and duplicate page numbers. This facility is better than <page-number-citation> because with <page-number-citation> there is no removal of duplicates or interpretation of ranges ... if two references are on the same page, you get that page number twice. For this reason the designers added <index-page-citation-list> to XSL-FO 1.1.

Your XSLT/XSL-FO has to accomplish all other aspects of formatting the index ... the citation list is *only* for the page numbers.

Under <index-page-citation-list> use an <index-key-reference ref-index-key="{value}"> where that value is unique for that particular entry in the index.

Every block in your flowing pages where you want the page number to show up at that point in the index is then annotated with an index-key="{value}" attribute.

That is all you need to get started. There are nuances available in the specification for <index-page-citation-list>. More details and examples are available in my XSL-FO PDF book that can be downloaded in its entirety on a "try and buy" basis from my web site linked below. Please delete the book if you don't plan to pay for it. I'm relying on the honour system for payment.

If the XSL-FO processor does not support <index-page-citation-list> and you are creating PDF outputs, I've published a free two-pass methodology for page number aggregation and arbitration at http://www.CraneSoftwrights.com/resources/#bbi that I used to use before processors supported this natively.

I hope this helps.

. . . . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/uoui9h
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread