 |
| 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
|
|
|
|

April 20th, 2011, 09:08 AM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
PDF giving first page as blank if page count > 1 using xsl:fo
Hi All,
I am generating a pdf from xsl:fo with 5x2 labels (10 )on each page , if lables are more than 10 it is giving first page as blank, second page onwards it is prinitng...
Could some one help me, i am having the code as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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="/candidates">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8in" page-height="11.5in">
<fo:region-body margin-top="0.80in" margin-bottom="0.20in" margin-left="0.20in" margin-right="0.20in" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:table text-align="center" border-spacing="3pt">
<fo:table-column column-number="1" />
<fo:table-column column-number="2" />
<fo:table-header>
<fo:table-row>
<fo:table-cell number-columns-spanned="2">
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:apply-templates select="report-bO/candidate-ro-details"/>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="report-bO/candidate-ro-details">
<fo:table-row>
<fo:table-cell height="5cm" overflow="hidden" number-rows-spanned="2" number-columns-spanned="1">
<fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve"><xsl:value-of select="attendancenumber"/></fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve"><xsl:value-of select="roname"/></fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve"><xsl:value-of select="contactname"/></fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve"><xsl:value-of select="filecasenumber"/></fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" ><xsl:value-of select="addressline1"/></fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" ><xsl:value-of select="addressline2"/></fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" ><xsl:value-of select="addressline3"/>
<xsl:choose>
<xsl:when test="(string-length(addressline4)>0)">
, <xsl:value-of select="addressline4"/>
</xsl:when>
<xsl:otherwise>
<fo:leader/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt"><xsl:value-of select="addressline5"/>
<xsl:choose>
<xsl:when test="(string-length(addressline6)>0)">
, <xsl:value-of select="addressline6"/>
</xsl:when>
<xsl:otherwise>
<fo:leader/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
<fo:block text-align="left" font-size="20pt"><fo:leader/></fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
|
|

April 26th, 2011, 04:45 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
|
|
With out seeing the xml input or the resulting FO, its hard to determine what your issue is. It could be a number of reasons.
|
|

