RE: [xsl] How to use xpath in this xml file...

Subject: RE: [xsl] How to use xpath in this xml file...
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Wed, 17 Mar 2004 09:48:53 -0500
Sorry, earlier xslt was incorrect.  Try this with the xml I provided(it
helps to have different ANNO values):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="PENSIONES">
	<xsl:for-each select="DETALLE_PENSION/ANNO">
		
		<xsl:value-of select="."/> = = <xsl:value-of
select="preceding::ANNO[1]"/> :: <xsl:value-of select=". =
preceding::ANNO[1]"/>
		<br/>
		
	</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Basically, loop through all DETALLE_PENSION/ANNO and get the value of the
ANNO (".")

Then compare preceding::ANNO[1](the very prior ANNO node).  For some reason
this will not work without the [1], although it was my impression that the
[1] was implicitly implied.  


Here is the output:

1998 = = :: false
1998 = = 1998 :: true
1998 = = 1998 :: true
1999 = = 1998 :: false
1998 = = 1999 :: false
1998 = = 1998 :: true

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of BECAPORTAL2
becario desarrollo
Sent: Wednesday, March 17, 2004 8:47 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] How to use xpath in this xml file...

Hi everybody,

I have a xml file like this:

<PENSIONES>
	<NOMBRE>28509599H</NOMBRE>
	<numCol>1</numCol>
	<Volver>0</Volver>
	<CIF>P4100000A</CIF>
	<RAZONSOCIAL>DIPUTACION PROVINCIAL DE SEVILLA</RAZONSOCIAL>
	<TOTAL_APORT_EMP>4.640,55</TOTAL_APORT_EMP>
	<TOTAL_APORT_TRAB>1.969,44</TOTAL_APORT_TRAB>
	<accion>listadoPensiones</accion>
	<desde>1</desde>
	<DETALLE_PENSION>
		<ANNO>1998</ANNO>
		<MES>4</MES>
		<APORT_EMP>1.514,55</APORT_EMP>
		<APORT_TRAB>0</APORT_TRAB>
	</DETALLE_PENSION>
	<DETALLE_PENSION>
		<ANNO>1998</ANNO>
		<MES>5</MES>
		<APORT_EMP>42,07</APORT_EMP>
		<APORT_TRAB>8,41</APORT_TRAB>
	</DETALLE_PENSION>
	<DETALLE_PENSION>
		<ANNO>1998</ANNO>
		<MES>6</MES>
		<APORT_EMP>42,07</APORT_EMP>
		<APORT_TRAB>8,41</APORT_TRAB>
	</DETALLE_PENSION>
	<DETALLE_PENSION>
		<ANNO>1998</ANNO>
		<MES>7</MES>
		<APORT_EMP>42,07</APORT_EMP>
		<APORT_TRAB>8,41</APORT_TRAB>
	</DETALLE_PENSION>
	<DETALLE_PENSION>
		<ANNO>1998</ANNO>
		<MES>8</MES>
		<APORT_EMP>42,07</APORT_EMP>
		<APORT_TRAB>8,41</APORT_TRAB>
	</DETALLE_PENSION>
	<DETALLE_PENSION>
		<ANNO>1998</ANNO>
		<MES>9</MES>
		<APORT_EMP>42,07</APORT_EMP>
		<APORT_TRAB>8,41</APORT_TRAB>
	</DETALLE_PENSION>
	<hasta>70</hasta>
	<registros>71</registros>
</PENSIONES>

 When i select value of "ANNO" with xsl, i would like compare with last
value of ANNO. I have trying with precedence,ancestor,position(), but i have
failled. Which xpath sentence will be good in this case?

Thanks in advance and Greetings from Spain


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread