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 "Steffanina, Jeff" <Je...@marriott.com> on 2008/08/25 19:07:05 UTC

0.95 - Printing a string and aligning the decimal points

Friends,


Existing Code in my XML file (the decimal points are aligned when using
Courier font):

<euro-tax-msg5>Quebec Native Seal Tax
15.42</euro-tax-msg5>
<euro-tax-msg6>BIG UPPER CASE TAX INO
439.59</euro-tax-msg6>

--------------------------
My XSL that prints (using Arial font):

<fo:block white-space-collapse="false" linefeed-treatment="preserve"
text-align="start" >
                 <xsl:text>&#x0A;</xsl:text>
                <xsl:value-of select="./euro-tax-msg5"/>
               <xsl:text>&#x0A;</xsl:text>
                <xsl:value-of select="./euro-tax-msg6"/>
                <xsl:text>&#x0A;</xsl:text>
        </fo:block>
-----------------------------
My Result:
    Thelkj lk laksjf lkasjd flkajs flkj    15.42
    Wakadf wlkej salksdjf HHHH         349.54


Without creating a table, is there a way to get the text to align left
and the digits to align right?

I thank you for any suggestions.


Jeff 

RE: 0.95 - Printing a string and aligning the decimal points

Posted by "Steffanina, Jeff" <Je...@marriott.com>.
 
David,
Your solution worked PERFECTLY!   
 
Thank you very much
 

Jeff 


________________________________

	From: David Gerdt [mailto:Dgerdt@bju.edu] 
	Sent: Monday, August 25, 2008 3:22 PM
	To: fop-users@xmlgraphics.apache.org
	Subject: RE: 0.95 - Printing a string and aligning the decimal
points
	
	
	Yes, definitely. I assumed because you hadn't done this already
that the XML data was out of your hands. But yes, if you can make the
XML a little more granular like you demonstrate then you don't need an
extra template at all. Just put a <fo:leader/> between the label and the
amount, and set the block's text-align-last to justify. So...
	 
	<fo:block white-space-collapse="false"
linefeed-treatment="preserve" text-align-last="justify" > 
	     <xsl:text>&#x0A;</xsl:text> 
	     <xsl:value-of select="euro-tax-msg5"/> 
	     <fo:leader/>
	     <xsl:value-of select="euro-tax-msg5-amt"/> 
	     <xsl:text>&#x0A;</xsl:text> 
	     <xsl:value-of select="euro-tax-msg6"/> 
	     <fo:leader/>
	     <xsl:value-of select="euro-tax-msg6-amt"/> 
	     <xsl:text>&#x0A;</xsl:text> 
	</fo:block>
	 

	>>> "Steffanina, Jeff" <Je...@marriott.com> 8/25/2008
3:00 PM >>>
	
	David,
	I can't make that guarantee of the space you mentioned.  Can I
make it more simple if I split the string into Description and Amount as
follows (again, my goal is to align the descriptions and the decimal
points):

	<euro-tax-msg5>Quebec Native Seal Tax</euro-tax-msg5>

	<euro-tax-msg5-amt>15.42</euro-tax-msg5-amt> 
	

	<euro-tax-msg6>BIG UPPER CASE TAX INO</euro-tax-msg6>

	euro-tax-msg6-amt>439.59</euro-tax-msg6-amt> 

	-------------------------- 
	Jeff 
	

________________________________

		From: David Gerdt [mailto:Dgerdt@bju.edu] 
		Sent: Monday, August 25, 2008 2:23 PM
		To: fop-users@xmlgraphics.apache.org
		Subject: Re: 0.95 - Printing a string and aligning the
decimal points
		
		
		Assuming you can guarantee that there will always be at
least two spaces between the text and the digits, could you do something
like the following?
		 
		<fo:block white-space-collapse="false"
linefeed-treatment="preserve" text-align-last="justify" > 
		     <xsl:text>&#x0A;</xsl:text> 
		     <xsl:call-template name="split">
		          <xsl:with-param name="string"