April 27th, 2011, 02:51 AM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi ,
Thanks for the reply, Here is the xml input.
If you need any information , please let me know.
<?xml version="1.0" encoding="UTF-8"?>
<candidates>
<report-bO>
<candidate-ro-details>
<candidatenumber>206498292_20100417_84212</candidatenumber>
<addressline1>UCAS 10 1016666709</addressline1>
<addressline2>Frenchay Campus</addressline2>
<addressline3>Coldharbour Lane</addressline3>
<addressline4>Bristol BS16 1QY</addressline4>
<roid>29611</roid>
<roname>University of West of England</roname>
<attendancenumber>000045</attendancenumber>
<candidateroid>41247</candidateroid>
</candidate-ro-details>
<candidate-ro-details>
<candidatenumber>206498292_20100417_84212</candidatenumber>
<addressline1>8 Floor Laver Building</addressline1>
<addressline2>North Park Road</addressline2>
<addressline3>Exeter</addressline3>
<addressline4>EX4 4QE</addressline4>
<roid>30046</roid>
<roname>Admissions Office, University of Exeter</roname>
<attendancenumber>000045</attendancenumber>
<candidateroid>41246</candidateroid>
</candidate-ro-details>
</report-bO>
<report-bO>
<candidate-ro-details>
<candidatenumber>209004185_20100417_84212</candidatenumber>
<addressline1>GPO BOX 4932</addressline1>
<addressline2>Melbourne</addressline2>
<addressline3>Vic 3001</addressline3>
<addressline4>Australia</addressline4>
<roid>30143</roid>
<roname>Nurses Board of Victoria</roname>
<attendancenumber>000046</attendancenumber>
<candidateroid>37172</candidateroid>
</candidate-ro-details>
</report-bO>
<report-bO>
<candidate-ro-details>
<candidatenumber>AN4189126_20100417_84212</candidatenumber>
<addressline1>United States of America</addressline1>
<addressline2>Bloomington IN</addressline2>
<roid>999</roid>
<roname>Indiana University</roname>
<attendancenumber>000049</attendancenumber>
<candidateroid>50802</candidateroid>
</candidate-ro-details>
<candidate-ro-details>
<candidatenumber>AN4189126_20100417_84212</candidatenumber>
<addressline1>Recruitment Office</addressline1>
<addressline2>University Rd</addressline2>
<addressline3>Southampton</addressline3>
<addressline4>SO17 1BJ</addressline4>
<roid>30052</roid>
<roname>University of Southampton</roname>
<attendancenumber>000049</attendancenumber>
<candidateroid>50801</candidateroid>
</candidate-ro-details>
<candidate-ro-details>
<candidatenumber>AN4189126_20100417_84212</candidatenumber>
<addressline1>University of Plymouth</addressline1>
<addressline2>Drake Circus</addressline2>
<addressline3>Plymouth</addressline3>
<addressline4>Devon, PL4 8AA</addressline4>
<roid>30026</roid>
<roname>Faculty of Education</roname>
<attendancenumber>000049</attendancenumber>
<candidateroid>50800</candidateroid>
</candidate-ro-details>
</report-bO>
<report-bO>
<candidate-ro-details>
<candidatenumber>15079078_20100417_84212</candidatenumber>
<addressline1>University of Plymouth</addressline1>
<addressline2>Drake Circus</addressline2>
<addressline3>Plymouth</addressline3>
<roid>29812</roid>
<roname>Faculty of Technology</roname>
<attendancenumber>000054</attendancenumber>
<candidateroid>38923</candidateroid>
</candidate-ro-details>
</report-bO>
<report-bO>
<candidate-ro-details>
<candidatenumber>05RE30726_20100417_84212</candidatenumber>
<addressline1>University Of Plymouth</addressline1>
<addressline2>Centre Court</addressline2>
<addressline3>Drake Circus</addressline3>
<addressline4>PL4 8AA</addressline4>
<roid>30067</roid>
<roname>Admissions Team</roname>
<attendancenumber>000087</attendancenumber>
<candidateroid>37089</candidateroid>
</candidate-ro-details>
</report-bO>
<report-bO>
<candidate-ro-details>
<candidatenumber>N1345250_20100417_84212</candidatenumber>
<addressline1>37 Wimpole Street</addressline1>
<addressline2>London</addressline2>
<addressline3>W1G 8DQ</addressline3>
<contactname>Sue Baptiste DCP Assessment</contactname>
<roid>29594</roid>
<roname>General Dental Council</roname>
<attendancenumber>000088</attendancenumber>
<candidateroid>36774</candidateroid>
</candidate-ro-details>
</report-bO>
<report-bO>
<candidate-ro-details>
<candidatenumber>109367468_20100417_84212</candidatenumber>
<addressline1>Unit 14 The Watermark</addressline1>
<addressline2>Leonards Road</addressline2>
<addressline3>Ivybridge PL21 0SZ</addressline3>
<roid>999</roid>
<roname>Susan Johnson</roname>
<attendancenumber>000089</attendancenumber>
<candidateroid>41122</candidateroid>
</candidate-ro-details>
</report-bO>
<report-bO>
<candidate-ro-details>
<candidatenumber>209529578_20100417_84212</candidatenumber>
<addressline1>PO BOX 873</addressline1>
<addressline2>Dickson Act 2602</addressline2>
<addressline3>Australia</addressline3>
<roid>30178</roid>
<roname>Australian Nursing and Midwifery Council</roname>
<attendancenumber>000092</attendancenumber>
<candidateroid>37623</candidateroid>
</candidate-ro-details>
</report-bO>
</candidates>
|
|

April 27th, 2011, 10:47 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
|
|
Hi,
You have 2 issues. First, you tell the FO processor to span rows, but the count doesnt match up. You tell the processor to span each row by 2, but the next row says the same thing. Also, each cell must have a block element.
I made some corrections:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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="/candidates">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8in" page-height="11.5in">
<fo:region-body margin-top="0.80in" margin-bottom="0.20in" margin-left="0.20in" margin-right="0.20in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:table text-align="center" border-spacing="3pt">
<fo:table-column column-number="1"/>
<fo:table-column column-number="2"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell number-columns-spanned="2">
<fo:block/>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:apply-templates select="report-bO/candidate-ro-details"/>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="report-bO/candidate-ro-details">
<fo:table-row>
<fo:table-cell height="5cm" number-columns-spanned="2">
<fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve">
<xsl:value-of select="attendancenumber"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve">
<xsl:value-of select="roname"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve">
<xsl:value-of select="contactname"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve">
<xsl:value-of select="filecasenumber"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt">
<xsl:value-of select="addressline1"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt">
<xsl:value-of select="addressline2"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt">
<xsl:value-of select="addressline3"/>
<xsl:choose>
<xsl:when test="(string-length(addressline4)>0)">
, <xsl:value-of select="addressline4"/>
</xsl:when>
<xsl:otherwise>
<fo:leader/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt">
<xsl:value-of select="addressline5"/>
<xsl:choose>
<xsl:when test="(string-length(addressline6)>0)">
, <xsl:value-of select="addressline6"/>
</xsl:when>
<xsl:otherwise>
<fo:leader/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
<fo:block text-align="left" font-size="20pt">
<fo:leader/>
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
|
|

