xsl-list
[Top] [All Lists]

RE: limit number of row return by xslt

2004-09-14 11:20:37
For short example, I would like to display 2 rows
return per page and I will be able to click next or go
back to see next or previouse 2 rows.

This may be hairy codes, but please help me.
XSLT code:

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
<xsl:output method="html"/>

<!--
Step 1: Define the primary key to be used in the
Muenchian grouping. The
beautiful thing about the xsl:key  element in our
example is that once we
know the "Administration", we can easily find all of
the WMSReport that match that Administration.
The xsl:key element (different from the key()
function) is defined as follows:-->

<xsl:key name="dsWMSRpt" match="WMSReport"
use="ReportUnitTitle"/>


<!-- Template for our root rule -->
<xsl:template match="/">
        <xsl:apply-templates/>
</xsl:template>


<!-- Template for our "dsWMSRpt" rule -->
<xsl:template match="dsWMSRpt">

                        <!--Step 2: Loop through the unique regions (the
primary key) in our document.  -->      
                        <xsl:for-each
select="//WMSReport[generate-id(.)=generate-id(key('dsWMSRpt',ReportUnitTitle))]">
                
                        <!-- Sort Primary key by ApptStatusCode in
ascending order -->
                <xsl:sort select="ApptStatusCode"
order="ascending"/>  
                        
                        <!-- Display the region as our table header -->
                        <h2 align="Center"><xsl:value-of
select="Administration"/></h2>
                                <h3 align="Center"><xsl:value-of
select="ReportUnitTitle"/></h3>
                
                                <!--Display all nodes for a given Administration
in a table-->
                                <table border="0">                              
                                <tr>
                                                <th>WMS Working Title</th>
                                                <th>Position Number</th>
                                                <th>Person Name</th>
                                                <th>Annual Salary</th>
                                                <th>Job Cls</th>
                                                <th>Band</th>
                                                <th>JVA Code</th>
                                                <th>Salary Standard</th>
                                                <th>Peer Group</th>
                                                <th>Employee Status</th>
                                                <th>Occ CD</th>
                                        </tr>
                                
                                                                                
                
                                        <!-- For each value in our key 
collection for the
given Administration display values -->
                                <xsl:for-each
select="key('dsWMSRpt',ReportUnitTitle)">                       
                                        <!--
                                        The expression 
"key('dsWMSRpt',Administration)"
will return all of the "WMSReport"
                                        elements from the key table whose "use="
expression defined in xsl:key
                                        (see xsl:key at top)  evaluated to the 
same value
as the "Administration" child
                                        of the current element.  In the the 
example, we
specified use="Admnistration".
                                        If Administration has a value of 
".EXEC", then
all of the WMSReport elements from
                                        the key table that contain a child 
element with a
value of ".EXEC" will
                                        be returned.
                                        -->
                                                                                
                                        <!--Sort our secondary key, product 
nodes,  by
ApptStatusCode-->
                                        <xsl:sort select="ApptStatusCode"/>     
                                        <tr>
                                            <xsl:if test="(position() mod 2 = 
1)">
                                                                <xsl:attribute
name="bgcolor">#ccffff</xsl:attribute>
                                                        </xsl:if>               
                        
                                                                        
<td><xsl:value-of
select="WMS_x0020_Working_x0020_Title"/></td>
                                                                        
<td><xsl:value-of
select="PositionNumber"/></td>
                                                                        
<td><xsl:value-of
select="Person_x0020_Name"/></td>
                                                                        <td>
                                                                                
<xsl:choose>
                                                                                
        <xsl:when test="AnnualSalary&gt;0">
                                                                                
                <!--format number function has been used
in the next line-->
                                                                                
                <xsl:value-of
select='format-number(AnnualSalary, "$###,###.00")' />
                                                                                
        </xsl:when>
                                                                                
        <xsl:otherwise>
                                                                                
                0
                                                                                
        </xsl:otherwise>
                                                                        
</xsl:choose>
                                                                        </td>
                                                                        
                                                                        
