Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4.  
  5. <!--Normalment preservar espais en strings com nom o title, i esborrar espais en numeros com year, price
  6. <xsl:strip-space elements="catalog"/>
  7. <xsl:preserve-space elements="title artist" />
  8. -->
  9.  
  10. <xsl:template match="/">
  11. <html>
  12. <body>
  13. <h2>My CD Collection </h2>
  14. <h3>Number of cds </h3> <xsl:value-of select="count(//cd)"/>
  15.  
  16. <xsl:apply-templates select = "/catalog/cd"/>
  17.  
  18.  
  19. <table border = "1">
  20.  
  21. <tr bgcolor="#9acd32">
  22. <th>Title</th>
  23. <th>Artist</th>
  24. <th>Year</th>
  25. </tr>
  26. <xsl:for-each select="/catalog/cd">
  27. <xsl:sort select="artist" order="descending" data-type="text"/>
  28. <tr>
  29. <td> <xsl:apply-templates select = "artist"/></td>
  30. <td><xsl:apply-templates select = "title"/></td>
  31. <td><xsl:value-of select="year"/></td>
  32. </tr>
  33. </xsl:for-each>
  34. </table>
  35. </body>
  36. </html>
  37. </xsl:template>
  38.  
  39. <xsl:template match="cd">
  40. <p>
  41. <xsl:apply-templates select="artist"/>
  42. <xsl:apply-templates select = "artist" mode="plantilla1"/>
  43. <xsl:apply-templates select="year"/>
  44. </p>
  45. </xsl:template>
  46.  
  47.  
  48. <xsl:template match="artist" mode="plantilla1">
  49. <p>
  50. Total Artista : <xsl:value-of select="count(.)"/>
  51.  
  52. </p>
  53. </xsl:template>
  54.  
  55. <xsl:template match="title">
  56. Title: <span style="color:#ff0000">
  57. <xsl:value-of select="."/></span>
  58. <br />
  59. </xsl:template>
  60.  
  61. <xsl:template match="artist">
  62. <company>Nicrosoft</company>
  63. Artist: <span style="color:#00ff00">
  64. <xsl:value-of select="."/></span>
  65. <br />
  66. </xsl:template>
  67.  
  68.  
  69. <xsl:template match="year">
  70. <p>
  71. Year: <span style="color:#ff0000">
  72. <xsl:value-of select="."/></span>
  73. </p>
  74. </xsl:template>
  75. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement