W3C home > Mailing lists > Public > www-xsl-fo@w3.org > April 2003

Re: total page count problem

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Thu, 03 Apr 2003 10:31:02 -0500
Message-Id: <5.2.0.9.0.20030403102148.028294b0@pop.storm.ca>
To: <www-xsl-fo@w3.org>

At 2003-04-03 08:51 -0600, Mike Haarman wrote:
> > I have displayed the generated id's  in the document to ensure myself that
>they are unique.
> > Any idea's?
>
><fo:page-number-citation
>ref-id="$particular.generated.id.you.wish.to.refer.to"/>

The above would have to be as follows to be useful:

   ref-id="{$particular.generated.id.you.wish.to.refer.to}"

It is a *very* common mistake.

>I am sure your generated id's are unique as the rec. demands it.  Make 
>sure you
>are referring to the correct one.
>
>In the interest of legibility I sometimes just use an attribute value of the
>element that dictates sequences, like:
>
><fo:page-number-citation ref-id="{@departmentID}"/>

While this works when inputs are controlled, it is my personal practice to 
never use naked ID values from my XML sources in my XSL-FO 
references.  Assuming the above is of type IDREF in my XML, I would use:

<fo:page-number-citation ref-id="{generate-id(id(@departmentID))}"/>

If it were of type ID, I would use:

<fo:page-number-citation ref-id="{generate-id(.)}"/>

I recommend to my students to do the above and that when doing the last 
page to use ....

<fo:page-number-citation ref-id="{generate-id(/)}"/>

.... as this is guaranteed never to clash with my practice of using 
generate-id() for other nodes since there will never be an IDREF pointing 
to the root.  If you choose something like "last", you run the risk when 
using naked ID values of your customers authoring an internal ID attribute 
with the same value.

I am in this practice now because so many of my transformations involve 
multiple source documents.  Should you introduce another source document 
into your transformation, and you forget to do the above, you run the risk 
of ID-value-collision from the ID values of the other XML documents.

Since I never "look" at the ID values in my XSL-FO intermediate 
transformations, I have no desire to preserve the original values (that I 
confess I do wish to do when going from XML to XML) and have no qualms 
about munging them with generate-id().

But, by getting in the habit of doing the above, I won't run into a mystery 
problem in the future.  Consider that once you hand off your stylesheets to 
your customers, you have no control over their selection of ID values 
across instances.  The technique above is guaranteed to be safe and to 
respect each input XML document's separate ID name value space.

I hope this helps.  I realize it is extra work, but it protects stylesheets 
for the long term.

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


--
Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO
                              North America:      June 16-20, 2003

G. Ken Holman                mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/f/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 0-13-140374-5                              Definitive XSL-FO
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1              Practical Formatting Using XSL-FO
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
Received on Thursday, 3 April 2003 10:33:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:10 GMT