<td><xsl:value-of
select="JobClassCode"/></td>
                                                                        
<td><xsl:value-of select="Band"/></td>
                                                                        
<td><xsl:value-of select="JVACode"/></td>
                                                                        <td>
                                                                                
<xsl:choose>
                                                                                
        <xsl:when
test="Salary_x0020_Standard&gt;0">
                                                                                
                <!--format number function has been used
in the next line-->
                                                                                
                <xsl:value-of
select='format-number(Salary_x0020_Standard,
"$###,###.00")' />
                                                                                
        </xsl:when>
                                                                                
        <xsl:otherwise>
                                                                                
                0
                                                                                
        </xsl:otherwise>
                                                                        
</xsl:choose>
                                                                        </td>   
                                                
                                                                        
<td><xsl:value-of
select="Peer_x0020_Group"/></td>
                                                                        
<!--concat function has been used in the next
line-->
                                                                        
<td><xsl:value-of
select='concat(ApptStatusCode, " ",
AppointmentStatusTitle)' /></td>
                                                                        
<td><xsl:value-of
select="OccupationCode"/></td>
                                                                <!--/xsl:when-->
                                                        <!--/xsl:choose-->
                                                </tr>
                                        
                                </xsl:for-each>
                        
                                </table>
                                <br>
                                        Employee Count: <xsl:value-of
select="count(key('dsWMSRpt',ReportUnitTitle)[Person_x0020_Name!='Vacancy'
and Person_x0020_Name!=''])"/>
                                </br>           
                                <br>
                                        Vacant Position Count: <xsl:value-of
select="count(key('dsWMSRpt',ReportUnitTitle)[Person_x0020_Name='Vacancy'])"/>
                                </br>
                                <br>
                                        Total Position Count: <xsl:value-of
select="count(key('dsWMSRpt',ReportUnitTitle))"/>
                                </br>
                        </xsl:for-each>

</xsl:template>

</xsl:stylesheet>

XML data:
<?xml version="1.0" standalone="yes"?>

<dsWMSRpt>
        <WMSReport>
                <AdministrationCode>HRS</AdministrationCode>
                <DivisionSort>HRS/Finacial</DivisionSort>
                <Status_x0020_Order>1</Status_x0020_Order>
                <Administration>Finacial</Administration>
                <DivisionTitle>Sale</DivisionTitle>
                <ReportUnitTitle>Sail</ReportUnitTitle>
                <WMS_x0020_Working_x0020_Title>Sale
Rep.</WMS_x0020_Working_x0020_Title>
                <PositionNumber> JP17</PositionNumber>
                <Person_x0020_Name>Green, Cloud 
</Person_x0020_Name>
                <ApptSalaryUnitCode>M</ApptSalaryUnitCode>
                <SalaryUnitAmount>6050.0000</SalaryUnitAmount>
                <AnnualSalary>72600</AnnualSalary>
                <Band>1</Band>
                <JVACode>000</JVACode>
        
<Salary_x0020_Standard>74760.0000</Salary_x0020_Standard>
                <Peer_x0020_Group>Q</Peer_x0020_Group>
                <ApptStatusCode>0</ApptStatusCode>
        
<AppointmentStatusTitle>Temporary</AppointmentStatusTitle>
                <ApptJobClassCode>SR</ApptJobClassCode>
                <JobClassCode>SR</JobClassCode>
                <ApptPartTimePct>100</ApptPartTimePct>
                <PositionCountyCode>27</PositionCountyCode>
                <PersonID>111111111</PersonID>
                <PositionOrgCode>000</PositionOrgCode>
        
<SeniorityDate>2003-11-20T00:00:00.0000000-08:00</SeniorityDate>
                <OccupationCode>183</OccupationCode>
        