April 27th, 2011, 11:36 AM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Format is missing:
Hi ,
Thanks for the mail , the lablels are displaying line by line sequentially , but have to displayed in below format only (side by side 2 labels)
10 labels in one page and the next 10 labels in 2ndpage and so on.
Format should be like below only
Label1..................Label2
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
Label3..................Label4
111111111111111 AAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
Label5..................Label6
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
Label7..................Label8
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
Label9..................Label10
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAAA
111111111111111 AAAAAAAAAAAAAAAAA
Label11-has to be in 2nd page.....
Thanks
Vishal
Last edited by srmxslca; April 27th, 2011 at 11:47 AM..
Reason: Editing the format
|
|

April 27th, 2011, 12:07 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
|
|
Hi Vishal,
Always happy to help. Your post said you were having trouble with the first page being blank, which I believe I answered. If you are having formatting issues, I would suggest doing some more reading on FO.
With that said, if you only want 10 labels per page you can add a page break:
Code:
<xsl:if test="(position() mod 10) = 0">
<xsl:attribute name="break-after"><xsl:text>page</xsl:text></xsl:attribute>
</xsl:if>
But you will have to rewrite your xslt to do this. You have asked for a cell height of 5cm, which causes a lot of whitespace.
In addition, you have leaders nested in fo:blocks, which causes white space
Code:
<fo:block text-align="left" font-size="20pt">
<fo:leader/>
</fo:block>
This is just a sample of how to do your conditional formatting. You will have to modify this code to get the desired output.
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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="/candidates">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8in" page-height="11.5in">
<fo:region-body margin-top="0.80in" margin-bottom="0.20in" margin-left="0.20in" margin-right="0.20in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:table text-align="center" border-spacing="3pt">
<fo:table-column column-number="1"/>
<fo:table-column column-number="2"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell number-columns-spanned="2">
<fo:block/>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:apply-templates select="report-bO/candidate-ro-details"/>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="report-bO/candidate-ro-details">
<fo:table-row>
<xsl:if test="(position() mod 10) = 0">
<xsl:attribute name="break-after"><xsl:text>page</xsl:text></xsl:attribute>
</xsl:if>
<fo:table-cell number-columns-spanned="2">
<fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve">
<xsl:value-of select="attendancenumber"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve">
<xsl:value-of select="roname"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve">
<xsl:value-of select="contactname"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt" white-space-collapse="false" white-space-treatment="preserve">
<xsl:value-of select="filecasenumber"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt">
<xsl:value-of select="addressline1"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt">
<xsl:value-of select="addressline2"/>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt">
<xsl:value-of select="addressline3"/>
<xsl:choose>
<xsl:when test="(string-length(addressline4)>0)">, <xsl:value-of select="addressline4"/>
</xsl:when>
<xsl:otherwise>
<fo:leader/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
<fo:block text-align="left" margin-left="40pt" font-size="10pt">
<xsl:value-of select="addressline5"/>
<xsl:choose>
<xsl:when test="(string-length(addressline6)>0)">, <xsl:value-of select="addressline6"/>
</xsl:when>
<xsl:otherwise>
<fo:leader/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
|
|

April 28th, 2011, 05:10 AM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi ,
Thanks for the reply.
My actual requirement is total 10 labels in page with each cell of height 5 cm, 5x2 labels in first page , in second page next 5X2 lables.
In this scenario i am getting the first page as blank page , if labels are more than 10.
Could you send me the email address , so that i can send the exact report i am getting.
Regards
Vishal
|
|

April 28th, 2011, 09:22 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
|
|
Hi Vishal,
I understand your requirements, but this forum is for helping xslt developers and not doing the actual work.
If you want 10 per page, look into grouping.
|
|

April 28th, 2011, 06:04 PM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi ,
Thanks for the Reply.
I am able to get 10 labels per page side by side , but my first page is always coming as blank.
I need a solution for that.
Could you please let me know some solution or an idea to progress further on this issue.
And the fop jar version also has an impact?
Regards
Vishal
|
|

April 29th, 2011, 08:48 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
|
|
Post your latest XSLT
|
|
 |