[xsl] New Table when I hit the nth column...

Subject: [xsl] New Table when I hit the nth column...
From: "Phil Jenkins" <philipjenkins@xxxxxxxxxxx>
Date: Mon, 13 Mar 2006 15:46:22 -0700
Hi.

I'm extremely new to XSL/FO (like 2 days), so I apologize if I'm asking a stupid question.

I currently have some XML with 'protocol' elements, each containing 'source' elements, which then contain 'weekEnding' elements, which contain 'respondent' elements. I'm making a table that lists the sources down the left, and the dates across the top, and populates the cells with respondents. Currently it works fine, because we only have data for 3 weeks. However, once we get past 6 or 7 weeks, we're gonna run out of room on the PDF. I need a way to make a new table after I hit 7 weeks worth of data. I found a similar posting at http://www.stylusstudio.com/xsllist/200402/post10580.html, but I couldn't find a way to map it onto what I'm doing (plus, as I'm new, I didn't quite understand everything that was going on). Hopefully y'all can help me.


Here's a sample of the XML:


<?xml version="1.0" encoding="UTF-8"?>
<AdSourceBySite title="Ad Source By Site">
    <study studyId="111">
         <studyName>STUDY</studyName>
         <customer>CUSTOMER</customer>
         <RMCode>2222</RMCode>
         <protocols>A,B,C</protocols>
         <Week>02/18/2006</Week>
         <Week>02/25/2006</Week>
         <Week>03/04/2006</Week>
         <Protocol protocol="A">
              <Source source="TV">
                   <WeekEnding date="02/18/2006">
                        <NumRespondents>0</NumRespondents>
                   </WeekEnding>
                   <WeekEnding date="02/25/2006">
                        <NumRespondents>1</NumRespondents>
                   </WeekEnding>
                   <WeekEnding date="03/04/2006">
                        <NumRespondents>0</NumRespondents>
                   </WeekEnding>
              </Source>
              <Source source="Radio">
                   <WeekEnding date="02/18/2006">
                        <NumRespondents>3</NumRespondents>
                   </WeekEnding>
                   <WeekEnding date="02/25/2006">
                        <NumRespondents>23</NumRespondents>
                   </WeekEnding>
                   <WeekEnding date="03/04/2006">
                        <NumRespondents>16</NumRespondents>
                   </WeekEnding>
              </Source>
         </Protocol>
         <Protocol protocol="B">
         ...
         ...
         </Protocol>
         ...
         ...
    </study>
</AdSourceBySite>



and here are (I think) the important parts of the XSL:

...blah blah...
...
<xsl:for-each select="AdSourceBySite/study/Protocol">
<xsl:if test="AdvertisementSource">
<fo:block break-after="page">
<xsl:call-template name="DisplayProtocolData"/>
</fo:block>
</xsl:if>
</xsl:for-each>
...
...blah blah...
...
<!-- Display the Data -->
<!-- Protocol Data Template -->
<xsl:template name="DisplayProtocolData">
<xsl:for-each select="AdvertisementSource[1]/WeekEnding[position() mod $n = 1]">
<xsl:variable name="x" select="position() - 1"/>
<fo:table table-layout="fixed" width="510px" space-before="10pt" space-after="10pt">
<fo:table-column column-width="510px"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="center">
<fo:block font-size="9pt" font-weight="bold" space-after="0pt" space-before="15pt">
<xsl:value-of select="/AdSourceBySite/study/customer"/> Local Advertisement Tracking Log for <xsl:value-of select="/AdSourceBySite/study/studyName"/> Protocol <xsl:value-of select="../@protocol"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table display-align="center" border-bottom-width="2pt" border-bottom-style="solid" table-layout="fixed" space-after="5pt" space-before="10pt">
<fo:table-column column-width="160px"/>
<xsl:for-each select=".|following-sibling::inventorlist[position()&lt;7]">
<fo:table-column column-width="50px"/>
</xsl:for-each>
<fo:table-body>
<fo:table-row height="10pt" padding="1pt">
<fo:table-cell/>
<fo:table-cell number-columns-spanned="{count(/AdSourceBySite/study/Week)}" border-style="solid" border-top-width="2pt" border-left-width="2pt" border-right-width="2pt">
<fo:block text-align="center" font-size="8pt" font-weight="bold">Total Weekly Respondents</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row height="20pt">
<fo:table-cell border-width="2px" border-style="solid" padding-left="2pt">
<fo:block font-size="8pt" font-weight="bold" padding-top="10pt" padding-left="5pt">Advertisement Source</fo:block>
</fo:table-cell>
<xsl:for-each select="/AdSourceBySite/study/Week">
<fo:table-cell border-bottom-width="2pt" border-right-width="2pt" border-top-width="2pt" border-style="solid">
<fo:block font-size="8pt" font-weight="bold" text-align="center">Week of</fo:block>
<fo:block font-size="8pt" font-weight="bold" text-align="center"><xsl:value-of select="."/></fo:block>
</fo:table-cell>
</xsl:for-each>
</fo:table-row>
<xsl:for-each select="AdvertisementSource">
<fo:table-row height="10pt">
<fo:table-cell border-width="1px" border-style="solid" border-left-width="2pt" border-right-width="2pt" padding-top="1pt" padding-bottom="1pt" padding-left="2pt">
<fo:block font-size="8pt"><xsl:value-of select="./@source"/></fo:block>
</fo:table-cell>
<xsl:for-each select="WeekEnding">
<fo:table-cell border-bottom-width="1px" border-style="solid" border-right-width="2pt" padding-top="1pt" padding-bottom="1pt" padding-right="2pt">
<fo:block font-size="8pt" text-align="right"><xsl:value-of select="NumRespondents"/></fo:block>
</fo:table-cell>
</xsl:for-each>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</xsl:for-each>
</xsl:template>
...
... blah blah ...
...


Currently, it works for the three dates provided, but I need it to make a new table for the protocol when there are more than 7 dates. Can anyone provide any insight? Thanks in advance.

Phil

_________________________________________________________________
Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Current Thread