Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
  4. >
  5. <xsl:output method="html" indent="yes"/>
  6.  
  7. <xsl:template match="/">
  8. <html>
  9. <head>
  10. <meta charset="UTF-8" />
  11. <title>Hypertext hypermedia</title>
  12. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  13. <link rel="stylesheet" href="index.css" />
  14. </head>
  15. <body>
  16. <div id="wrapper">
  17. <header>
  18. <h1>Hypertext hypermedia</h1>
  19. </header>
  20. <!-- menu for moving within a page -->
  21. <xsl:call-template name="nav"/>
  22.  
  23. <div id="content">
  24. <!-- a place for information about lecture, laboratory, project and links -->
  25. <h3 id="lecture">
  26. Lecture
  27. <!-- reference to a template that allows to display a picture -->
  28. <xsl:apply-templates select="course/information/media/image"/>
  29. </h3>
  30. <p>
  31. Information about the lecture.
  32. </p>
  33. <!-- information about lecture -->
  34. <xsl:apply-templates select="course/classes[@kind='lecture']/component"/>
  35. <!-- reference to a template that allows to display information about laboratory and project -->
  36. <xsl:apply-templates select="course/classes"/>
  37. <xsl:apply-templates select="course/project"/>
  38. <h3 id="links">Additional information about HTML and XML</h3>
  39. <ul>
  40. <!-- reference to a template that allows to display links -->
  41. <xsl:apply-templates select="course/information/links/link"/>
  42. </ul>
  43. </div>
  44. <!-- end content -->
  45. </div>
  46. <!-- end wrapper -->
  47. <footer>
  48. <xsl:apply-templates select="course/author"/>
  49. <!-- reference to a template that allows for displaying information about the name and surname of the student -->
  50. </footer>
  51. </body>
  52. </html>
  53. </xsl:template>
  54.  
  55. <xsl:template match="author">
  56. Copyright 2019,
  57. <xsl:value-of select="name"/>
  58. <xsl:text> </xsl:text>
  59. <xsl:value-of select="surname"/>
  60. </xsl:template>
  61.  
  62. <xsl:template match="classes">
  63. <xsl:if test="@kind='laboratory'">
  64. <h3 id="lab">Laboratory</h3>
  65. <p>Information about the laboratory.</p>
  66. <ol>
  67. <xsl:apply-templates select="component"/>
  68. </ol>
  69. </xsl:if>
  70. </xsl:template>
  71.  
  72. <xsl:template match="component">
  73. <li>
  74. <xsl:value-of select="topic"/>
  75. </li>
  76. <ul>
  77. <xsl:apply-templates select="theme"/>
  78. </ul>
  79. </xsl:template>
  80.  
  81. <xsl:template match="theme">
  82. <li>
  83. <xsl:value-of select="."/>
  84. </li>
  85. </xsl:template>
  86.  
  87. <xsl:template match="classes[@kind='project']">
  88. <h3 id="project">Project</h3>
  89. <p>Information about the project.</p>
  90. <table style="width:50%; border:5px solid red">
  91. <tr>
  92. <th>Title of the project</th>
  93. <th>Score</th>
  94. </tr>
  95. <xsl:apply-templates select="component"/>
  96. </table>
  97. </xsl:template>
  98.  
  99. <xsl:template match="classes[@kind='project']/component">
  100. <tr>
  101. <td><xsl:value-of select="topic"/></td>
  102. <td><xsl:value-of select="score"/></td>
  103. </tr>
  104. </xsl:template>
  105.  
  106. <xsl:template name="nav">
  107. <nav>
  108. <ul>
  109. <li><a href="#lecture">Lecture</a></li>
  110. <li><a href="#lab">Laboratory</a></li>
  111. <li><a href="#project">Project</a></li>
  112. <li><a href="#links">Links</a></li>
  113. </ul>
  114. </nav>
  115. </xsl:template>
  116.  
  117. <xsl:template match="media/image">
  118. <img>
  119. <xsl:attribute name="src">
  120. <xsl:value-of select="@source"/>
  121. </xsl:attribute>
  122. <xsl:attribute name="class">right</xsl:attribute>
  123. <xsl:attribute name="title">
  124. <xsl:value-of select="."/>
  125. </xsl:attribute>
  126. </img>
  127. </xsl:template>
  128.  
  129. <xsl:template match="links/link">
  130. <xsl:if test="not(position()=last())">
  131. <li>
  132. <a>
  133. <xsl:attribute name="href">
  134. <xsl:value-of select="@source"/>
  135. </xsl:attribute>
  136. <xsl:value-of select="."/>
  137. </a>
  138. </li>
  139. </xsl:if>
  140. </xsl:template>
  141.  
  142. <xsl:template match="classes[@kind='lecture']/component">
  143. <xsl:for-each select="theme">
  144. <xsl:sort select="." order="ascending"/>
  145. <xsl:value-of select="position()"/>
  146. <xsl:text>. </xsl:text>
  147. <xsl:value-of select="."/>
  148. <br/>
  149. </xsl:for-each>
  150. </xsl:template>
  151.  
  152. <!--
  153. <nav>
  154. <ul>
  155. <li> <a href="#lecture">Lecture</a> </li>
  156. <li> <a href="#lab">Laboratory</a> </li>
  157. <li> <a href="#project">Project</a> </li>
  158. <li> <a href="#links">Links</a> </li>
  159. </ul>
  160. </nav>
  161. </xsl:template>
  162. -->
  163.  
  164. <!--
  165. <h3 id="lab">Laboratory</h3>
  166. <p>
  167. Information about the laboratory.
  168. </p>
  169. <ol>
  170. <li>......
  171. <ul>
  172. <li>...... </li>
  173. </ul>
  174. </li>
  175.  
  176. </ol>
  177. -->
  178.  
  179. <!--
  180. <h3 id="project">Project</h3>
  181. <p>
  182. Information about the project.
  183. </p>
  184. <table style="width:50%; border: 5px solid red">
  185. <tr>
  186. <th>Title of the project</th>
  187. <th>Score</th>
  188. </tr>
  189.  
  190. </table>
  191. -->
  192.  
  193. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement