[xsl] RE: xsl-list Digest 15 Dec 2006 06:10:00 -0000 Issue 989

Subject: [xsl] RE: xsl-list Digest 15 Dec 2006 06:10:00 -0000 Issue 989
From: "McDonald, Shaun" <Shaun.McDonald@xxxxxxxxxxx>
Date: Wed, 27 Dec 2006 06:58:12 -0500
Hello All,

Thanks for all the replies.  And thank you, Phil, for being more
specific about the problem I'm trying to solve.

I apologize for having taken so long, but I've done more exhaustive
research.  Subsequently, I have decided that using markers with filters
and absolutely positioned block-containers is very close to what we
need.

For example: (Version 1.0 / UTF-8 / FOP Processor)

<xsl:template match="Para">
 <fo:block >
  <xsl:if test="@change = 1">
   <fo:marker marker-class-name="changed">
    <fo:block-container position="absolute" width="7.3in" height="0.5in"
     background-color="white">
     <fo:table width="100%">
	<fo:table-column
column-width="proportional-column-width(49.2)"/>
	<fo:table-column
column-width="proportional-column-width(49.2)"/>
	<fo:table-column column-width="proportional-column-width(0.6)"/>
	<fo:table-body>
	 <fo:table-row>
	  <fo:table-cell width="44.2%" >
	   <fo:block>
	    <fo:inline font-size="10pt">Revision: </fo:inline>
	    <fo:inline font-size="10pt">
	     <xsl:value-of select="@Revision"/>
	    </fo:inline>
	   </fo:block>
	  </fo:table-cell>
	  <fo:table-cell width="44.2%" >
	   <fo:block>
	    <fo:inline font-size="10pt">Page: </fo:inline>
	    <fo:inline font-size="10pt">
	     <fo:page-number/>
	    </fo:inline>
	   </fo:block>
	  </fo:table-cell>
	  <fo:table-cell border-right-style="solid"
border-right-width="1pt"
         border-right-color="black" width="0.6%">
	   <fo:block start-indent=".2in">
	    <fo:inline font-size="10pt"> </fo:inline>
	   </fo:block>
	  </fo:table-cell>
	 </fo:table-row>
	</fo:table-body>
     </fo:table>
    </fo:block-container>
   </fo:marker>
  </xsl:if>
  <xsl:if test="@Revision = true() and @change = false()">
   <fo:marker marker-class-name="unchanged">
    <fo:block-container position="absolute" width="7.3in" height="0.5in"
     background-color="white">
	<fo:table width="100%" >
	<fo:table-column column-width="proportional-column-width(50)"/>
	<fo:table-column column-width="proportional-column-width(50)"/>
	<fo:table-body>
	 <fo:table-row>
	  <fo:table-cell width="50%" >
	   <fo:block>
	    <fo:inline font-size="10pt">Revision: </fo:inline>
	    <fo:inline font-size="10pt">
	     <xsl:value-of select="@Revision"/>
	    </fo:inline>
	   </fo:block>
	  </fo:table-cell>
	  <fo:table-cell width="50%" >
	   <fo:block>
	    <fo:inline font-size="10pt">Page: </fo:inline>
	    <fo:inline font-size="10pt">
	     <fo:page-number/>
	    </fo:inline>
	   </fo:block>
	  </fo:table-cell>
	 </fo:table-row>
	</fo:table-body>
     </fo:table>
    </fo:block-container>
   </fo:marker>
  </xsl:if>
  <!--Para template data here-->
 </fo:block>
</xsl:template>

And:

<xsl:template name="footerall">
 <fo:static-content flow-name="xsl-region-after" display-align="after">
  <fo:retrieve-marker retrieve-class-name="unchanged" retrieve
   boundary="page" retrieve-position="first-starting-within-page"/>
  <fo:retrieve-marker retrieve-class-name="changed"
retrieve-boundary="page"
   retrieve-position="first-starting-within-page"/>
 </fo:static-content>
</xsl:template>

When XML:

<Para Revision = "00"> text </Para>
<Para Revision = "00"> text </Para>
<Para Revision = "00"> text </Para>
--- natural page break ---
<Para Revision = "00"> text </Para>
<Para Revision = "00"> text </Para>
<Para change = "1" Revision = "01"> text </Para>
<Para Revision = "00"> text </Para>

Output in the footer:

Revision: 00	      Page: 1   (When @change is false() on page one)

Revision: 01	      Page: 2 | (When @change = 1 on page one)

This works great.  In the footer, the "changed" marker overlays the
"unchanged" marker when that page contains a paragraph where @change =
1.

