Advertisement
Chevallier

shitty shit xml

Mar 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.90 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!--
  3.   New Perspectives on XML, 3rd Edition
  4.   Tutorial 6
  5.   Tutorial Project
  6.  
  7.   DVD Library XSLT Style Sheet
  8.   Author: Nicolas Catlin
  9.   Date: 03/26/2019
  10.  
  11.   Filename:         dvdlibrary.xsl
  12.  
  13. -->
  14.  
  15. <xsl:stylesheet version="1.0"
  16.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  17.    <xsl:variable name="currentYear" select="2019" />
  18.    <xsl:output method="html"
  19.      doctype-system="about:legacy-compat"
  20.      encoding="UTF-8"
  21.      indent="yes" />
  22.  
  23.    <xsl:template match="/">
  24.     <html>
  25.        <head>
  26.           <title>Jenna's DVD Collection</title>
  27.           <link href="dvdlibrarystyles.css"
  28.                 rel="stylesheet" type="text/css" />
  29.        </head>
  30.        <body>
  31.           <header>
  32.              <h1>Jenna's DVD Collection</h1>
  33.           </header>
  34.             <section>
  35.                <h1>DVD List</h1>
  36.                <xsl:apply-templates select="dvdlibrary/dvd">
  37.                   <xsl:sort select="title" />
  38.                </xsl:apply-templates>
  39.             </section>
  40.        </body>
  41.     </html>
  42.    </xsl:template>
  43.  
  44.   <xsl:template match="dvd">
  45.       <article>
  46.          <h1>
  47.             <xsl:value-of select="title" />
  48.          </h1>
  49.          <h2>
  50.             Featuring:
  51.             <xsl:for-each select="characters/character">
  52.             [
  53.                <xsl:value-of select="." />
  54.             ]
  55.             </xsl:for-each>
  56.          </h2>
  57.          <p>
  58.             Bonus Features:
  59.             <span>
  60.                <xsl:for-each select="bonus/feature">
  61.                   <xsl:value-of select="." />/
  62.                </xsl:for-each>
  63.             </span>
  64.          </p>
  65.      <table>
  66.         <tr>
  67.           <th>Price</th>
  68.           <th>Location</th>
  69.           <th>Release Date</th>
  70.           <th>Years Since Release</th>
  71.         </tr>
  72.         <tr>
  73.           <td><xsl:value-of select="format-number(purchased/price, '$#, ##.##')"  /></td>
  74.           <td><xsl:value-of select="purchased/location" /></td>
  75.           <td><xsl:value-of select="year" /></td>
  76.           <td><xsl:value-of select="$currentYear - year" /></td>
  77.         </tr>
  78.         <tr>
  79.           <td colspan="4">
  80.              <p>My Rating:</p>
  81.                  <xsl:call-template name="drawStars">
  82.                      <xsl:with-param name="starFile" select="'star.png'" />
  83.                      <xsl:with-param name="starCount" select="rating" />
  84.                  </xsl:call-template>
  85.           </td>
  86.         </tr>
  87.       </table>
  88.       </article>
  89.   </xsl:template>
  90.  
  91.   <xsl:template name="drawStars">
  92.       <xsl:param name="starFile" />
  93.       <xsl:param name="starCount" />
  94.      
  95.       <xsl:if test="$starCount > 0">
  96.           <img src="($starFile)" alt="" />
  97.           <xsl:call-template name="drawStars">
  98.               <xsl:with-param name="starFile" select="$starFile" />
  99.               <xsl:with-param name="starCount" select="$starCount - 1" />
  100.           </xsl:call-template>
  101.       </xsl:if>
  102.   </xsl:template>
  103.      
  104.  
  105. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement