|
|
(Hi ha 464 revisions intermèdies sense mostrar fetes per més de 100 usuaris) |
Línia 1: |
Línia 1: |
| == '''Exemple Empleats''' ==
| | Interesting article, http://roweda.in/toyota-echo-seats.html http://roweda.in/toyota-echo-seats.html, 6548, http://roweda.in/sullivan-missouri-car-dealerships.html http://roweda.in/sullivan-missouri-car-dealerships.html, nsdcvw, http://roweda.in/dierks-bentley-band-of-brothers.html http://roweda.in/dierks-bentley-band-of-brothers.html, %-(, http://roweda.in/massachusetts-maynard-mercury.html http://roweda.in/massachusetts-maynard-mercury.html, >:-OOO, http://roweda.in/car-corner-cartersville.html http://roweda.in/car-corner-cartersville.html, ixl, http://roweda.in/toyota-colorado-maintainence.html http://roweda.in/toyota-colorado-maintainence.html, 33378, http://roweda.in/1997-ford-mustang-wheels.html http://roweda.in/1997-ford-mustang-wheels.html, =-(((, http://roweda.in/insurance-auto-auction-of-tampa-bay.html http://roweda.in/insurance-auto-auction-of-tampa-bay.html, dxlc, http://roweda.in/honda-motorsport-gnl-quebec-canada.html http://roweda.in/honda-motorsport-gnl-quebec-canada.html, :-[[, http://roweda.in/budget-car-rental-great-britain.html http://roweda.in/budget-car-rental-great-britain.html, neqyk, http://roweda.in/fena-apd-plymouth-michigan.html http://roweda.in/fena-apd-plymouth-michigan.html, :-], http://roweda.in/value-used-car-sales-ontario-2998.html http://roweda.in/value-used-car-sales-ontario-2998.html, 8], http://roweda.in/1967-ford-mustang-fastback-nebraska.html http://roweda.in/1967-ford-mustang-fastback-nebraska.html, uiqky, http://roweda.in/1966-ford-restoration-parts.html http://roweda.in/1966-ford-restoration-parts.html, 6280, http://roweda.in/indy-car-speedway-series.html http://roweda.in/indy-car-speedway-series.html, ldvtm, http://roweda.in/seattle-best-car-rentals.html http://roweda.in/seattle-best-car-rentals.html, >:-OOO, http://roweda.in/tata-indicom-dsl.html http://roweda.in/tata-indicom-dsl.html, 482, http://roweda.in/hyundai-sonata-2011-bethlehem-pa.html http://roweda.in/hyundai-sonata-2011-bethlehem-pa.html, 8PP, http://roweda.in/chrysler-plants-in-mexico.html http://roweda.in/chrysler-plants-in-mexico.html, 8), |
| | |
| Codi XML d'una BBDD d'empleats amb sou ('''empleats.xml'''):
| |
| | |
| <?xml version="1.0" encoding='UTF-8'?>
| |
| <?xml-stylesheet href="empleats.xsl" type="text/xsl"?>
| |
| <empresa>
| |
| <departament>
| |
| <empleats>
| |
| <nom>Eduard</nom>
| |
| <sou>3500</sou>
| |
| </empleats>
| |
| <empleats>
| |
| <nom>Montse</nom>
| |
| <sou>1250</sou>
| |
| </empleats>
| |
| <empleats>
| |
| <nom>Lluis</nom>
| |
| <sou>750</sou>
| |
| </empleats>
| |
| <empleats>
| |
| <nom>Jordi</nom>
| |
| <sou>1850</sou>
| |
| </empleats>
| |
| </departament>
| |
| </empresa>
| |
| | |
| | |
| A continuació tenim el codi font del fitxer XSL ('''empleats.xsl''') que executarem per mostrar les dades del XML anterior:
| |
| | |
| <pre>
| |
| <?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>
| |
| <table border="1">
| |
| <tr>
| |
| <th>Nom</th>
| |
| <th>Sou</th>
| |
| </tr>
| |
| <xsl:for-each select="empresa/departament/empleats">
| |
| <xsl:choose>
| |
| <!-- sous superiors a 1500 -->
| |
| <xsl:when test="sou > 1500">
| |
| <tr bgcolor="green">
| |
| <td><xsl:value-of select="nom"/></td>
| |
| <td><xsl:value-of select="sou"/></td>
| |
| </tr>
| |
| </xsl:when>
| |
| <!-- sous inferiors a 1000 -->
| |
| <xsl:when test="sou < 1000">
| |
| <tr bgcolor="yellow">
| |
| <td><xsl:value-of select="nom"/></td>
| |
| <td><xsl:value-of select="sou"/></td>
| |
| </tr>
| |
| </xsl:when>
| |
| <!-- sous entre 1000 i 1500 -->
| |
| <xsl:otherwise>
| |
| <tr bgcolor="grey">
| |
| <td><xsl:value-of select="nom"/></td>
| |
| <td><xsl:value-of select="sou"/></td>
| |
| </tr>
| |
| </xsl:otherwise>
| |
| </xsl:choose>
| |
| </xsl:for-each>
| |
| </table>
| |
| </body>
| |
| </html>
| |
| </xsl:template>
| |
| </xsl:stylesheet> | |
| </pre>
| |
| | |
| | |
| Aquest exemple ens mostrarà una taula on apareixeran els noms i sous dels empleats amb els següents criteris:
| |
| | |
| * En groc els empleats amb un sou inferior a 1000
| |
| * En gris els empleats amb un sou entre 1000 i 1500
| |
| * En verd els empleats amb un sou superior a 1500
| |
| | |
| I el resultat serà quelcom semblant a:
| |
| | |
| {| class="wikitable" margin:0 0 1em 1em"
| |
| ! Nom !! Sou
| |
| |-style="background:green;"
| |
| | Eduard || 3500
| |
| |-style="background:grey;"
| |
| | Montse || 1250
| |
| |-style="background:yellow;"
| |
| | Lluís || 750
| |
| |-style="background:green;"
| |
| | Jordi || 1850
| |
| |}
| |
| | |
| | |
| | |
| | |
| | |
| == '''Exemple DiscsXML''' ==
| |
| | |
| Codi XML sobre una BBDD de discs ('''DiscsXML.xml'''):
| |
| | |
| <?xml version="1.0" encoding="UTF-8"?>
| |
| <?xml-stylesheet type="text/xsl" href="DiscsXML.xsl"?>
| |
| <catalog> | |
| <cd>
| |
| <title>Empire Burlesque</title>
| |
| <artist>Bob Dylan</artist>
| |
| <country>USA</country>
| |
| <company>Columbia</company>
| |
| <price>10.90</price>
| |
| <year>1985</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Hide your heart</title>
| |
| <artist>Bonnie Tyler</artist>
| |
| <country>UK</country>
| |
| <company>CBS Records</company>
| |
| <price>9.90</price>
| |
| <year>1988</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Greatest Hits</title>
| |
| <artist>Dolly Parton</artist>
| |
| <country>USA</country>
| |
| <company>RCA</company>
| |
| <price>9.90</price>
| |
| <year>1982</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Still got the blues</title>
| |
| <artist>Gary Moore</artist>
| |
| <country>UK</country>
| |
| <company>Virgin records</company>
| |
| <price>10.20</price>
| |
| <year>1990</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Eros</title>
| |
| <artist>Eros Ramazzotti</artist>
| |
| <country>EU</country>
| |
| <company>BMG</company>
| |
| <price>9.90</price>
| |
| <year>1997</year>
| |
| </cd>
| |
| <cd>
| |
| <title>One night only</title>
| |
| <artist>Bee Gees</artist>
| |
| <country>UK</country>
| |
| <company>Polydor</company>
| |
| <price>10.90</price>
| |
| <year>1998</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Sylvias Mother</title>
| |
| <artist>Dr.Hook</artist>
| |
| <country>UK</country>
| |
| <company>CBS</company>
| |
| <price>8.10</price>
| |
| <year>1973</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Maggie May</title>
| |
| <artist>Rod Stewart</artist>
| |
| <country>UK</country>
| |
| <company>Pickwick</company>
| |
| <price>8.50</price>
| |
| <year>1990</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Romanza</title>
| |
| <artist>Andrea Bocelli</artist>
| |
| <country>EU</country>
| |
| <company>Polydor</company>
| |
| <price>10.80</price>
| |
| <year>1996</year>
| |
| </cd>
| |
| <cd>
| |
| <title>When a man loves a woman</title>
| |
| <artist>Percy Sledge</artist>
| |
| <country>USA</country>
| |
| <company>Atlantic</company>
| |
| <price>8.70</price>
| |
| <year>1987</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Black angel</title>
| |
| <artist>Savage Rose</artist>
| |
| <country>EU</country>
| |
| <company>Mega</company>
| |
| <price>10.90</price>
| |
| <year>1995</year>
| |
| </cd>
| |
| <cd>
| |
| <title>1999 Grammy Nominees</title>
| |
| <artist>Many</artist>
| |
| <country>USA</country>
| |
| <company>Grammy</company>
| |
| <price>10.20</price>
| |
| <year>1999</year>
| |
| </cd>
| |
| <cd>
| |
| <title>For the good times</title>
| |
| <artist>Kenny Rogers</artist>
| |
| <country>UK</country>
| |
| <company>Mucik Master</company>
| |
| <price>8.70</price>
| |
| <year>1995</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Big Willie style</title>
| |
| <artist>Will Smith</artist>
| |
| <country>USA</country>
| |
| <company>Columbia</company>
| |
| <price>9.90</price>
| |
| <year>1997</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Tupelo Honey</title>
| |
| <artist>Van Morrison</artist>
| |
| <country>UK</country>
| |
| <company>Polydor</company>
| |
| <price>8.20</price>
| |
| <year>1971</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Soulsville</title>
| |
| <artist>Jorn Hoel</artist>
| |
| <country>Norway</country>
| |
| <company>WEA</company>
| |
| <price>7.90</price>
| |
| <year>1996</year>
| |
| </cd>
| |
| <cd>
| |
| <title>The very best of</title>
| |
| <artist>Cat Stevens</artist>
| |
| <country>UK</country>
| |
| <company>Island</company>
| |
| <price>8.90</price>
| |
| <year>1990</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Stop</title>
| |
| <artist>Sam Brown</artist>
| |
| <country>UK</country>
| |
| <company>A and M</company>
| |
| <price>8.90</price>
| |
| <year>1988</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Bridge of Spies</title>
| |
| <artist>T`Pau</artist>
| |
| <country>UK</country>
| |
| <company>Siren</company>
| |
| <price>7.90</price>
| |
| <year>1987</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Private Dancer</title>
| |
| <artist>Tina Turner</artist>
| |
| <country>UK</country>
| |
| <company>Capitol</company>
| |
| <price>8.90</price>
| |
| <year>1983</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Midt om natten</title>
| |
| <artist>Kim Larsen</artist>
| |
| <country>EU</country>
| |
| <company>Medley</company>
| |
| <price>7.80</price>
| |
| <year>1983</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Pavarotti Gala Concert</title>
| |
| <artist>Luciano Pavarotti</artist>
| |
| <country>UK</country>
| |
| <company>DECCA</company>
| |
| <price>9.90</price>
| |
| <year>1991</year>
| |
| </cd>
| |
| <cd>
| |
| <title>The dock of the bay</title>
| |
| <artist>Otis Redding</artist>
| |
| <country>USA</country>
| |
| <company>Atlantic</company>
| |
| <price>7.90</price>
| |
| <year>1987</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Picture book</title>
| |
| <artist>Simply Red</artist>
| |
| <country>EU</country>
| |
| <company>Elektra</company>
| |
| <price>7.20</price>
| |
| <year>1985</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Red</title>
| |
| <artist>The Communards</artist>
| |
| <country>UK</country>
| |
| <company>London</company>
| |
| <price>7.80</price>
| |
| <year>1987</year>
| |
| </cd>
| |
| <cd>
| |
| <title>Unchain my heart</title>
| |
| <artist>Joe Cocker</artist>
| |
| <country>USA</country>
| |
| <company>EMI</company>
| |
| <price>8.20</price>
| |
| <year>1987</year>
| |
| </cd>
| |
| </catalog> | |
| | |
| | |
| | |
| A continuació tenim el codi font del fitxer XSL ('''DiscsXML.xsl''') que executarem per mostrar les dades del XML anterior:
| |
| | |
| <pre>
| |
| | |
| <?xml version="1.0" encoding="UTF-8"?>
| |
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| |
| <xsl:template match="/">
| |
| <pre><html>
| |
| <body>
| |
| <h2>My CD Collection</h2>
| |
| <table border="1">
| |
| <tr bgcolor="#9acd32">
| |
| <th>Title</th>
| |
| <th>Artist</th>
| |
| </tr>
| |
| <xsl:for-each select="catalog/cd">
| |
| <tr>
| |
| <td><xsl:value-of select="title"/></td>
| |
| <td><xsl:value-of select="artist"/></td>
| |
| </tr>
| |
| </xsl:for-each>
| |
| </table>
| |
| </body>
| |
| </html>
| |
| </xsl:template>
| |
| </xsl:stylesheet>
| |
| </pre>
| |
| | |
| | |
| | |
| | |
| | |
| | |
| == '''Links a exemples externs''' ==
| |
| | |
| | |
| | |
| | |
| | |
| | |
| == '''Vegeu També''' ==
| |
| | |
| [http://www.w3.org/TR/xpath/ Manual XPath]
| |
| | |
| [http://www.w3.org/TR/xslt Manual XSLT]
| |
| | |
| [[XSL#Sintaxi XSL|Sintaxi XSL]]
| |