Re: [xsl] pagin and sorting XSL

Subject: Re: [xsl] pagin and sorting XSL
From: Carlos Humberto - IntelVision <carlosweb@xxxxxxxxxxxxxxxxxx>
Date: Mon, 04 Sep 2006 15:48:06 -0300
Hello Abel, thank you for the fast answer.

I am sending my XML and XSL for the list (I don't know it goes if).

I wanted that each it paginates of results he/she had an ordination. But usually in my tests when I ask to order he orders everything, not just the results of the page.

Regards,
Carlos H.



XML
-----------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>

<tribunais>

	<tribunal>
		<id>14</id>
		<numero>1</numero>
		<categoria>Tribunal Superior</categoria>
		<nome>Superior Tribunal de Justiga</nome>
		<website>www.stj.gov.br</website>
	</tribunal>

	<tribunal>
		<id>2</id>
		<numero>2</numero>
		<categoria>Tribunal Superior</categoria>
		<nome>Supremo Tribunal Federal</nome>
		<website>www.stf.gov.br</website>
	</tribunal>

	<tribunal>
		<id>16</id>
		<numero>3</numero>
		<categoria>Tribunal Superior</categoria>
		<nome>Tribunal de Contas da Unico</nome>
		<website>www.stm.gov.br</website>
	</tribunal>

	<tribunal>
		<id>19</id>
		<numero>4</numero>
		<categoria>Tribunal Regional do Trabalho</categoria>
		<nome>01* Regico - RJ</nome>
		<website>www.trtrio.gov.br</website>
	</tribunal>

	<tribunal>
		<id>20</id>
		<numero>5</numero>
		<categoria>Tribunal Regional do Trabalho</categoria>
		<nome>02* Regico - SP</nome>
		<website>www.trt02.gov.br</website>
	</tribunal>

	<tribunal>
		<id>18</id>
		<numero>6</numero>
		<categoria>Tribunal de Contas </categoria>
		<nome>Goias</nome>
		<website>www.tce.go.gov.br</website>
	</tribunal>

	<tribunal>
		<id>17</id>
		<numero>7</numero>
		<categoria>Tribunal de Contas </categoria>
		<nome>Bahia</nome>
		<website>www.tce.ba.gov.br</website>
	</tribunal>

	<tribunal>
		<id>15</id>
		<numero>8</numero>
		<categoria>Tribunal de Contas </categoria>
		<nome>Alagoas</nome>
		<website>www.tc.al.gov.br</website>
	</tribunal>

</tribunais>






XSL -----------------------------------------------------------------


<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="msxsl"
version="1.0">

<xsl:output method="xml" indent ="yes"/>


<xsl:param name="direcao"></xsl:param>
<xsl:param name="sortBy"></xsl:param>
<xsl:param name="start" select="1"/> <xsl:param name="range" select="2"/>


<xsl:variable name="tableData">
	<xsl:apply-templates select="tribunais/tribunal[position() &gt;=$start and position() &lt; $start + $range]" mode="tableData">
 </xsl:apply-templates>
</xsl:variable>



<xsl:template match="tribunais">

		<table width="100%" border="1">
		<tr align="center">
			<td><a href="#" onclick="renderData('categoria');">categoria</a></td>
			<td><a href="#" onclick="renderData('nome');">nome</a></td>
			<td><a href="#" onclick="renderData('website');">website</a></td>						
		</tr>
		
   <xsl:apply-templates select="msxsl:node-set($tableData)/tribunal">
			<xsl:sort select="*[name()=$sortBy]" order="{$direcao}"/>
   </xsl:apply-templates>


</table> </xsl:template>



<xsl:template match="tribunal">
	<tr>
		<td><xsl:value-of select="categoria"/></td>		
		<td><xsl:value-of select="nome" /></td>
		<td><xsl:value-of select="website" /></td>
	</tr>
</xsl:template>



<xsl:template match="tribunal" mode="tableData">
		<xsl:copy>
			<xsl:copy-of select="categoria"/>
			<xsl:copy-of select="nome"/>
			<xsl:copy-of select="website"/>
		</xsl:copy>		
	</xsl:template>

</xsl:stylesheet>
--------------------------------------------------------------------








Abel Online escreveu:
Hi Carlos,

It would help if you'd send us the XML you are trying to transform, and the XSLT that you have got so far. Also, it'll help if you include the XML of what you expect from your transformation (well, perhaps you don't even want XML as output? Your post doesn't say).

Please update, it will make it easier to help you.

Kind regards,

Abel Braaksma
http://abelleba.metacarpus.com


Carlos Humberto - IntelVision wrote:
Hello it would like a help of you. I am then Brazilian they excuse for my bad English. I would Like to paginate the data of a simple XML through XSL and to order the results of each it paginates. could anybody help me with some example? I already tried of everything and I didn't get. I thank the help of all. Thank you, Carlos H

Current Thread