select="euro-tax-msg5" />
		     </xsl:call-template>
		     <xsl:text>&#x0A;</xsl:text> 
		     <xsl:call-template name="split">
		          <xsl:with-param name="string"
select="euro-tax-msg6" />
		     </xsl:call-template>
		     <xsl:text>&#x0A;</xsl:text> 
		</fo:block>
		 
		 
		<xsl:template name="split">
		     <xsl:param name="string" />
		     <xsl:variable name="first"
select="substring-before($string,'  ')" />
		     <xsl:variable name="rest"
select="substring-after($string,'  ')" />
		     <xsl:value-of select="$first"
/><fo:leader/><xsl:value-of select="$rest" />
		</xsl:template>
		 


		>>> "Steffanina, Jeff" <Je...@marriott.com>
8/25/2008 1:07 PM >>>
		

		Friends, 


		Existing Code in my XML file (the decimal points are
aligned when using Courier font): 

		<euro-tax-msg5>Quebec Native Seal Tax
15.42</euro-tax-msg5> 
		<euro-tax-msg6>BIG UPPER CASE TAX INO
439.59</euro-tax-msg6> 

		-------------------------- 
		My XSL that prints (using Arial font): 

		<fo:block white-space-collapse="false"
linefeed-treatment="preserve" text-align="start" > 
		                 <xsl:text>&#x0A;</xsl:text> 
		                <xsl:value-of select="./euro-tax-msg5"/>

		               <xsl:text>&#x0A;</xsl:text> 
		                <xsl:value-of select="./euro-tax-msg6"/>

		                <xsl:text>&#x0A;</xsl:text> 
		        </fo:block> 
		----------------------------- 
		My Result: 
		    Thelkj lk laksjf lkasjd flkajs flkj    15.42 
		    Wakadf wlkej salksdjf HHHH         349.54 


		Without creating a table, is there a way to get the text
to align left and the digits to align right? 

		I thank you for any suggestions. 


		Jeff 


RE: 0.95 - Printing a string and aligning the decimal points

Posted by David Gerdt <Dg...@bju.edu>.
Yes, definitely. I assumed because you hadn't done this already that the XML data was out of your hands. But yes, if you can make the XML a little more granular like you demonstrate then you don't need an extra template at all. Just put a <fo:leader/> between the label and the amount, and set the block's text-align-last to justify. So...
 
<fo:block white-space-collapse="false" linefeed-treatment="preserve" text-align-last="justify" > 
     <xsl:text>&#x0A;</xsl:text> 
     <xsl:value-of select="euro-tax-msg5"/> 
     <fo:leader/>
     <xsl:value-of select="euro-tax-msg5-amt"/> 
     <xsl:text>&#x0A;</xsl:text> 
     <xsl:value-of select="euro-tax-msg6"/> 
     <fo:leader/>
     <xsl:value-of select="euro-tax-msg6-amt"/> 
     <xsl:text>&#x0A;</xsl:text> 
</fo:block>
 

>>> "Steffanina, Jeff" <Je...@marriott.com> 8/25/2008 3:00 PM >>>
David,
I can't make that guarantee of the space you mentioned.  Can I make it more simple if I split the string into Description and Amount as follows (again, my goal is to align the descriptions and the decimal points):

<euro-tax-msg5>Quebec Native Seal Tax</euro-tax-msg5>
<euro-tax-msg5-amt>15.42</euro-tax-msg5-amt> 

<euro-tax-msg6>BIG UPPER CASE TAX INO</euro-tax-msg6>
euro-tax-msg6-amt>439.59</euro-tax-msg6-amt> 
-------------------------- 
Jeff 


From: David Gerdt [mailto:Dgerdt@bju.edu] 
Sent: Monday, August 25, 2008 2:23 PM
To: fop-users@xmlgraphics.apache.org 
Subject: Re: 0.95 - Printing a string and aligning the decimal points

