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

RE: [xsl] how to get total string-length()


Subject: RE: [xsl] how to get total string-length()
From: "Matthew L. Avizinis" <mla@xxxxxxxxx>
Date: Fri, 2 Aug 2002 10:17:21 -0400

Of course, it was the end of the day and I didn't see such an obvious
solution.
In any case, thanks much.
Now that that piece clicks in place, what I have is a, albeit rough,
solution to the problem of justifying text...page numbers that has been
going on in the FOP-user list about behavior of fo:leaders.
    ^^^-----fo:leader here
If you have text...page numbers in a block contained in a fo:table-cell what
happens is that the leader fills the remaining cell space and the
page-numbers overflow the cell.  This is not, at least in my case, an
acceptable outcome.  However, if the margin-right for the table-cell is set
to some amount the leader will stop there instead of filling the rest of the
cell.  Although I am using a variable width font, since the numbers are
essentially all the same width, except for #1, I can calculate how far to
set the right margin and let the page numbers be plugged onto the end of the
line and have a relatively pretty right alignment.  With the current state
of FOP code for fo:leader behavior this seems like an acceptable workaround.
   Matthew L. Avizinis <mailto:mla@xxxxxxxxx>
Gleim Publications, Inc.
   4201 NW 95th Blvd.
 Gainesville, FL 32606
(352)-375-0772
      www.gleim.com <http://www.gleim.com>


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of J.Pietschmann
> Sent: Thursday, August 01, 2002 3:46 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] how to get total string-length()
>
>
> Matthew L. Avizinis wrote:
> > Hello all,
> > If I have the following snippet:
> >
> > <fo:block margin-right="{concat(NNN*1.5),'mm')}">
> > --------------------------------^^^
> >    <xsl:call-template name="process-nodes"/>
> >    <xsl:if test="not(@no-pg-num)">
> >        <fo:leader leader-pattern="dots" leader-pattern-width="2.0mm"
> > leader-alignment="reference-area"/>
> >    </xsl:if>
> >    <xsl:for-each
> > select="document(concat($libname,'/index.xml'))//index/index-term[@id =
> > $primary]">
> >       <xsl:value-of select="."/><xsl:if test="position() !=
> > last()">,&nbsp;</xsl:if>
> >    </xsl:for-each>
> > </fo:block>
> >
> > In the for-each line I grab each index-term that has an id that
> matches the
> > value in $primary.  Thus I could have a line like
> >    the index entry..........123, 234, 345
> >
> > What I want to be able to do is, using the example in the line above,
> > calculate the number of characters in "123, 234, 345" and be
> able to insert
> > it in the NNN location in the block margin-right location.
> Obviously I need
> > to figure this out outside/before the block, but howto, that's
> the question.
>
> This appears to be really easy: put it into a variable
> and use string-length:
>
> <xsl:variable name="page-list">
>     <xsl:for-each
>      select="document(concat($libname,
>        '/index.xml'))//index/index-term[@id = $primary]">
>        <xsl:value-of select="."/><xsl:if test="position() !=
>       last()">,&nbsp;</xsl:if>
>     </xsl:for-each>
> </xsl:variable>
>
>
> <fo:block margin-right="{concat(string-length($page-list)*1.5),'mm')}">
>     <xsl:call-template name="process-nodes"/>
>     <xsl:if test="not(@no-pg-num)">
>         <fo:leader leader-pattern="dots" leader-pattern-width="2.0mm"
>          leader-alignment="reference-area"/>
>     </xsl:if>
>     <xsl:value-of select="$page-list"/>
> </fo:block>
>
> If you have any markup in the page number list, like fo:basic-links,
> use xsl:copy-of instead of xsl:value-of.
>
> J.Pietschmann
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread