odml.xsl 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. </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" valign="middle" align="left">
  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>Type</b></font></th>
  122. <th><font size="+1" color="white"><b>Reference</b></font></th>
  123. <th><font size="+1" color="white"><b>Definition</b></font></th>
  124. <th><font size="+1" color="white"><b>Value origin</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. </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%"><p><xsl:value-of select="value"/></p></td>
  139. <td width="5%"><p><xsl:value-of select="uncertainty"/></p></td>
  140. <td width="5%"><p><xsl:value-of select="unit"/></p></td>
  141. <td width="5%"><p><xsl:value-of select="type"/></p></td>
  142. <td width="5%"><p><xsl:value-of select="reference"/></p></td>
  143. <td width="22.5%"><p><xsl:value-of select="definition"/></p></td>
  144. <td width="7.5%%"><p><xsl:value-of select="value_origin"/></p></td>
  145. <!--
  146. <td width="5%"><p><xsl:value-of select="dependency"/></p></td>
  147. <td width="5%"><p><xsl:value-of select="dependencyValue"/></p></td>
  148. -->
  149. </tr>
  150. </xsl:for-each></font>
  151. </table>
  152. </xsl:if>
  153. <a href="#top"><tiny>top</tiny></a>
  154. <hr style="background-color:#336699; height:1px; margin-right:0; text-align:right;"/>
  155. <!-- recursive call if there are subsections -->
  156. <xsl:if test="section">
  157. <xsl:for-each select="section">
  158. <xsl:call-template name="sectionTemplate">
  159. <xsl:with-param name="navigation" select="$navigation"/>
  160. <xsl:with-param name="anchorBase" select="concat($anchorName,'SubSec')"/>
  161. <xsl:with-param name="url" select="$repository"/>
  162. </xsl:call-template>
  163. </xsl:for-each>
  164. </xsl:if>
  165. </xsl:otherwise>
  166. </xsl:choose>
  167. </xsl:template>
  168. </xsl:stylesheet>