You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by pat <pa...@xvalheru.org> on 2006/07/18 12:02:25 UTC

marker value to variable

Hi all,

I have a problem and I'm not able to solve it :-( I'm using marker to generate
subtotat (it works) and for retrievng the subtotal I'm using retrieve-marker
(that works too), but I need to split subtotal to part before decimal point
and after decimal point ant this is the problem. How to store the value from
retrieve-marker to variable or use it directly ???

I'm looking for something like this:
<xsl:variable name="qqq">
  <fo:retrieve-marker .../>
</xsl:variable>

Is there a way how to do that ???

Thanks a lot.

     Pat

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Jul 18, 2006, at 20:36, Andreas L Delmelle wrote:

> (so, one marker/retrieve-marker pair per subtotal).

Errrm... I mean *two* pairs, of course 8)

Cheers,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Jul 18, 2006, at 12:02, pat wrote:

> I have a problem and I'm not able to solve it :-( I'm using marker  
> to generate
> subtotat (it works) and for retrievng the subtotal I'm using  
> retrieve-marker
> (that works too), but I need to split subtotal to part before  
> decimal point
> and after decimal point ant this is the problem. How to store the  
> value from
> retrieve-marker to variable or use it directly ???
>
> I'm looking for something like this:
> <xsl:variable name="qqq">
>   <fo:retrieve-marker .../>
> </xsl:variable>

As Glen already indicated, it is impossible to know at XSLT stage  
what the content will be of a given fo:retrieve-marker during the  
formatting stage. This does not IMO make what you need completely  
impossible. Even without knowing why precisely you need to separate  
the integer and fractional part, you could do it using one marker- 
class for each (so, one marker/retrieve-marker pair per subtotal).

HTH!

Cheers,

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable [SOLVED]

Posted by Glen Mazza <gm...@apache.org>.
*Very* impressive and clean solution, Andreas.  I wish I could have 
thought of that.

Glen

pat wrote:
> YES !!! That's it !!! That's the way :-)
> 
> My problem was that I firstly counted the summary and then I've try to split
> the fraction instead firstly count the integer and fraction and then only
> disply them.
> 
> Thanks a lot !!!
> 
>      Pat
> 
> On Wed, 19 Jul 2006 18:26:22 +0200, Andreas L Delmelle wrote
> 
>>On Jul 19, 2006, at 17:16, Andreas L Delmelle wrote:
>>
>><snip />
>>
>>To illustrate what I mean (untested, but seems OK, for positive  
>>numbers at least... gotta leave some to you ;)):
>>
>><xsl:template match="someNum">
>>   <xsl:variable name="vSum" select="sum(preceding::someNum)" />
>>   <xsl:variable name="vInt" select="floor($vSum)" />
>>   <xsl:variable name="vFrac" select="$vSum - $vInt" />
>>
>>   <fo:block>
>>     <fo:marker marker-class-name="intMarker">
>>       <xsl:value-of select="$vInt" />
>>     </fo:marker>
>>     <fo:marker marker-class-name="fracMarker">
>>       <xsl:value-of select="substring(string($vFrac),3))" />
>>     </fo:marker>
>>   </fo:block>
>></xsl:template>
>>
>>and then
>>
>><xsl:template match="...">
>>   <fo:static-content>
>>   ...
>>     <xsl:text>integer part is </xsl:text>
>>     <fo:retrieve-marker retrieve-class-name="intMarker" .../>
>>     <xsl:text>fractional part is 0.</xsl:text>
>>     <fo:retrieve-marker retrieve-class-name="fracMarker" .../>
>>   ...
>></xsl:template>
>>
>>No?
>>
>>IOW: don't focus *too* much on retrieve-marker alone, perform both  
>>sum and separation *before* creating the markers.
>>Plus the usual completions, of course, like 'take care of floor();  
>>for negative numbers use ceiling() to obtain the integer part' and  
>>'take the absolute value of the fractional part'...
>>
>>HTH!
>>
>>Cheers,
>>
>>Andreas
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>>For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable [SOLVED]

Posted by pat <pa...@xvalheru.org>.
YES !!! That's it !!! That's the way :-)

My problem was that I firstly counted the summary and then I've try to split
the fraction instead firstly count the integer and fraction and then only
disply them.

Thanks a lot !!!

     Pat

On Wed, 19 Jul 2006 18:26:22 +0200, Andreas L Delmelle wrote
> On Jul 19, 2006, at 17:16, Andreas L Delmelle wrote:
> 
> <snip />
> 
> To illustrate what I mean (untested, but seems OK, for positive  
> numbers at least... gotta leave some to you ;)):
> 
> <xsl:template match="someNum">
>    <xsl:variable name="vSum" select="sum(preceding::someNum)" />
>    <xsl:variable name="vInt" select="floor($vSum)" />
>    <xsl:variable name="vFrac" select="$vSum - $vInt" />
> 
>    <fo:block>
>      <fo:marker marker-class-name="intMarker">
>        <xsl:value-of select="$vInt" />
>      </fo:marker>
>      <fo:marker marker-class-name="fracMarker">
>        <xsl:value-of select="substring(string($vFrac),3))" />
>      </fo:marker>
>    </fo:block>
> </xsl:template>
> 
> and then
> 
> <xsl:template match="...">
>    <fo:static-content>
>    ...
>      <xsl:text>integer part is </xsl:text>
>      <fo:retrieve-marker retrieve-class-name="intMarker" .../>
>      <xsl:text>fractional part is 0.</xsl:text>
>      <fo:retrieve-marker retrieve-class-name="fracMarker" .../>
>    ...
> </xsl:template>
> 
> No?
> 
> IOW: don't focus *too* much on retrieve-marker alone, perform both  
> sum and separation *before* creating the markers.
> Plus the usual completions, of course, like 'take care of floor();  
> for negative numbers use ceiling() to obtain the integer part' and  
> 'take the absolute value of the fractional part'...
> 
> HTH!
> 
> Cheers,
> 
> Andreas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by "Peter B. West" <li...@pbw.id.au>.
Peter B. West wrote:
> Andreas L Delmelle wrote:
> 
>> On Jul 19, 2006, at 17:16, Andreas L Delmelle wrote:
>>
>> <snip />
>>
>> To illustrate what I mean (untested, but seems OK, for positive  
>> numbers at least... gotta leave some to you ;)):
>>
>> <xsl:template match="someNum">
>>   <xsl:variable name="vSum" select="sum(preceding::someNum)" />
>>   <xsl:variable name="vInt" select="floor($vSum)" />
>>   <xsl:variable name="vFrac" select="$vSum - $vInt" />
>>
>>   <fo:block>
>>     <fo:marker marker-class-name="intMarker">
>>       <xsl:value-of select="$vInt" />
>>     </fo:marker>
>>     <fo:marker marker-class-name="fracMarker">
>>       <xsl:value-of select="substring(string($vFrac),3))" />
>>     </fo:marker>
>>   </fo:block>
>> </xsl:template>
>>
>> and then
>>
>> <xsl:template match="...">
>>   <fo:static-content>
>>   ...
>>     <xsl:text>integer part is </xsl:text>
>>     <fo:retrieve-marker retrieve-class-name="intMarker" .../>
>>     <xsl:text>fractional part is 0.</xsl:text>
>>     <fo:retrieve-marker retrieve-class-name="fracMarker" .../>
>>   ...
>> </xsl:template>
>>
>>
>> No?
>>
>> IOW: don't focus *too* much on retrieve-marker alone, perform both  
>> sum and separation *before* creating the markers.
>> Plus the usual completions, of course, like 'take care of floor();  
>> for negative numbers use ceiling() to obtain the integer part' and  
>> 'take the absolute value of the fractional part'...
>>
> 
> 
> Except on the money market, money amounts are integers; integral numbers 
> of cents or equivalent.  Work with the basics units and format for output.
> 
> Peter

A pretty pointless comment here, given the limitations of sum().

