Need once more a litle bit of help on (re) paginate that already mentioned simple xml table data (XML table columns vertically stacked within rows) but transposed this time as Michael Hor sugested over the above SO's second answer post up, but in addition with displaying three records per (mobile) page.
Need this for a mobile pages..
The xml file goes something like this:
<persns>
<prsn>
<fname>Smith</fname>
<lname>Milton</lname>
<age>44</age>
<addrss>5th summer st, mntb</addrss>
<city>Portland</city>
</prsn>
<prsn>
<fname>Ken</fname>
<lname>Jackson</lname>
<age>37</age>
<addrss>19th Penfield ave, brtcl</addrss>
<city>Kelowna</city>
</prsn>
<prsn>
<fname>Susan</fname>
<lname>Arkland</lname>
<age>48</age>
<addrss>34th Mansfield st, sgtp</addrss>
<city>Raleigh</city>
</prsn>
<prsn>
<fname>George</fname>
<lname>Bond</lname>
<age>35</age>
<addrss>5th drive, mntb</addrss>
<city>Albany</city>
</prsn>
<prsn>
<fname>Ron</fname>
<lname>Davis</lname>
<age>37</age>
<addrss>12th Greenfield ave, brtcl</addrss>
<city>Pheonix</city>
</prsn>
</persns>
The way displaying is needed is as follows:
|===========|---------------|-------------|------------|
| FNAME | Smith | Ken | Susan |
|===========|---------------|-------------|------------|
| LNAME | Milton | Jackson | Arkland |
|===========|---------------|-------------|------------|
| AGE | 44 | 37 | 48 |
|===========|---------------|-------------|------------|
| ADDRESS |5th smmr st,mntb9th Pnfeld ave 34th Mansfield st |===========|---------------|-------------|------------|
| CITY | Portland | Kelowna | Raleigh |
|===========|---------------|-------------|------------|
| << < 1/4 > >> |
|=======================================================
Fig 1 First Page
|===========|---------------|-------------|------------|
| FNAME | George | Ron | Marie-Ann |
|===========|---------------|-------------|------------|
| LNAME | Bond | Davis | Spencer |
|===========|---------------|-------------|------------|
| AGE | 35 | 37 | 48 |
|===========|---------------|-------------|------------|
| ADDRESS |5th drive, mntb|12th Greenfld ave 273 Simpson square
|===========|---------------|-------------|------------|
| CITY | Albany | Pheonix | Oklahoma |
|===========|---------------|-------------|------------|
| << < 2/4 > >> |
|=======================================================
Fig 2 Second Page
Exactly as Michael Hor suggested through that previous post's answer. And that stylesheet is somehow as follows:
<xsl:param name="frame" select="3"/>
<xsl:template match="persns">
<xsl:apply-templates select="prsn[position() mod $frame=1]">
<xsl:with-param name="pags" select="ceiling(count(prsn) div$frame)"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="/prsn">
<xsl:variable name="rec" select="prsn"/>
<table border="1">
<xsl:for-each select="prsn[1]/*">
<xsl:variable name="pag" select="position()"/>
<tr><th><xsl:value-of select="name()"/></th>
<xsl:for-each select="$rec">
<td><xsl:value-of select="*[$pag]"/> </td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
As one can easily notice the second template - just by itself - would correctly displays All the xml records. And it does it exactly the way I wanted to, but without pagination.
If I actually insert the first template (on the other hand) where is xsl:apply-templates declaration and "with param" stuff everything gets "mixed up"; as first template - by itself - displays that set of 3 records (or something) with no formatting and ignoring the second template which is suppose to display records in a formated manner.
Don't know why those two templates are somehow "mutually exclusive"
After that it comes the pagination section area, and a couple of small js functions bound over those <a href links.
All these could be found here:
one record at a time xml pagination on xslt
This would be it for now.
I really struggled for weeks for properly display all these.
Thank you guys în advance.