Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Repeating text in table headers with dynamic values from child node

From: Pankaj Yadav <yadavpankaj@--------->
To:
Date: 3/1/2007 12:13:00 PM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent