odml.xsl 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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"><font size="normal"><a href="#{$anchorName}">
  81. <xsl:value-of select="name"/> (type: <xsl:value-of select="type"/>)</a></font>
  82. <!-- recursive call if there are subsections -->
  83. <xsl:if test="section">
  84. <xsl:for-each select="section">
  85. <xsl:call-template name="sectionTemplate">
  86. <xsl:with-param name="navigation" select="$navigation"/>
  87. <xsl:with-param name="anchorBase" select="concat($anchorName,'SubSec')"/>
  88. <xsl:with-param name="url" select="$repository"/>
  89. </xsl:call-template>
  90. </xsl:for-each>
  91. </xsl:if>
  92. </ol>
  93. </xsl:when>
  94. <!-- otherwise use template to display the content (navigation !=1) -->
  95. <xsl:otherwise>
  96. <a name="{$anchorName}"><h3>Section: <xsl:value-of select="name"/> </h3></a>
  97. <p>
  98. <b>Type: </b><xsl:value-of select="type"/><br/>
  99. <b>Id: </b><xsl:value-of select="id"/><br/>
  100. <xsl:choose>
  101. <xsl:when test ="repository">
  102. <b>Repository: </b><xsl:value-of select="repository"/><br/>
  103. </xsl:when>
  104. <xsl:otherwise>
  105. <b>Repository: </b><xsl:value-of select="$repository"/><br/>
  106. </xsl:otherwise>
  107. </xsl:choose>
  108. <b>Link: </b><xsl:if test="link"><xsl:value-of select="link"/></xsl:if><br/>
  109. <b>Include:</b> <xsl:if test="include"><font color="red"><xsl:value-of select="include"/></font></xsl:if><br/>
  110. <b>Definition:</b> <xsl:if test="definition"><xsl:value-of select="definition"/></xsl:if><br/>
  111. <b>Mapping: </b> <xsl:if test="mapping"><xsl:value-of select="mapping"/></xsl:if><br/>
  112. </p>
  113. <!-- Check if there are any properties -->
  114. <xsl:if test="property">
  115. <table border="1" rules="rows" width="100%"><font size ="-1">
  116. <tr bgcolor="#336699">
  117. <th><font size="+1" color="white"><b>Name</b></font></th>
  118. <th><font size="+1" color="white"><b>Value</b></font></th>
  119. <th><font size="+1" color="white"><b>Uncertainty</b></font></th>
  120. <th><font size="+1" color="white"><b>Unit</b></font></th>
  121. <th><font size="+1" color="white"><b>value reference</b></font></th>
  122. <th><font size="+1" color="white"><b>Type</b></font></th>
  123. <th><font size="+1" color="white"><b>Comment</b></font></th>
  124. <!--
  125. <th><font size="+1" color="white"><b>Dependency</b></font></th>
  126. <th><font size="+1" color="white"><b>Dependency Value</b></font></th>
  127. -->
  128. <th><font size="+1" color="white"><b>Definition</b></font></th>
  129. </tr>
  130. <xsl:for-each select="property">
  131. <xsl:variable name="anchor">
  132. <xsl:value-of select ="name"/>
  133. </xsl:variable>
  134. <tr>
  135. <td width="15%"><a name="{$anchor}"/>
  136. <p><xsl:value-of select="name"/></p>
  137. </td>
  138. <td width="10%">
  139. <xsl:for-each select="value">
  140. <p><xsl:value-of select="text()"/><br/></p>
  141. </xsl:for-each>
  142. </td>
  143. <td width="5%">
  144. <xsl:for-each select="value">
  145. <p><xsl:value-of select="uncertainty"/><br/></p>
  146. </xsl:for-each>
  147. </td>
  148. <td width="5%">
  149. <xsl:for-each select="value">
  150. <p><xsl:value-of select="unit"/><br/></p>
  151. </xsl:for-each>
  152. </td>
  153. <td width="5%">
  154. <xsl:for-each select="value">
  155. <p><xsl:value-of select="reference"/><br/></p>
  156. </xsl:for-each>
  157. </td>
  158. <td width="5%">
  159. <xsl:for-each select="value">
  160. <p><xsl:value-of select="type"/><br/></p>
  161. </xsl:for-each>
  162. </td>
  163. <td width="22.5%">
  164. <xsl:for-each select="value">
  165. <p><xsl:value-of select="comment"/><br/></p>
  166. </xsl:for-each>
  167. </td>
  168. <!--
  169. <td width="5%"><p><xsl:value-of select="dependency"/></p></td>
  170. <td width="5%"><p><xsl:value-of select="dependencyValue"/></p></td>
  171. -->
  172. <td width="22.5%"><p><xsl:value-of select="definition"/></p></td>
  173. </tr>
  174. </xsl:for-each></font>
  175. </table>
  176. </xsl:if>
  177. <a href="#top"><tiny>top</tiny></a>
  178. <hr style="background-color:#336699; height:1px; margin-right:0; text-align:right;"/>
  179. <!-- recursive call if there are subsections -->
  180. <xsl:if test="section">
  181. <xsl:for-each select="section">
  182. <xsl:call-template name="sectionTemplate">
  183. <xsl:with-param name="navigation" select="$navigation"/>
  184. <xsl:with-param name="anchorBase" select="concat($anchorName,'SubSec')"/>
  185. <xsl:with-param name="url" select="$repository"/>
  186. </xsl:call-template>
  187. </xsl:for-each>
  188. </xsl:if>
  189. </xsl:otherwise>
  190. </xsl:choose>
  191. </xsl:template>
  192. </xsl:stylesheet>