<SnapshotDate>2004-08-08T00:00:00.0000000-07:00</SnapshotDate>
                <ReportingUnitID>38</ReportingUnitID>
                <SupervisorInd>Y</SupervisorInd>
        </WMSReport>
                <WMSReport>
                <AdministrationCode>HRS</AdministrationCode>
                <DivisionSort>HRS/Finacial</DivisionSort>
                <Status_x0020_Order>1</Status_x0020_Order>
                <Administration>Finacial</Administration>
                <DivisionTitle>Sale</DivisionTitle>
                <ReportUnitTitle>Sail</ReportUnitTitle>
                <WMS_x0020_Working_x0020_Title>Sale
Rep.</WMS_x0020_Working_x0020_Title>
                <PositionNumber> SDSS</PositionNumber>
                <Person_x0020_Name>Shine, Sun  </Person_x0020_Name>
                <ApptSalaryUnitCode>M</ApptSalaryUnitCode>
                <SalaryUnitAmount>6050.0000</SalaryUnitAmount>
                <AnnualSalary>72600</AnnualSalary>
                <Band>1</Band>
                <JVACode>000</JVACode>
        
<Salary_x0020_Standard>74760.0000</Salary_x0020_Standard>
                <Peer_x0020_Group>Q</Peer_x0020_Group>
                <ApptStatusCode>0</ApptStatusCode>
        
<AppointmentStatusTitle>Temporary</AppointmentStatusTitle>
                <ApptJobClassCode>SR</ApptJobClassCode>
                <JobClassCode>SR</JobClassCode>
                <ApptPartTimePct>100</ApptPartTimePct>
                <PositionCountyCode>27</PositionCountyCode>
                <PersonID>44444444444</PersonID>
                <PositionOrgCode>000</PositionOrgCode>
        
<SeniorityDate>2003-11-20T00:00:00.0000000-08:00</SeniorityDate>
                <OccupationCode>183</OccupationCode>
        
<SnapshotDate>2004-08-08T00:00:00.0000000-07:00</SnapshotDate>
                <ReportingUnitID>38</ReportingUnitID>
                <SupervisorInd>Y</SupervisorInd>
        </WMSReport>
        <WMSReport>
                <AdministrationCode>HRS</AdministrationCode>
                <DivisionSort>HRS/Personnel</DivisionSort>
                <Status_x0020_Order>Z</Status_x0020_Order>
                <Administration>Personnel</Administration>
                <DivisionTitle>Some Thing</DivisionTitle>
                <ReportUnitTitle>Personnel</ReportUnitTitle>
        
<WMS_x0020_Working_x0020_Title>IT</WMS_x0020_Working_x0020_Title>
                <PositionNumber>SDFG</PositionNumber>
                <Person_x0020_Name>Red, Brow</Person_x0020_Name>
                <ApptSalaryUnitCode>M</ApptSalaryUnitCode>
                <SalaryUnitAmount>2984.0000</SalaryUnitAmount>
                <AnnualSalary>35808</AnnualSalary>
                <Band>1</Band>
                <JVACode>456</JVACode>
        
<Salary_x0020_Standard>53112.0000</Salary_x0020_Standard>
                <Peer_x0020_Group>B</Peer_x0020_Group>
                <ApptStatusCode>K</ApptStatusCode>
        
<AppointmentStatusTitle>Manager-ACTING</AppointmentStatusTitle>
                <ApptJobClassCode>WMS</ApptJobClassCode>
                <JobClassCode>WMS</JobClassCode>
                <ApptPartTimePct>100</ApptPartTimePct>
                <PositionCountyCode>34</PositionCountyCode>
                <PersonID>222222222</PersonID>
                <PositionOrgCode>G70   </PositionOrgCode>
        
<SeniorityDate>2003-10-01T00:00:00.0000000-07:00</SeniorityDate>
                <OccupationCode>180</OccupationCode>
        
<SnapshotDate>2004-08-08T00:00:00.0000000-07:00</SnapshotDate>
                <ReportingUnitID>34</ReportingUnitID>
                <SupervisorInd>Y</SupervisorInd>
        </WMSReport>
        <WMSReport>
                <AdministrationCode>HRS</AdministrationCode>
                <DivisionSort>HRS/Traninig</DivisionSort>
                <Status_x0020_Order>1</Status_x0020_Order>
                <Administration>Personnel</Administration>
                <DivisionTitle>Training</DivisionTitle>
                <ReportUnitTitle>Training</ReportUnitTitle>
                <WMS_x0020_Working_x0020_Title>Training
