Subject: [xsl] Repeating text in table headers with dynamic values from child node From: Pankaj Yadav <yadavpankaj@xxxxxxxxx> Date: Thu, 1 Mar 2007 04:12:27 -0800 (PST) |
Dear All, I am using FOP version fop-0.20.5rc2 for generating PDF files on Windows XP box. I am facing a problem in repeating values in table header from chid node. To explain this in detail, I am enclosing a sample xml, required output and xsl I have written for that. I have following XML structure which needs to be displayed in a tabular format. The number of rows to be displayed in table is dynamic and would depend on number of StudentResultStruc in XML. If the table spans next page, the table headers need to repeated on next page. The XML layout is fixed and cannot be changed <ExamReport> <ClassData> <Class>I</Class> <StudentResultStruc> <DateOfTest>01/02/2006</DateOfTest> <TestNumber>T1</TestNumber> <StudentID>A1</StudentID> <GradeSub1>S1</GradeSub1> <GradeSub2>S2</GradeSub2> <Result>R1</Result> </StudentResultStruc> <StudentResultStruc> <TestNumber>T2</TestNumber> <StudentID>B1</StudentID> <GradeSub1>R1</GradeSub1> <GradeSub2>R2</GradeSub2> <Result>P1</Result> </StudentResultStruc> <StudentResultStruc> <TestNumber>T3</TestNumber> <StudentID>C1</StudentID> <GradeSub1>G1</GradeSub1> <GradeSub2>G2</GradeSub2> <Result>H1</Result> </StudentResultStruc> <StudentResultStruc> <DateOfTest>01/03/2007</DateOfTest> <TestNumber>T4</TestNumber> <StudentID>D1</StudentID> <GradeSub1>E1</GradeSub1> <GradeSub2>E2</GradeSub2> <Result>K1</Result> </StudentResultStruc> <ClassData> <ExamReport> The output table is as follows: -------------------------- Page 1 ---------------------------------------- Date of Test(s) 01/02/2006 Test Number Student ID Grade Sub 1 Grade Sub 2 Result T1 A1 S1 S2 R1 T2 B1 R1 R2 P1 If this table spans on next page then, the Date of Test and Table header need to repeat on next page as follows: -------------------------- Page 2 ---------------------------------------- Date of Test(s) 01/02/2006 Test Number Student ID Grade Sub 1 Grade Sub 2 Result T3 C1 G1 G2 H1 ---------------------------- on Change of Date, the headers need to appear again. Date of Test(s) 01/03/2007 Test Number Student ID Grade Sub 1 Grade Sub 2 Result T4 D1 E1 E2 K1 <xsl:template match="ClassData"> <fo:table table-layout="fixed" table-omit-header-at-break="false"> <fo:table-column column-width="480pt"/> <fo:table-header> <!-- ****** Dynamic Part of the Header ***** --> <fo:table-row> <fo:table-cell> <fo:table table-layout="fixed"> <fo:table-column column-width="70pt"/> <fo:table-column column-width="410pt"/> <fo:table-body> <fo:table-row> <fo:table-cell> <fo:block xsl:use-attribute-sets="FontSetA">Date of Test(s)</fo:block> </fo:table-cell> <fo:table-cell> <fo:block xsl:use-attribute-sets="FontSetA"><xsl:value-of select="DateOfTest"/></fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:table-cell> </fo:table-row> <!-- ****** Static Part of the Header ***** --> <fo:table-row> <fo:table-cell> <fo:table table-layout="fixed"> <fo:table-column column-width="55pt"/> <fo:table-column column-width="55pt"/> <fo:table-column column-width="50pt"/> <fo:table-column column-width="50pt"/> <fo:table-column column-width="40pt"/> <fo:table-body> <fo:table-row> <fo:table-cell> <fo:block xsl:use-attribute-sets="FontSetA">Test Number</fo:block> </fo:table-cell> <fo:table-cell> <fo:block xsl:use-attribute-sets="FontSetA">Student ID</fo:block> </fo:table-cell> <fo:table-cell> <fo:block xsl:use-attribute-sets="FontSetA">Grade Sub 1</fo:block> </fo:table-cell> <fo:table-cell> <fo:block xsl:use-attribute-sets="FontSetA">Grade Sub 2</fo:block> </fo:table-cell> <fo:table-cell> <fo:block xsl:use-attribute-sets="FontSetA">Result</fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:table-cell> </fo:table-row> </fo:table-header> <!-- ****** Table Body that ***** --> <fo:table-body> <fo:table-row> <fo:table-cell> <!-- ********** This part generates the actual data in table ************* --> <xsl:apply-templates select="StudentResultStruc"/> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </xsl:template> Any help in resolving this issue would be highly appreciated. Regads, PY _____________________________________________________________________________ _______ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: xsl-list Digest 1 Mar 200, Andy Carr1 | Thread | Re: [xsl] Repeating text in table h, Abel Braaksma |
Re: [xsl] XML Tag to Output Math ty, Owen Rees | Date | Re: [xsl] Repeating text in table h, Abel Braaksma |
Month |