Cambiamos el XSL
| <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <body> <table border="1"> <tr> <td><b>Nombre</b></td> <td><b>Mercado</b></td> <td><b>Precio</b></td> <td><b>Fecha</b></td> </tr> <xsl:for-each select="*/cotizacion" order-by="nombre"> <tr> <td><xsl:value-of select="nombre"/></td> <td><xsl:value-of select="mercado"/></td> <td><xsl:value-of select="precio"/></td> <td><xsl:value-of select="fecha/dia"/>- <xsl:value-of select="fecha/mes"/>- <xsl:value-of select="fecha/anio"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> |
Y el resultado Seria
| Nombre | Mercado | Precio | Fecha |
| Acertia | Madrid | 21 | 23- 04- 2003 |
| Autentia | Madrid | 12 | 24- 04- 2003 |
Si queremos que sea ascendente o descendente
<xsl:for-each select="*/cotizacion" order-by="-nombre">
Ahora vamos a introducir condicionales
| <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="oferta.xsl"?> <fichero> <cotizacion> <nombre>Autentia</nombre> <mercado>Madrid</mercado> <precio>12</precio> <fecha> <dia>24</dia> <mes>04</mes> <anio>2003</anio> </fecha> </cotizacion> <cotizacion> <nombre>Acertia</nombre> <mercado>Madrid</mercado> <precio>21</precio> <fecha> <dia>23</dia> <mes>04</mes> <anio>2003</anio> </fecha> </cotizacion> <cotizacion> <nombre>AdictosAlTrabajo</nombre> <mercado>Barcelona</mercado> <precio>2</precio> <fecha> <dia>25</dia> <mes>04</mes> <anio>2003</anio> </fecha> </cotizacion> </fichero> |
Usuarios que han visto este tema también han visto...
- Document Object Model y Visual Basic en XML
- Qué es RSS
- Lenguaje de Enlace XML (XLink)
- Espacios de Nombres en XML
- XML en 10 Puntos
Información legal | Política de Privacidad | Contacte con nosotros
Otro proyecto de Factoría de Internet. Copyright© 2003-2008 Factoría de Internet S.L.. Todos los derechos reservados.