The problem arises when I have three or more @Revision values.
Consider the following XML:

<Para Revision = "00"> text </Para>
<Para Revision = "01"> text </Para>
<Para change = "1" Revision = "02"> text </Para>
--- natural page break ---
<Para Revision = "00"> text </Para>
<Para Revision = "01"> text </Para>

The first output page is fine:

Revision: 01	      Page: 1 |

The second output page is incorrect:

Revision: 00	      Page: 2

It should read Revision: 01 because that is the latest revision for that
page.

I have created a conditional marker for each @Revision value.  That
works, but it's too much if there are 98 revisions.

How do I set a marker only for the highest @Revision value on a page?

Regards,

Shaun

>Date: Thu, 14 Dec 2006 18:35:11 -0500
>To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>From: "Philip Vallone" <philip.vallone@xxxxxxxxxxx>
>Subject: RE: [xsl] XSL-FO: Accessing nodes by page
>Message-id: <000101c71fd8$80749730$2f01a8c0@Main>
>
>Hi All,
>
>I am currently trying to publish an XML doc in PDF. This manual is a
print
>on paper and revised often. This means that the contents of the page
would
>dictate what's in the footer (date of revision and revision number).
>
>Has anyone any advice on how to achieve this. I am using the apache FOP
>processor.
>
>Thanks,
>
>Phil
>
>-----Original Message-----
>From: McDonald, Shaun [mailto:Shaun.McDonald@xxxxxxxxxxx]
>Sent: Thursday, December 14, 2006 2:23 PM
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: [xsl] XSL-FO: Accessing nodes by page
>
>Hello List,
>
>According to
>http://www.dpawson.co.uk/xsl/sect3/pagelayout.html#d12370e288, I quote:
>
>"...pagination is done after the transformation, in an independent
step.
>Therefore there is no way to get hold of the number of prescriptions
>laid out on a certain page in the transformation.  The layout process
>itself lacks higher level functionality like counting, so no easy
>solution here either."
>
>Is this still true?  Is there no way to access nodes by page (for
>instance, from a footer template) without forcing page breaks?
>
>Regards,
>
>Shaun McDonald
>
>------------------------------
>
>Date: Fri, 15 Dec 2006 00:49:43 +0100
>To:  xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
>Subject: Re: [xsl] XSL-FO: Accessing nodes by page
>Message-ID: <4581E317.6060207@xxxxxxxx>
>
>McDonald, Shaun wrote:
>> "...pagination is done after the transformation, in an independent
step.
>> Therefore there is no way to get hold of the number of prescriptions
>> laid out on a certain page in the transformation.  The layout process
>> itself lacks higher level functionality like counting, so no easy
>> solution here either."
>>
>> Is this still true?  Is there no way to access nodes by page (for
>> instance, from a footer template) without forcing page breaks?
>
>That's correct. Some FO processors have extension functions which
>might allow to do certain things.
>
>J.Pietschmann
>
>------------------------------
>
>Date: Fri, 15 Dec 2006 00:23:16 GMT
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>From: David Carlisle <davidc@xxxxxxxxx>
>Subject: Re: [xsl] XSL-FO: Accessing nodes by page
>Message-Id: <200612150023.kBF0NGc6016033@xxxxxxxxxxxxxxxxxxx>
>
>> Has anyone any advice on how to achieve this. I am using the apache
FOP
>> processor.
>
>In general the way you use page contents to affect the page head and
>foot is to use markers. The typesetting happens (in the model at least)
>before pagination so there are no "nodes" to access by that time, but
>when setting the head and foot you have access to any text put
>in "markers" on the page. I just noticed 9while checking the link
below)
>that the markers are a bit more expressive in an xsl 1.1 system, but
xsl
>1.0 marks should be enough for doing revision numbers, and things like
>index headlines which show the word range on teh current page, etc
>
>http://www.w3.org/TR/xsl11/
>
>says in the status section:
>
>This Recommendation supersedes [XSL 1.0], which was published 15
October
>2001. New functionality has been added to support change marks,
indexes,
>multiple flows, and bookmarks. Existing functionality has been extended
>in the areas of graphics scaling, "markers" and their retrieval in
>tables to support e.g. partial sums, and page number referencing. The
>changes made in this document are intended to meet the requirements for
>XSL 1.1 described in [XSL 1.1 Requirements]. A number of errata have
>been incorporated into the text
>
>I suspect fop is 1.0 so a better ref would be the markers in that which
>is:
>
>http://www.w3.org/TR/2001/REC-xsl-20011015/slice7.html#section-N48193-
>Properties-for-Markers

Current Thread