Assuming you can guarantee that there will always be at least two spaces between the text and the digits, could you do something like the following?
 
<fo:block white-space-collapse="false" linefeed-treatment="preserve" text-align-last="justify" > 
     <xsl:text>&#x0A;</xsl:text> 
     <xsl:call-template name="split">
          <xsl:with-param name="string" select="euro-tax-msg5" />
     </xsl:call-template>
     <xsl:text>&#x0A;</xsl:text> 
     <xsl:call-template name="split">
          <xsl:with-param name="string" select="euro-tax-msg6" />
     </xsl:call-template>
     <xsl:text>&#x0A;</xsl:text> 
</fo:block>
 
 
<xsl:template name="split">
     <xsl:param name="string" />
     <xsl:variable name="first" select="substring-before($string,'  ')" />
     <xsl:variable name="rest" select="substring-after($string,'  ')" />
     <xsl:value-of select="$first" /><fo:leader/><xsl:value-of select="$rest" />
</xsl:template>
 


>>> "Steffanina, Jeff" <Je...@marriott.com> 8/25/2008 1:07 PM >>>

Friends, 

Existing Code in my XML file (the decimal points are aligned when using Courier font): 
<euro-tax-msg5>Quebec Native Seal Tax                      15.42</euro-tax-msg5> 
<euro-tax-msg6>BIG UPPER CASE TAX INO              439.59</euro-tax-msg6> 
-------------------------- 
My XSL that prints (using Arial font): 
<fo:block white-space-collapse="false" linefeed-treatment="preserve" text-align="start" > 
                 <xsl:text>&#x0A;</xsl:text> 
                <xsl:value-of select="./euro-tax-msg5"/> 
               <xsl:text>&#x0A;</xsl:text> 
                <xsl:value-of select="./euro-tax-msg6"/> 
                <xsl:text>&#x0A;</xsl:text> 
        </fo:block> 
----------------------------- 
My Result: 
    Thelkj lk laksjf lkasjd flkajs flkj    15.42 
    Wakadf wlkej salksdjf HHHH         349.54 

Without creating a table, is there a way to get the text to align left and the digits to align right? 
I thank you for any suggestions. 

Jeff 

RE: 0.95 - Printing a string and aligning the decimal points

Posted by "Steffanina, Jeff" <Je...@marriott.com>.
David,
I can't make that guarantee of the space you mentioned.  Can I make it
more simple if I split the string into Description and Amount as follows
(again, my goal is to align the descriptions and the decimal points):

<euro-tax-msg5>Quebec Native Seal Tax</euro-tax-msg5>

<euro-tax-msg5-amt>15.42</euro-tax-msg5-amt> 


<euro-tax-msg6>BIG UPPER CASE TAX INO</euro-tax-msg6>

euro-tax-msg6-amt>439.59</euro-tax-msg6-amt> 

-------------------------- 
Jeff 


________________________________

	From: David Gerdt [mailto:Dgerdt@bju.edu] 
	Sent: Monday, August 25, 2008 2:23 PM
	To: fop-users@xmlgraphics.apache.org
	Subject: Re: 0.95 - Printing a string and aligning the decimal
points
	
	
	Assuming you can guarantee that there will always be at least
two spaces between the text and the digits, could you do something like
the following?
	 
	<fo:block white-space-collapse="false"
linefeed-treatment="preserve" text-align-last="justify" > 
	     <xsl:text>&#x0A;</xsl:text> 
	     <xsl:call-template name="split">
	          <xsl:with-param name="string" select="euro-tax-msg5"
/>
	     </xsl:call-template>
	     <xsl:text>&#x0A;</xsl:text> 
	     <xsl:call-template name="split">
	          <xsl:with-param name="string" select="euro-tax-msg6"
/>
	     </xsl:call-template>
	     <xsl:text>&#x0A;</xsl:text> 
	</fo:block>
	 
	 
	<xsl:template name="split">
	     <xsl:param name="string" />
	     <xsl:variable name="first"
select="substring-before($string,'  ')" />
	     <xsl:variable name="rest" select="substring-after($string,'
')" />
	     <xsl:value-of select="$first" /><fo:leader/><xsl:value-of
select="$rest" />
	</xsl:template>
	 


	>>> "Steffanina, Jeff" <Je...@marriott.com> 8/25/2008
1:07 PM >>>
	

	Friends, 


	Existing Code in my XML file (the decimal points are aligned
when using Courier font): 

	<euro-tax-msg5>Quebec Native Seal Tax
15.42</euro-tax-msg5> 
	<euro-tax-msg6>BIG UPPER CASE TAX INO
439.59</euro-tax-msg6> 

	-------------------------- 
	My XSL that prints (using Arial font): 

	<fo:block white-space-collapse="false"
linefeed-treatment="preserve" text-align="start" > 
	                 <xsl:text>&#x0A;</xsl:text> 
	                <xsl:value-of select="./euro-tax-msg5"/> 
	               <xsl:text>&#x0A;</xsl:text> 
	                <xsl:value-of select="./euro-tax-msg6"/> 
	                <xsl:text>&#x0A;</xsl:text> 
	        </fo:block> 
	----------------------------- 
	My Result: 
	    Thelkj lk laksjf lkasjd flkajs flkj    15.42 
	    Wakadf wlkej salksdjf HHHH         349.54 


	Without creating a table, is there a way to get the text to
align left and the digits to align right? 

	I thank you for any suggestions. 


	Jeff 


Re: 0.95 - Printing a string and aligning the decimal points

Posted by David Gerdt <Dg...@bju.edu>.
Assuming you can guarantee that there will always be at least two spaces between the text and the digits, could you do something like the following?
 
<fo:block white-space-collapse="false" linefeed-treatment="preserve" text-align-last="justify" > 
     <xsl:text>&#x0A;</xsl:text> 
     <xsl:call-template name="split">
          <xsl:with-param name="string" select="euro-tax-msg5" />
     </xsl:call-template>
     <xsl:text>&#x0A;</xsl:text> 
     <xsl:call-template name="split">
          <xsl:with-param name="string" select="euro-tax-msg6" />
     </xsl:call-template>
     <xsl:text>&#x0A;</xsl:text> 
</fo:block>
 
 
<xsl:template name="split">
     <xsl:param name="string" />
     <xsl:variable name="first" select="substring-before($string,'  ')" />
     <xsl:variable name="rest" select="substring-after($string,'  ')" />
     <xsl:value-of select="$first" /><fo:leader/><xsl:value-of select="$rest" />
</xsl:template>
 


>>> "Steffanina, Jeff" <Je...@marriott.com> 8/25/2008 1:07 PM >>>

Friends, 

Existing Code in my XML file (the decimal points are aligned when using Courier font): 
<euro-tax-msg5>Quebec Native Seal Tax                      15.42</euro-tax-msg5> 
<euro-tax-msg6>BIG UPPER CASE TAX INO              439.59</euro-tax-msg6> 
-------------------------- 
My XSL that prints (using Arial font): 
<fo:block white-space-collapse="false" linefeed-treatment="preserve" text-align="start" > 
                 <xsl:text>&#x0A;</xsl:text> 
                <xsl:value-of select="./euro-tax-msg5"/> 
               <xsl:text>&#x0A;</xsl:text> 
                <xsl:value-of select="./euro-tax-msg6"/> 
                <xsl:text>&#x0A;</xsl:text> 
        </fo:block> 
----------------------------- 
My Result: 
    Thelkj lk laksjf lkasjd flkajs flkj    15.42 
    Wakadf wlkej salksdjf HHHH         349.54 

Without creating a table, is there a way to get the text to align left and the digits to align right? 
I thank you for any suggestions. 

Jeff