Specialist</WMS_x0020_Working_x0020_Title>
                <PositionNumber>DREW</PositionNumber>
                <Person_x0020_Name>White, Golden   
</Person_x0020_Name>
                <ApptSalaryUnitCode>M</ApptSalaryUnitCode>
                <SalaryUnitAmount>5043.0000</SalaryUnitAmount>
                <AnnualSalary>60516</AnnualSalary>
                <Band>2</Band>
                <JVACode>456</JVACode>
        
<Salary_x0020_Standard>60516.0000</Salary_x0020_Standard>
                <Peer_x0020_Group>C1</Peer_x0020_Group>
                <ApptStatusCode>3</ApptStatusCode>
                <AppointmentStatusTitle>TRIAL
SERVICE</AppointmentStatusTitle>
                <ApptJobClassCode>WMS</ApptJobClassCode>
                <JobClassCode>WMS</JobClassCode>
                <ApptPartTimePct>100</ApptPartTimePct>
                <PositionCountyCode>34</PositionCountyCode>
                <PersonID>333333333</PersonID>
                <PositionOrgCode>DSF</PositionOrgCode>
        
<SeniorityDate>2004-01-02T00:00:00.0000000-08:00</SeniorityDate>
                <OccupationCode>600</OccupationCode>
        
<SnapshotDate>2004-08-08T00:00:00.0000000-07:00</SnapshotDate>
                <ReportingUnitID>19</ReportingUnitID>
                <SupervisorInd>N</SupervisorInd>
        </WMSReport>
                <WMSReport>
                <AdministrationCode>HRS</AdministrationCode>
                <DivisionSort>HRS/Traninig</DivisionSort>
                <Status_x0020_Order>1</Status_x0020_Order>
                <Administration>Personnel</Administration>
                <DivisionTitle>Training</DivisionTitle>
                <ReportUnitTitle>Training</ReportUnitTitle>
                <WMS_x0020_Working_x0020_Title>Training
Specialist</WMS_x0020_Working_x0020_Title>
                <PositionNumber>EWQS</PositionNumber>
                <Person_x0020_Name>Gate, Golden   
</Person_x0020_Name>
                <ApptSalaryUnitCode>M</ApptSalaryUnitCode>
                <SalaryUnitAmount>5043.0000</SalaryUnitAmount>
                <AnnualSalary>60516</AnnualSalary>
                <Band>2</Band>
                <JVACode>456</JVACode>
        
<Salary_x0020_Standard>60516.0000</Salary_x0020_Standard>
                <Peer_x0020_Group>C1</Peer_x0020_Group>
                <ApptStatusCode>3</ApptStatusCode>
                <AppointmentStatusTitle>TRIAL
SERVICE</AppointmentStatusTitle>
                <ApptJobClassCode>WMS</ApptJobClassCode>
                <JobClassCode>WMS</JobClassCode>
                <ApptPartTimePct>100</ApptPartTimePct>
                <PositionCountyCode>34</PositionCountyCode>
                <PersonID>333333333</PersonID>
                <PositionOrgCode>FET</PositionOrgCode>
        
<SeniorityDate>2004-01-02T00:00:00.0000000-08:00</SeniorityDate>
                <OccupationCode>600</OccupationCode>
        
<SnapshotDate>2004-08-08T00:00:00.0000000-07:00</SnapshotDate>
                <ReportingUnitID>19</ReportingUnitID>
                <SupervisorInd>N</SupervisorInd>
        </WMSReport>
</dsWMSRpt>


=====
"It is essential to know that to be a happy person, a happy family, a happy 
society, it is very crucial to have a good heart, that is very crucial,"
Dalai Lama


                
__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now. 
http://messenger.yahoo.com


<Prev in Thread] Current Thread [Next in Thread>