Advertisement
Guest User

laborka 3

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