XSLT terminado
authordanigm <dani@danigm.net>
Sun, 12 Oct 2008 17:27:10 +0000 (19:27 +0200)
committerdanigm <dani@danigm.net>
Sun, 12 Oct 2008 17:27:10 +0000 (19:27 +0200)
15 files changed:
catalogo.xml [new file with mode: 0644]
catalogo.xsl [new file with mode: 0644]
cdcatalog.xml [new file with mode: 0644]
plantilla.xsl [new file with mode: 0644]
plantilla2.xsl [new file with mode: 0644]
presentacion2.odp
tienda-html.xsl [new file with mode: 0644]
tienda0.xml [new file with mode: 0644]
tienda1-html.xsl [new file with mode: 0644]
tienda1.xml [new file with mode: 0644]
xml-xslt.xml [new file with mode: 0644]
xsl01.png [new file with mode: 0644]
xslt-example1.png [new file with mode: 0644]
xslt02.png [new file with mode: 0644]
xslt03.png [new file with mode: 0644]

diff --git a/catalogo.xml b/catalogo.xml
new file mode 100644 (file)
index 0000000..8b7aea5
--- /dev/null
@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="catalogo.xsl" type="text/xsl"?>
+<catalogo>
+    <cd valoracion="10">
+        <titulo>Empire Burlesque</titulo>
+        <artista>Bob Dylan</artista>
+        <pais>USA</pais>
+        <discografica>Columbia</discografica>
+        <precio>10.90</precio>
+        <anio>1985</anio>
+    </cd>
+    <cd valoracion="2">
+        <titulo>Bulería</titulo>
+        <artista>David Bisbal</artista>
+        <pais>España</pais>
+        <discografica>Vale</discografica>
+        <precio>20</precio>
+        <anio>2004</anio>
+    </cd>
+       <cd valoracion="7">
+               <titulo>Hide your heart</titulo>
+               <artista>Bonnie Tyler</artista>
+               <paisy>UK</paisy>
+               <discografica>CBS Records</discografica>
+               <precio>9.90</precio>
+               <anio>1988</anio>
+       </cd>
+       <cd valoracion="3">
+               <titulo>Greatest Hits</titulo>
+               <artista>Dolly Parton</artista>
+               <paisy>USA</paisy>
+               <discografica>RCA</discografica>
+               <precio>9.90</precio>
+               <anio>1982</anio>
+       </cd>
+       <cd valoracion="8">
+               <titulo>Still got the blues</titulo>
+               <artista>Gary Moore</artista>
+               <paisy>UK</paisy>
+               <discografica>Virgin records</discografica>
+               <precio>10.20</precio>
+               <anio>1990</anio>
+       </cd>
+       <cd valoracion="6">
+               <titulo>Eros</titulo>
+               <artista>Eros Ramazzotti</artista>
+               <paisy>EU</paisy>
+               <discografica>BMG</discografica>
+               <precio>9.90</precio>
+               <anio>1997</anio>
+       </cd>
+       <cd valoracion="5">
+               <titulo>One night only</titulo>
+               <artista>Bee Gees</artista>
+               <paisy>UK</paisy>
+               <discografica>Polydor</discografica>
+               <precio>10.90</precio>
+               <anio>1998</anio>
+       </cd>
+       <cd valoracion="2">
+               <titulo>Sylvias Mother</titulo>
+               <artista>Dr.Hook</artista>
+               <paisy>UK</paisy>
+               <discografica>CBS</discografica>
+               <precio>8.10</precio>
+               <anio>1973</anio>
+       </cd>
+       <cd valoracion="9">
+               <titulo>Maggie May</titulo>
+               <artista>Rod Stewart</artista>
+               <paisy>UK</paisy>
+               <discografica>Pickwick</discografica>
+               <precio>8.50</precio>
+               <anio>1990</anio>
+       </cd>
+       <cd valoracion="9">
+               <titulo>Romanza</titulo>
+               <artista>Andrea Bocelli</artista>
+               <paisy>EU</paisy>
+               <discografica>Polydor</discografica>
+               <precio>10.80</precio>
+               <anio>1996</anio>
+       </cd>
+       <cd valoracion="5">
+               <titulo>When a man loves a woman</titulo>
+               <artista>Percy Sledge</artista>
+               <paisy>USA</paisy>
+               <discografica>Atlantic</discografica>
+               <precio>8.70</precio>
+               <anio>1987</anio>
+       </cd>
+       <cd valoracion="7">
+               <titulo>Black angel</titulo>
+               <artista>Savage Rose</artista>
+               <paisy>EU</paisy>
+               <discografica>Mega</discografica>
+               <precio>10.90</precio>
+               <anio>1995</anio>
+       </cd>
+       <cd valoracion="4">
+               <titulo>1999 Grammy Nominees</titulo>
+               <artista>Many</artista>
+               <paisy>USA</paisy>
+               <discografica>Grammy</discografica>
+               <precio>10.20</precio>
+               <anio>1999</anio>
+       </cd>
+       <cd valoracion="8">
+               <titulo>For the good times</titulo>
+               <artista>Kenny Rogers</artista>
+               <paisy>UK</paisy>
+               <discografica>Mucik Master</discografica>
+               <precio>8.70</precio>
+               <anio>1995</anio>
+       </cd>
+       <cd valoracion="5">
+               <titulo>Big Willie style</titulo>
+               <artista>Will Smith</artista>
+               <paisy>USA</paisy>
+               <discografica>Columbia</discografica>
+               <precio>9.90</precio>
+               <anio>1997</anio>
+       </cd>
+       <cd valoracion="2">
+               <titulo>Tupelo Honey</titulo>
+               <artista>Van Morrison</artista>
+               <paisy>UK</paisy>
+               <discografica>Polydor</discografica>
+               <precio>8.20</precio>
+               <anio>1971</anio>
+       </cd>
+       <cd valoracion="9">
+               <titulo>Soulsville</titulo>
+               <artista>Jorn Hoel</artista>
+               <paisy>Norway</paisy>
+               <discografica>WEA</discografica>
+               <precio>7.90</precio>
+               <anio>1996</anio>
+       </cd>
+       <cd valoracion="8">
+               <titulo>The very best of</titulo>
+               <artista>Cat Stevens</artista>
+               <paisy>UK</paisy>
+               <discografica>Island</discografica>
+               <precio>8.90</precio>
+               <anio>1990</anio>
+       </cd>
+       <cd valoracion="5">
+               <titulo>Stop</titulo>
+               <artista>Sam Brown</artista>
+               <paisy>UK</paisy>
+               <discografica>A and M</discografica>
+               <precio>8.90</precio>
+               <anio>1988</anio>
+       </cd>
+       <cd valoracion="5">
+               <titulo>Bridge of Spies</titulo>
+               <artista>T`Pau</artista>
+               <paisy>UK</paisy>
+               <discografica>Siren</discografica>
+               <precio>7.90</precio>
+               <anio>1987</anio>
+       </cd>
+       <cd valoracion="6">
+               <titulo>Private Dancer</titulo>
+               <artista>Tina Turner</artista>
+               <paisy>UK</paisy>
+               <discografica>Capitol</discografica>
+               <precio>8.90</precio>
+               <anio>1983</anio>
+       </cd>
+       <cd valoracion="5">
+               <titulo>Midt om natten</titulo>
+               <artista>Kim Larsen</artista>
+               <paisy>EU</paisy>
+               <discografica>Medley</discografica>
+               <precio>7.80</precio>
+               <anio>1983</anio>
+       </cd>
+       <cd valoracion="7">
+               <titulo>Pavarotti Gala Concert</titulo>
+               <artista>Luciano Pavarotti</artista>
+               <paisy>UK</paisy>
+               <discografica>DECCA</discografica>
+               <precio>9.90</precio>
+               <anio>1991</anio>
+       </cd>
+       <cd valoracion="1">
+               <titulo>The dock of the bay</titulo>
+               <artista>Otis Redding</artista>
+               <paisy>USA</paisy>
+               <discografica>Atlantic</discografica>
+               <precio>7.90</precio>
+               <anio>1987</anio>
+       </cd>
+       <cd valoracion="3">
+               <titulo>Picture book</titulo>
+               <artista>Simply Red</artista>
+               <paisy>EU</paisy>
+               <discografica>Elektra</discografica>
+               <precio>7.20</precio>
+               <anio>1985</anio>
+       </cd>
+       <cd valoracion="7">
+               <titulo>Red</titulo>
+               <artista>The Communards</artista>
+               <paisy>UK</paisy>
+               <discografica>London</discografica>
+               <precio>7.80</precio>
+               <anio>1987</anio>
+       </cd>
+       <cd valoracion="10">
+               <titulo>Unchain my heart</titulo>
+               <artista>Joe Cocker</artista>
+               <paisy>USA</paisy>
+               <discografica>EMI</discografica>
+               <precio>8.20</precio>
+               <anio>1987</anio>
+       </cd>
+</catalogo>
diff --git a/catalogo.xsl b/catalogo.xsl
new file mode 100644 (file)
index 0000000..099f37b
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+  <html>
+    <table border="1">
+        <tr bgcolor="#aaaaff">
+            <th>Titulo</th>
+            <th>Artista</th>
+            <th>Valoracion</th>
+        </tr>
+        <xsl:for-each select="catalogo/cd">
+            <xsl:sort select="@valoracion" order="descending" data-type="number"/>
+          <tr>
+             <xsl:choose>
+                 <xsl:when test="precio &gt; 15">
+                     <td bgcolor="#ffaaaa"><xsl:apply-templates select="titulo"/></td>
+                 </xsl:when>
+                 <xsl:when test="precio &lt; 10">
+                     <td bgcolor="#aaffaa"><xsl:apply-templates select="titulo"/></td>
+                 </xsl:when>
+                 <xsl:otherwise>
+                     <td><xsl:apply-templates select="titulo"/></td>
+                 </xsl:otherwise>
+             </xsl:choose>
+             <td><xsl:apply-templates select="artista"/></td>
+             <td><xsl:value-of select="@valoracion"/></td>
+          </tr>
+        </xsl:for-each>
+    </table>
+  </html>
+</xsl:template>
+
+<xsl:template match="titulo|artista">
+    <u><xsl:apply-templates/></u>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/cdcatalog.xml b/cdcatalog.xml
new file mode 100644 (file)
index 0000000..6295eed
--- /dev/null
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>\r
+<!-- Edited by XMLSpy® -->\r
+<catalog>\r
+       <cd>\r
+               <title>Empire Burlesque</title>\r
+               <artist>Bob Dylan</artist>\r
+               <country>USA</country>\r
+               <company>Columbia</company>\r
+               <price>10.90</price>\r
+               <year>1985</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Hide your heart</title>\r
+               <artist>Bonnie Tyler</artist>\r
+               <country>UK</country>\r
+               <company>CBS Records</company>\r
+               <price>9.90</price>\r
+               <year>1988</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Greatest Hits</title>\r
+               <artist>Dolly Parton</artist>\r
+               <country>USA</country>\r
+               <company>RCA</company>\r
+               <price>9.90</price>\r
+               <year>1982</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Still got the blues</title>\r
+               <artist>Gary Moore</artist>\r
+               <country>UK</country>\r
+               <company>Virgin records</company>\r
+               <price>10.20</price>\r
+               <year>1990</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Eros</title>\r
+               <artist>Eros Ramazzotti</artist>\r
+               <country>EU</country>\r
+               <company>BMG</company>\r
+               <price>9.90</price>\r
+               <year>1997</year>\r
+       </cd>\r
+       <cd>\r
+               <title>One night only</title>\r
+               <artist>Bee Gees</artist>\r
+               <country>UK</country>\r
+               <company>Polydor</company>\r
+               <price>10.90</price>\r
+               <year>1998</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Sylvias Mother</title>\r
+               <artist>Dr.Hook</artist>\r
+               <country>UK</country>\r
+               <company>CBS</company>\r
+               <price>8.10</price>\r
+               <year>1973</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Maggie May</title>\r
+               <artist>Rod Stewart</artist>\r
+               <country>UK</country>\r
+               <company>Pickwick</company>\r
+               <price>8.50</price>\r
+               <year>1990</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Romanza</title>\r
+               <artist>Andrea Bocelli</artist>\r
+               <country>EU</country>\r
+               <company>Polydor</company>\r
+               <price>10.80</price>\r
+               <year>1996</year>\r
+       </cd>\r
+       <cd>\r
+               <title>When a man loves a woman</title>\r
+               <artist>Percy Sledge</artist>\r
+               <country>USA</country>\r
+               <company>Atlantic</company>\r
+               <price>8.70</price>\r
+               <year>1987</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Black angel</title>\r
+               <artist>Savage Rose</artist>\r
+               <country>EU</country>\r
+               <company>Mega</company>\r
+               <price>10.90</price>\r
+               <year>1995</year>\r
+       </cd>\r
+       <cd>\r
+               <title>1999 Grammy Nominees</title>\r
+               <artist>Many</artist>\r
+               <country>USA</country>\r
+               <company>Grammy</company>\r
+               <price>10.20</price>\r
+               <year>1999</year>\r
+       </cd>\r
+       <cd>\r
+               <title>For the good times</title>\r
+               <artist>Kenny Rogers</artist>\r
+               <country>UK</country>\r
+               <company>Mucik Master</company>\r
+               <price>8.70</price>\r
+               <year>1995</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Big Willie style</title>\r
+               <artist>Will Smith</artist>\r
+               <country>USA</country>\r
+               <company>Columbia</company>\r
+               <price>9.90</price>\r
+               <year>1997</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Tupelo Honey</title>\r
+               <artist>Van Morrison</artist>\r
+               <country>UK</country>\r
+               <company>Polydor</company>\r
+               <price>8.20</price>\r
+               <year>1971</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Soulsville</title>\r
+               <artist>Jorn Hoel</artist>\r
+               <country>Norway</country>\r
+               <company>WEA</company>\r
+               <price>7.90</price>\r
+               <year>1996</year>\r
+       </cd>\r
+       <cd>\r
+               <title>The very best of</title>\r
+               <artist>Cat Stevens</artist>\r
+               <country>UK</country>\r
+               <company>Island</company>\r
+               <price>8.90</price>\r
+               <year>1990</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Stop</title>\r
+               <artist>Sam Brown</artist>\r
+               <country>UK</country>\r
+               <company>A and M</company>\r
+               <price>8.90</price>\r
+               <year>1988</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Bridge of Spies</title>\r
+               <artist>T`Pau</artist>\r
+               <country>UK</country>\r
+               <company>Siren</company>\r
+               <price>7.90</price>\r
+               <year>1987</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Private Dancer</title>\r
+               <artist>Tina Turner</artist>\r
+               <country>UK</country>\r
+               <company>Capitol</company>\r
+               <price>8.90</price>\r
+               <year>1983</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Midt om natten</title>\r
+               <artist>Kim Larsen</artist>\r
+               <country>EU</country>\r
+               <company>Medley</company>\r
+               <price>7.80</price>\r
+               <year>1983</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Pavarotti Gala Concert</title>\r
+               <artist>Luciano Pavarotti</artist>\r
+               <country>UK</country>\r
+               <company>DECCA</company>\r
+               <price>9.90</price>\r
+               <year>1991</year>\r
+       </cd>\r
+       <cd>\r
+               <title>The dock of the bay</title>\r
+               <artist>Otis Redding</artist>\r
+               <country>USA</country>\r
+               <company>Atlantic</company>\r
+               <price>7.90</price>\r
+               <year>1987</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Picture book</title>\r
+               <artist>Simply Red</artist>\r
+               <country>EU</country>\r
+               <company>Elektra</company>\r
+               <price>7.20</price>\r
+               <year>1985</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Red</title>\r
+               <artist>The Communards</artist>\r
+               <country>UK</country>\r
+               <company>London</company>\r
+               <price>7.80</price>\r
+               <year>1987</year>\r
+       </cd>\r
+       <cd>\r
+               <title>Unchain my heart</title>\r
+               <artist>Joe Cocker</artist>\r
+               <country>USA</country>\r
+               <company>EMI</company>\r
+               <price>8.20</price>\r
+               <year>1987</year>\r
+       </cd>\r
+</catalog>\r
diff --git a/plantilla.xsl b/plantilla.xsl
new file mode 100644 (file)
index 0000000..72761b6
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+<html>
+    <body>
+    <h2>Mi coleccion de CD</h2>
+    <table border="1">
+        <tr bgcolor="#9acd32">
+            <th align="left">Titulo</th>
+            <th align="left">Artista</th>
+        </tr>
+        <xsl:for-each select="catalogo/cd">
+            <tr>
+                <td><xsl:value-of select="titulo"/></td>
+                <td><xsl:value-of select="artista"/></td>
+            </tr>
+        </xsl:for-each>
+    </table>
+    </body>
+</html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/plantilla2.xsl b/plantilla2.xsl
new file mode 100644 (file)
index 0000000..5ebed6a
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+  <html>
+    <table border="1">
+      <xsl:apply-templates/>
+    </table>
+  </html>
+</xsl:template>
+
+<xsl:template match="cd">
+  <tr>
+     <td><xsl:apply-templates select="titulo"/></td>
+     <td><xsl:apply-templates select="artista"/></td>
+     <td><xsl:value-of select="@valoracion"/></td>
+  </tr>
+</xsl:template>
+
+<xsl:template match="titulo|artista">
+    <u><xsl:apply-templates/></u>
+</xsl:template>
+
+</xsl:stylesheet>
index 95cf4fd..e681b16 100644 (file)
Binary files a/presentacion2.odp and b/presentacion2.odp differ
diff --git a/tienda-html.xsl b/tienda-html.xsl
new file mode 100644 (file)
index 0000000..9991f24
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match='/'>
+  <html> 
+     <head><title>Generado con tienda-html.xsl</title></head>
+     <body>
+        <h1> <xsl:apply-templates /> </h1>
+     </body>
+  </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/tienda0.xml b/tienda0.xml
new file mode 100644 (file)
index 0000000..418b383
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>\r
+<?xml-stylesheet href="tienda0.xsl" type="text/xsl"?>\r
+<tienda>\r
+ <nombre>La tiendecilla</nombre>\r
+ <telefono>953 87 12 23</telefono>\r
+</tienda>\r
diff --git a/tienda1-html.xsl b/tienda1-html.xsl
new file mode 100644 (file)
index 0000000..8d722d6
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match='/'>
+  <html> 
+  <xsl:apply-templates /> 
+</html>
+</xsl:template>
+
+<xsl:template match='tienda'>
+  <head><title><xsl:value-of select='nombre' /> (Generado por tienda1-html.xsl)</title></head>
+  <body>
+    <h1><xsl:value-of select='nombre' /> </h1>
+    
+    <h2>Teléfono: <xsl:value-of select='telefono' /> </h2>
+
+    <h2>Nuestros mejores productos </h2>
+    <table>
+      <tr><th>Código</th><th>Existencias</th><th>Artículo</th></tr>
+      <xsl:apply-templates select='producto' />
+    </table>
+  </body>
+</xsl:template>
+
+<xsl:template match='producto'>
+  <tr><xsl:apply-templates /></tr>
+</xsl:template>
+
+<xsl:template match='codigo|cantidad|articulo'>
+  <td><xsl:apply-templates /></td>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/tienda1.xml b/tienda1.xml
new file mode 100644 (file)
index 0000000..6da3a0a
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>\r
+<?xml-stylesheet href="tienda1-html.xsl" type="text/xsl"?>\r
+<tienda>\r
+  <nombre>La tiendecilla</nombre>\r
+  <telefono>953 87 12 23</telefono>\r
+\r
+  <producto>\r
+   <codigo>92</codigo>\r
+   <cantidad>10</cantidad>\r
+   <articulo>Radio-Casette</articulo>\r
+  </producto>\r
+  <producto>\r
+   <codigo>103</codigo>\r
+   <cantidad>50</cantidad>\r
+   <articulo>Reloj Cocina</articulo>\r
+  </producto>\r
+  <producto>\r
+   <codigo>1312</codigo>\r
+   <cantidad>3</cantidad>\r
+   <articulo>Sofá</articulo>\r
+  </producto>\r
+</tienda>
\ No newline at end of file
diff --git a/xml-xslt.xml b/xml-xslt.xml
new file mode 100644 (file)
index 0000000..2f40749
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="plantilla2.xsl" type="text/xsl"?>
+<catalogo>
+    <cd valoracion="bueno">
+        <titulo>Empire Burlesque</titulo>
+        <artista>Bob Dylan</artista>
+        <pais>USA</pais>
+        <discografica>Columbia</discografica>
+        <precio>10.90</precio>
+        <anio>1985</anio>
+    </cd>
+    <cd valoracion="malo">
+        <titulo>Bulería</titulo>
+        <artista>David Bisbal</artista>
+        <pais>España</pais>
+        <precio>20</precio>
+        <anio>2004</anio>
+    </cd>
+</catalogo>
diff --git a/xsl01.png b/xsl01.png
new file mode 100644 (file)
index 0000000..7d01908
Binary files /dev/null and b/xsl01.png differ
diff --git a/xslt-example1.png b/xslt-example1.png
new file mode 100644 (file)
index 0000000..6594613
Binary files /dev/null and b/xslt-example1.png differ
diff --git a/xslt02.png b/xslt02.png
new file mode 100644 (file)
index 0000000..fdbe54e
Binary files /dev/null and b/xslt02.png differ
diff --git a/xslt03.png b/xslt03.png
new file mode 100644 (file)
index 0000000..e61d738
Binary files /dev/null and b/xslt03.png differ