Peter
-- 
Peter B. West <http://cv.pbw.id.au/>
Folio <http://defoe.sourceforge.net/folio/>

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by "Peter B. West" <li...@pbw.id.au>.
Andreas L Delmelle wrote:
> On Jul 19, 2006, at 17:16, Andreas L Delmelle wrote:
> 
> <snip />
> 
> To illustrate what I mean (untested, but seems OK, for positive  numbers 
> at least... gotta leave some to you ;)):
> 
> <xsl:template match="someNum">
>   <xsl:variable name="vSum" select="sum(preceding::someNum)" />
>   <xsl:variable name="vInt" select="floor($vSum)" />
>   <xsl:variable name="vFrac" select="$vSum - $vInt" />
> 
>   <fo:block>
>     <fo:marker marker-class-name="intMarker">
>       <xsl:value-of select="$vInt" />
>     </fo:marker>
>     <fo:marker marker-class-name="fracMarker">
>       <xsl:value-of select="substring(string($vFrac),3))" />
>     </fo:marker>
>   </fo:block>
> </xsl:template>
> 
> and then
> 
> <xsl:template match="...">
>   <fo:static-content>
>   ...
>     <xsl:text>integer part is </xsl:text>
>     <fo:retrieve-marker retrieve-class-name="intMarker" .../>
>     <xsl:text>fractional part is 0.</xsl:text>
>     <fo:retrieve-marker retrieve-class-name="fracMarker" .../>
>   ...
> </xsl:template>
> 
> 
> No?
> 
> IOW: don't focus *too* much on retrieve-marker alone, perform both  sum 
> and separation *before* creating the markers.
> Plus the usual completions, of course, like 'take care of floor();  for 
> negative numbers use ceiling() to obtain the integer part' and  'take 
> the absolute value of the fractional part'...
> 


Except on the money market, money amounts are integers; integral numbers 
of cents or equivalent.  Work with the basics units and format for output.

Peter
-- 
Peter B. West <http://cv.pbw.id.au/>
Folio <http://defoe.sourceforge.net/folio/>

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Jul 19, 2006, at 17:16, Andreas L Delmelle wrote:

<snip />

To illustrate what I mean (untested, but seems OK, for positive  
numbers at least... gotta leave some to you ;)):

<xsl:template match="someNum">
   <xsl:variable name="vSum" select="sum(preceding::someNum)" />
   <xsl:variable name="vInt" select="floor($vSum)" />
   <xsl:variable name="vFrac" select="$vSum - $vInt" />

   <fo:block>
     <fo:marker marker-class-name="intMarker">
       <xsl:value-of select="$vInt" />
     </fo:marker>
     <fo:marker marker-class-name="fracMarker">
       <xsl:value-of select="substring(string($vFrac),3))" />
     </fo:marker>
   </fo:block>
</xsl:template>

and then

<xsl:template match="...">
   <fo:static-content>
   ...
     <xsl:text>integer part is </xsl:text>
     <fo:retrieve-marker retrieve-class-name="intMarker" .../>
     <xsl:text>fractional part is 0.</xsl:text>
     <fo:retrieve-marker retrieve-class-name="fracMarker" .../>
   ...
</xsl:template>


No?

IOW: don't focus *too* much on retrieve-marker alone, perform both  
sum and separation *before* creating the markers.
Plus the usual completions, of course, like 'take care of floor();  
for negative numbers use ceiling() to obtain the integer part' and  
'take the absolute value of the fractional part'...


HTH!


Cheers,

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Jul 19, 2006, at 09:46, pat wrote:

Hi,

> So, the creation of two markers is not possible (addition of  
> fraction can
> produce integer part :-\).

I don't get it...
1) you calculate the sum
2) then split that sum in integer and fraction
3) create two markers from the results.

What would be wrong with that? You can use the result from step 1) as  
a basis for calculating the next sum (not: add integer to integer and  
fraction to fraction)

Cheers,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by Glen Mazza <gm...@apache.org>.
pat wrote:

>Hi,
>
>Well, the template is for kind of "bill" for Czech postal service and they
>require to split payment to integer part and the fraction (don't ask me why).
>
>  
>

Yes, the Czech postal service is a constant source of problems on this 
ML.   ;-)

>So, the creation of two markers is not possible (addition of fraction can
>produce integer part :-\). The way should be adding all prices on the page and
>then split integer and fraction (split 10.50 as 10 and 50 in two separated
>columns in table).
>
>In the fo:flow is used:
><fo:marker marker-class-name="subtotal">
>   <xsl:value-of select="price + sum(preceding::price)"/>
></fo:marker>
>
>and in <fo:static-content flow-name="xsl-region-after"> thers's:
><fo:block text-align-last="end" font-size="12pt">
>   <fo:retrieve-marker retrieve-class-name="subtotal" retrieve-boundary="page"
>       retrieve-position="last-starting-within-page"/>
></fo:block>
>
>I have played a bit with setting the marker value to variable and I've found this:
>1) variable definition:
><xsl:variable name="tmp">
>   <fo:retrieve-marker ... />
></xsl:variable>
>2) reading $tmp by <xsl:copy-of select="$tmp"/> gave me a requested number
>3) reading $tmp by <xsl:value-of select="$tmp"/> does nothing
>
>  
>

