odml.xsl 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:odml="http://www.g-node.org/odml">
  4. <!-- ************************************************ -->
  5. <!-- root template -->
  6. <xsl:template match="odML">
  7. <xsl:variable name="repository" select="repository"/>
  8. <html>
  9. <style type="text/css">
  10. body { margin-left:2%; margin-top:10px; padding:0;} div { border:0px solid #888; }
  11. #navigationContainer { left:10%; width:95%;}
  12. #contentContainer { left:10%; width:95%;}
  13. </style>
  14. <body>
  15. <a name="top" style="color:#336699"><h1>odML - Metadata</h1></a>
  16. <div id="navigationContainer">
  17. <p>
  18. <hr style="color:yellow; background-color:#336699; height:4px; margin-right:0; text-align:right; border:1px dashed black;"/>
  19. <h2>Document info</h2>
  20. <b>Author: </b><xsl:if test="author"><xsl:value-of select="author"/></xsl:if><br/>
  21. <b>Date: </b><xsl:if test="date"><xsl:value-of select="date"/></xsl:if><br/>
  22. <b>Version: </b><xsl:if test="version"><xsl:value-of select="version"/></xsl:if><br/>
  23. <b>Repository: </b><xsl:if test="repository"><xsl:value-of select="repository"/></xsl:if><br/>
  24. </p>
  25. <hr style="color:yellow; background-color:#336699; height:4px; margin-right:0; text-align:right; border:1px dashed black;"/>
  26. <h2>Structure</h2>
  27. <font size ="-1" >
  28. <xsl:if test="section">
  29. <xsl:for-each select="section">
  30. <li>
  31. <xsl:call-template name="sectionTemplate">
  32. <xsl:with-param name="navigation">1</xsl:with-param>
  33. <xsl:with-param name="anchorBase">Sec</xsl:with-param>
  34. <xsl:with-param name="url" select="$repository"/>
  35. </xsl:call-template>
  36. </li>
  37. </xsl:for-each>
  38. </xsl:if></font>
  39. </div>
  40. <div id="contentContainer">
  41. <hr style="color:yellow; background-color:#336699; height:4px; margin-right:0; text-align:right; border:1px dashed black;"/>
  42. <h2>Content</h2>
  43. <xsl:if test="section">
  44. <xsl:for-each select="section">
  45. <xsl:call-template name="sectionTemplate">
  46. <xsl:with-param name="navigation">0</xsl:with-param>
  47. <xsl:with-param name="anchorBase">Sec</xsl:with-param>
  48. <xsl:with-param name="url" select="$repository"/>
  49. </xsl:call-template>
  50. </xsl:for-each>
  51. </xsl:if>
  52. </div>
  53. </body>
  54. </html>
  55. </xsl:template>
  56. <!-- ************************************************ -->
  57. <!-- section template. -->
  58. <xsl:template name="sectionTemplate" match="section">
  59. <xsl:param name="navigation"/>
  60. <xsl:param name="anchorBase"/>
  61. <xsl:param name="url"/>
  62. <!-- create the anchor for the navigation menu-->
  63. <xsl:variable name="anchorName" select="concat($anchorBase,position())"/>
  64. <!-- set new baseurl if specified within this section otherwise use the old one -->
  65. <xsl:variable name="repository">
  66. <xsl:choose>
  67. <xsl:when test="repository">
  68. <xsl:value-of select ="repository"/>
  69. </xsl:when>
  70. <xsl:otherwise>
  71. <xsl:value-of select ="$url"/>
  72. </xsl:otherwise>
  73. </xsl:choose>
  74. </xsl:variable>
  75. <!-- print out the content -->
  76. <xsl:choose>
  77. <!-- fill the navigation container if this is the task (navigation param = 1) -->
  78. <xsl:when test="$navigation = 1">
  79. <!-- create a link to the anchor in the content container -->
  80. <ol style="compact">
  81. <font size="normal"><a href="#{$anchorName}">
  82. <xsl:value-of select="name"/> (type: <xsl:value-of select="type"/>)
  83. </a></font>
  84. <!-- recursive call if there are subsections -->
  85. <xsl:if test="section">
  86. <xsl:for-each select="section">
  87. <xsl:call-template name="sectionTemplate">
  88. <xsl:with-param name="navigation" select="$navigation"/>
  89. <xsl:with-param name="anchorBase" select="concat($anchorName,'SubSec')"/>
  90. <xsl:with-param name="url" select="$repository"/>
  91. </xsl:call-template>
  92. </xsl:for-each>
  93. </xsl:if>
  94. </ol>
  95. </xsl:when>
  96. <!-- otherwise use template to display the content (navigation !=1) -->
  97. <xsl:otherwise>
  98. <a name="{$anchorName}"><h3>Section: <xsl:value-of select="name"/> </h3></a>
  99. <p>
  100. <b>Type: </b><xsl:value-of select="type"/><br/>
  101. <xsl:choose>
  102. <xsl:when test ="repository">
  103. <b>Repository: </b><xsl:value-of select="repository"/><br/>
  104. </xsl:when>
  105. <xsl:otherwise>
  106. <b>Repository: </b><xsl:value-of select="$repository"/><br/>
  107. </xsl:otherwise>
  108. </xsl:choose>
  109. <b>Link: </b><xsl:if test="link"><xsl:value-of select="link"/></xsl:if><br/>
  110. <b>Include:</b> <xsl:if test="include"><font color="red"><xsl:value-of select="include"/></font></xsl:if><br/>
  111. <b>Definition:</b> <xsl:if test="definition"><xsl:value-of select="definition"/></xsl:if><br/>
  112. <b>Mapping: </b> <xsl:if test="mapping"><xsl:value-of select="mapping"/></xsl:if><br/>
  113. </p>
  114. <!-- Check if there are any properties -->
  115. <xsl:if test="property">
  116. <table border="1" rules="rows" width="100%"><font size ="-1">
  117. <tr bgcolor="#336699">
  118. <th><font size="+1" color="white"><b>Name</b></font></th>
  119. <th><font size="+1" color="white"><b>Value</b></font></th>
  120. <th><font size="+1" color="white"><b>Uncertainty</b></font></th>
  121. <th><font size="+1" color="white"><b>Unit</b></font></th>
  122. <th><font size="+1" color="white"><b>value reference</b></font></th>
  123. <th><font size="+1" color="white"><b>Type</b></font></th>
  124. <th><font size="+1" color="white"><b>Comment</b></font></th>
  125. <!--
  126. <th><font size="+1" color="white"><b>Dependency</b></font></th>
  127. <th><font size="+1" color="white"><b>Dependency Value</b></font></th>
  128. -->
  129. <th><font size="+1" color="white"><b>Definition</b></font></th>
  130. </tr>
  131. <xsl:for-each select="property">
  132. <xsl:variable name="anchor">
  133. <xsl:value-of select ="name"/>
  134. </xsl:variable>
  135. <tr>
  136. <td width="15%"><a name="{$anchor}"/>
  137. <p><xsl:value-of select="name"/></p>
  138. </td>
  139. <td width="10%">
  140. <xsl:for-each select="value">
  141. <p><xsl:value-of select="text()"/><br/></p>
  142. </xsl:for-each>
  143. </td>
  144. <td width="5%">
  145. <xsl:for-each select="value">
  146. <p><xsl:value-of select="uncertainty"/><br/></p>
  147. </xsl:for-each>
  148. </td>
  149. <td width="5%">
  150. <xsl:for-each select="value">
  151. <p><xsl:value-of select="unit"/><br/></p>
  152. </xsl:for-each>
  153. </td>
  154. <td width="5%">
  155. <xsl:for-each select="value">
  156. <p><xsl:value-of select="reference"/><br/></p>
  157. </xsl:for-each>
  158. </td>
  159. <td width="5%">
  160. <xsl:for-each select="value">
  161. <p><xsl:value-of select="type"/><br/></p>
  162. </xsl:for-each>
  163. </td>
  164. <td width="22.5%">
  165. <xsl:for-each select="value">
  166. <p><xsl:value-of select="comment"/><br/></p>
  167. </xsl:for-each>
  168. </td>
  169. <!--
  170. <td width="5%"><p><xsl:value-of select="dependency"/></p></td>
  171. <td width="5%"><p><xsl:value-of select="dependencyValue"/></p></td>
  172. -->
  173. <td width="22.5%"><p><xsl:value-of select="definition"/></p></td>
  174. </tr>
  175. </xsl:for-each></font>
  176. </table>
  177. </xsl:if>
  178. <a href="#top"><tiny>top</tiny></a>
  179. <hr style="background-color:#336699; height:1px; margin-right:0; text-align:right;"/>
  180. <!-- recursive call if there are subsections -->
  181. <xsl:if test="section">
  182. <xsl:for-each select="section">
  183. <xsl:call-template name="sectionTemplate">
  184. <xsl:with-param name="navigation" select="$navigation"/>
  185. <xsl:with-param name="anchorBase" select="concat($anchorName,'SubSec')"/>
  186. <xsl:with-param name="url" select="$repository"/>
  187. </xsl:call-template>
  188. </xsl:for-each>
  189. </xsl:if>
  190. </xsl:otherwise>
  191. </xsl:choose>
  192. </xsl:template>
  193. </xsl:stylesheet>