Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2013, 08:46 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default Set Attribute Value for "extent"

Hello,

Could somebody please show me the syntax of setting the "extent" attribute
to the same value of the "margin-top" attribute of the <fo:region-body>
Code:
 <fo:simple-page-master>
    <fo:region-before>
      <xsl:attribute name="extent">
  
      I want to set the "extent" attribute here to the same value as the 
      "margin-top" attribute of the <fo:region-body>
Many thanks!
Rita
 
Old February 6th, 2013, 07:28 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Hi,

Are you using XSLT to generate your FO File?
 
Old February 6th, 2013, 11:32 AM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default Set Attribute Value for "extent"

Yes, XSLT version 1.0 is being used.
 
Old February 7th, 2013, 07:49 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Great. So In order so someone to help, please provide a snippet of your relevant XML and the area of the XSLT that process it. You original post does not give enough information.
 
Old February 7th, 2013, 04:45 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default Set Attribute Value for "extent"

I want to set the value of the attribute "extent" in the <region-before> to the same value as the attribute "margin-top" in the <region-body" since they are the same - without repeating the same code in the <region-before>.

Code:
      <fo:layout-master-set>
        <fo:simple-page-master master-name="repeating" page-height="28cm" page-width="22cm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="0cm">
          <fo:region-body>
            <xsl:attribute name="margin-top">
              <xsl:choose>
                <xsl:when test="(EOB/PKCREVIEWONLYFLAG[.='D'] or EOB/PKCREVIEWONLYFLAG[.='R']) and EOB/PAYKINDCODEDESC[.!='']">
                  <xsl:value-of select="format-number($varHeaderMinHeight_DEFAULT_PDF+(($varHeadingRows + .3)*$varLineHeight_DEFAULT_PDF)+.1,'#.00')"/>
                  <xsl:value-of select="$varUnitOfMeasure_DEFAULT_PDF"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="format-number($varHeaderMinHeight_DEFAULT_PDF+($varHeadingRows*$varLineHeight_DEFAULT_PDF)+.1,'#.00')"/>
                  <xsl:value-of select="$varUnitOfMeasure_DEFAULT_PDF"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:attribute>
            <xsl:attribute name="margin-bottom">
              <xsl:value-of select="format-number(count(EOB/TRAILER/TRAILERLINE[.!=''])*$varLineHeight_DEFAULT_PDF+$varHeadingLineHeight_DEFAULT_PDF,'#.00')"/>
              <xsl:value-of select="$varUnitOfMeasure_DEFAULT_PDF"/>
            </xsl:attribute>
          </fo:region-body>                    
          <fo:region-before>
            <xsl:attribute name="extent">
              <xsl:choose>
                <xsl:when test="(EOB/PKCREVIEWONLYFLAG[.='D'] or EOB/PKCREVIEWONLYFLAG[.='R']) and EOB/PAYKINDCODEDESC[.!='']">
                  <xsl:value-of select="format-number($varHeaderMinHeight_DEFAULT_PDF+(($varHeadingRows + .3)*$varLineHeight_DEFAULT_PDF)+.1,'#.00')"/>
                  <xsl:value-of select="$varUnitOfMeasure_DEFAULT_PDF"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="format-number($varHeaderMinHeight_DEFAULT_PDF+($varHeadingRows*$varLineHeight_DEFAULT_PDF)+.1,'#.00')"/>
                  <xsl:value-of select="$varUnitOfMeasure_DEFAULT_PDF"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:attribute>
          </fo:region-before>
 
Old February 8th, 2013, 06:53 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

I believe the best approach is to use a variable and a named template. With named templates you can pass in parameters. Here is my suggestions. Keep in mind I do not have an xml input and this is untested, but the approach can be easy to duplicate in your real code:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:template match="/">
		<fo:layout-master-set>
			<fo:simple-page-master master-name="repeating" page-height="28cm" page-width="22cm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="0cm">
				<xsl:variable name="size">
					<xsl:call-template name="reg-sizes">
						<xsl:with-param name="headrows">10</xsl:with-param>
						<xsl:with-param name="lineheight">35</xsl:with-param>
						<xsl:with-param name="lineheightminmax">2</xsl:with-param>
						<xsl:with-param name="uom">px</xsl:with-param>
					</xsl:call-template>
				</xsl:variable>
				<xsl:variable name="varLineHeight_DEFAULT_PDF" select="string('2')"></xsl:variable>
				<xsl:variable name="varHeadingLineHeight_DEFAULT_PDF" select="string('2')"></xsl:variable>
				<xsl:variable name="varUnitOfMeasure_DEFAULT_PDF" select="string('2')"></xsl:variable>
				<fo:region-body>
					<xsl:attribute name="margin-top">
						<xsl:value-of select="$size"/>
					</xsl:attribute>
					<xsl:attribute name="margin-bottom">
						<xsl:value-of select="format-number(count(EOB/TRAILER/TRAILERLINE[.!=''])*$varLineHeight_DEFAULT_PDF+$varHeadingLineHeight_DEFAULT_PDF,'#.00')"/>
						<xsl:value-of select="$varUnitOfMeasure_DEFAULT_PDF"/>
					</xsl:attribute>
				</fo:region-body>
				<fo:region-before>
					<xsl:attribute name="extent">
							<xsl:value-of select="$size"/>
					</xsl:attribute>
				</fo:region-before>
			</fo:simple-page-master>
		</fo:layout-master-set>
	</xsl:template>
	<xsl:template name="reg-sizes">
		<xsl:param name="headrows"/>
		<xsl:param name="lineheight"/>
		<xsl:param name="lineheightminmax"/>
		<xsl:param name="uom"/>
		<xsl:choose>
			<xsl:when test="(EOB/PKCREVIEWONLYFLAG[.='D'] or EOB/PKCREVIEWONLYFLAG[.='R']) and EOB/PAYKINDCODEDESC[.!='']">
				<xsl:value-of select="format-number($lineheightminmax+(($headrows + .3)*$lineheight)+.1,'#.00')"/>
				<xsl:value-of select="$uom"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="format-number($lineheightminmax+($headrows*$lineheight)+.1,'#.00')"/>
				<xsl:value-of select="$uom"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
The Following User Says Thank You to bonekrusher For This Useful Post:
ritagr (February 8th, 2013)
 
Old February 8th, 2013, 05:10 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default Set Attribute Value for "extent"

Thank you "bonekrusher"!
Your code is exactly what I was looking for.
So simple now that I can see how it's done!

Many thanks for your help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting "margin-top" Attribute of <fo:region-body> ritagr XSLT 0 January 18th, 2013 05:37 PM
"type" attribute in <script> tag Latinsteps BOOK: Beginning JavaScript 4th Edition 2 September 6th, 2011 01:29 AM
"type" attribute missing in $pres() responce senpai BOOK: Professional XMPP Programming with JavaScript and jQuery 11 April 21st, 2010 12:14 PM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
MasterPage Attribute alink "Outdated?" Psyclist BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 March 28th, 2009 05:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.