I would stop thinking about using xsl: tags.  Again, they all disappear 
before the fo: tags are activated.  By the time fo:retrieve-marker has a 
value, the xsl:anything stuff is long gone from the stylesheet.

Instead, I wonder if you can use div and mod[1] to get the portions you 
need.  I haven't done this before with XSL, however.

$55.28 * 100 = 5528 mod 100 = 28?
$55.28 * 100 = 5528 - ($55.28 * 100 mod 100) = 5000 div 100 = 50?

I don't know if <fo:retrieve-marker/> can be used in place of $55.28 
above though.

Glen

[1] 
http://www.w3.org/TR/2001/REC-xsl-20011015/slice5.html#section-N6961-Expressions


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by pat <pa...@xvalheru.org>.
On Tue, 18 Jul 2006 09:06:00 -0400, Glen Mazza wrote
> pat wrote:
> 
> >Hi all,
> >
> >I have a problem and I'm not able to solve it :-( I'm using marker to generate
> >subtotat (it works) and for retrievng the subtotal I'm using retrieve-marker
> >(that works too), but I need to split subtotal to part before decimal point
> >and after decimal point ant this is the problem. How to store the value from
> >retrieve-marker to variable or use it directly ???
> >
> >I'm looking for something like this:
> ><xsl:variable name="qqq">
> >  <fo:retrieve-marker .../>
> ></xsl:variable>
> >
> >Is there a way how to do that ???
> >
> >  
> >
> I don't think so.  By the time FOP is processing your input XML, it 
> is fully in the FO namespace.  (It initially uses Xalan--or Saxon--
> to do the XSLT transformations, replacing your xsl: elements with 
> the result tree of your XSLT transformation.)  The xsl: elements are 
> all gone by the time FOP is processing fo:retrieve-marker.
> 
> It may be helpful for others to be able to answer your question if 
> you let us know what type of data you are handling and why you need 
> this functionality.  There may be another way to accomplish what you 
> need here.
> 
> Glen

Hi,

Well, the template is for kind of "bill" for Czech postal service and they
require to split payment to integer part and the fraction (don't ask me why).

So, the creation of two markers is not possible (addition of fraction can
produce integer part :-\). The way should be adding all prices on the page and
then split integer and fraction (split 10.50 as 10 and 50 in two separated
columns in table).

In the fo:flow is used:
<fo:marker marker-class-name="subtotal">
   <xsl:value-of select="price + sum(preceding::price)"/>
</fo:marker>

and in <fo:static-content flow-name="xsl-region-after"> thers's:
<fo:block text-align-last="end" font-size="12pt">
   <fo:retrieve-marker retrieve-class-name="subtotal" retrieve-boundary="page"
       retrieve-position="last-starting-within-page"/>
</fo:block>

I have played a bit with setting the marker value to variable and I've found this:
1) variable definition:
<xsl:variable name="tmp">
   <fo:retrieve-marker ... />
</xsl:variable>
2) reading $tmp by <xsl:copy-of select="$tmp"/> gave me a requested number
3) reading $tmp by <xsl:value-of select="$tmp"/> does nothing

I expect the problem is, that I'm not able to read the $tmp by <xsl:value-of
...>. Finally I need to do something like:
<xsl:value-of select="substring-after($tmp, '.')"/> to get fraction etc.

Can someone help me on that ???

Thanks a lot.

     Pat

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: marker value to variable

Posted by Glen Mazza <gm...@apache.org>.
pat wrote:

>Hi all,
>
>I have a problem and I'm not able to solve it :-( I'm using marker to generate
>subtotat (it works) and for retrievng the subtotal I'm using retrieve-marker
>(that works too), but I need to split subtotal to part before decimal point
>and after decimal point ant this is the problem. How to store the value from
>retrieve-marker to variable or use it directly ???
>
>I'm looking for something like this:
><xsl:variable name="qqq">
>  <fo:retrieve-marker .../>
></xsl:variable>
>
>Is there a way how to do that ???
>
>  
>
I don't think so.  By the time FOP is processing your input XML, it is 
fully in the FO namespace.  (It initially uses Xalan--or Saxon--to do 
the XSLT transformations, replacing your xsl: elements with the result 
tree of your XSLT transformation.)  The xsl: elements are all gone by 
the time FOP is processing fo:retrieve-marker.

It may be helpful for others to be able to answer your question if you 
let us know what type of data you are handling and why you need this 
functionality.  There may be another way to accomplish what you need here.

Glen


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org