[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] finding closest node with certain characteristics


Subject: [xsl] finding closest node with certain characteristics
From: "Steve Ylvisaker ylvisaker.steve@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 6 May 2014 14:23:35 -0000

forum: 

I am implementing a variation on Ken's PSMI process to accommodate some
special needs for tax tables in our composition to PDF process. So, my input
is a namespace fo file that contains a special wrapper:
<psmi:inserted-page-geometry/>. This wrapper may occur multiple times within
the XML instance.

All is well with my psmi process, however, I can run into situations where
an element following the psmi wrapper has the break-after="page" or
break-before="page" attribute associated with it and is now redundant
resulting in a blank page.

So I need to find the first occurrence of any element with attribute
break-after (or break-before) following a psmi wrapper and determine if
there is any content between that element and the psmi wrapper. If there is
no content then the page break request is likely redundant and needs to be
defeated.

Example data:

<psmi:inserted-page-geometry>
  <fo:table>
   ~large table markup ~
  </fo:table>
</psmi:inserted-page-geometry>
<fo:block margin-top="8pt">
  <fo:marker marker-class-name="runningFoot"/>
  <fo:block span="all" break-after="page"/>
  <fo:block>Composition text here</fo:block>

My problem is that the psmi wrapper may occur multiple times in the xml
instance so I need to determine if my break-after element is the first one
following the closest psmi wrapper. I know I have figured this out before
but have a block trying to figure it out now.

psudo code:
<xsl:template match="*[@break-after]">
 <xsl:choose>
<!-- this test is where I need help, the rest I am fine with -->
  <xsl:when test="(I am the first occurrence of an element with the
attribute break-after following the closest psmi wrapper element) and 
                  (there is no content in the elements that exist between me
and the closest psmi wrapper element)">copy the element without the
break-after attribute</xsl:when>
  <xsl:otherwise>copy the element as it occurred in the xml
instance</xsl:otherwise>
 </xsl:choose>>
</xsl:template>

Thanks for any clues.
Steve


Current Thread
Keywords
xml