odmlFileContent.xsl 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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">
  4. <!-- This stylesheet is for viewing odml-terminologies in a web browser -->
  5. <!-- Please note: only those elements will be displayed terminology related -->
  6. <!-- e.g. uncertainty, id, and valueComments will not be shown -->
  7. <!-- For viewing real metadata files use the odml.xsl stylesheet -->
  8. <!-- ************************************************ -->
  9. <!-- root template -->
  10. <xsl:template match="odML">
  11. <!-- if there is a base url definition read it and later pass it to the sections template -->
  12. <xsl:variable name="repository" select="repository"/>
  13. <html>
  14. <head>
  15. <link rel="stylesheet" href="./odml_style.css" />
  16. <link href="./odMLIcon.ico" rel="shortcut icon" livesrc="./odMLIcon.png" />
  17. </head>
  18. <body>
  19. <navigationContainer>
  20. <a name="top" style="color:#336699"><h1>odML - Metadata</h1></a>
  21. <div id="navigationContainer">
  22. <p>
  23. <hr style="color:yellow; background-color:#336699; height:4px; margin-right:0; text-align:right; border:1px dashed black;"/>
  24. <h2>Document info</h2>
  25. <b>Author: </b><xsl:if test="author"><xsl:value-of select="author"/></xsl:if><br/>
  26. <b>Date: </b><xsl:if test="date"><xsl:value-of select="date"/></xsl:if><br/>
  27. <b>Version: </b><xsl:if test="version"><xsl:value-of select="version"/></xsl:if><br/>
  28. <b>Repository: </b><xsl:if test="repository"><xsl:value-of select="repository"/></xsl:if><br/>
  29. </p>
  30. <hr style="color:yellow; background-color:#336699; height:4px; margin-right:0; text-align:right; border:1px dashed black;"/>
  31. <h2>Structure</h2>
  32. <font size ="-1" >
  33. <xsl:if test="section">
  34. <xsl:for-each select="section">
  35. <li>
  36. <xsl:call-template name="sectionTemplate">
  37. <xsl:with-param name="navigation">1</xsl:with-param>
  38. <xsl:with-param name="anchorBase">Sec</xsl:with-param>
  39. <xsl:with-param name="url" select="$repository"/>
  40. </xsl:call-template>
  41. </li>
  42. </xsl:for-each>
  43. </xsl:if>
  44. </font>
  45. </div>
  46. <div id="contentContainer">
  47. <hr style="color:yellow; background-color:#336699; height:4px; margin-right:0; text-align:right; border:1px dashed black;"/>
  48. <h2>Content</h2>
  49. <!-- apply the section template -->
  50. <xsl:if test="section">
  51. <xsl:for-each select="section">
  52. <xsl:call-template name="sectionTemplate">
  53. <xsl:with-param name="navigation">0</xsl:with-param>
  54. <xsl:with-param name="anchorBase">Sec</xsl:with-param>
  55. <xsl:with-param name="url" select="$repository"/>
  56. </xsl:call-template>
  57. </xsl:for-each>
  58. </xsl:if>
  59. </div>
  60. </navigationContainer>
  61. </body>
  62. </html>
  63. </xsl:template>
  64. <!-- ************************************************ -->
  65. <!-- section template. -->
  66. <xsl:template name="sectionTemplate" match="section">
  67. <xsl:param name="navigation"/>
  68. <xsl:param name="anchorBase"/>
  69. <xsl:param name="url"/>
  70. <xsl:variable name="anchorName" select="concat($anchorBase,position())"/>
  71. <!-- set new repository if specified within this section otherwise use the old one -->
  72. <xsl:variable name="repository">
  73. <xsl:choose>
  74. <xsl:when test="repository">
  75. <xsl:value-of select ="repository"/>
  76. </xsl:when>
  77. <xsl:otherwise>
  78. <xsl:value-of select ="$url"/>
  79. </xsl:otherwise>
  80. </xsl:choose>
  81. </xsl:variable>
  82. <!-- print out the content -->
  83. <xsl:choose>
  84. <!-- fill the navigation container if this is the task (navigation param = 1) -->
  85. <xsl:when test="$navigation = 1">
  86. <!-- create a link to the anchor in the content container -->
  87. <ol style="compact">
  88. <font size="normal"><a href="#{$anchorName}">
  89. <xsl:value-of select="name"/> (type: <xsl:value-of select="type"/>)
  90. </a></font>
  91. <!-- recursive call if there are subsections -->
  92. <xsl:if test="section">
  93. <xsl:for-each select="section">
  94. <xsl:call-template name="sectionTemplate">
  95. <xsl:with-param name="navigation" select="$navigation"/>
  96. <xsl:with-param name="anchorBase" select="concat($anchorName,'SubSec')"/>
  97. <xsl:with-param name="url" select="$repository"/>
  98. </xsl:call-template>
  99. </xsl:for-each>
  100. </xsl:if>
  101. </ol>
  102. </xsl:when>
  103. <!-- otherwise use template to display the content (navigation !=1) -->
  104. <xsl:otherwise>
  105. <a name="{$anchorName}"><h3> <xsl:value-of select="name"/> Section</h3></a>
  106. <p>
  107. <b>Type: </b><xsl:value-of select="type"/><br/>
  108. <xsl:choose>
  109. <xsl:when test ="repository">
  110. <b>Repository: </b><xsl:value-of select="repository"/><br/>
  111. </xsl:when>
  112. <xsl:otherwise>
  113. <b>Repository: </b><xsl:value-of select="$repository"/><br/>
  114. </xsl:otherwise>
  115. </xsl:choose>
  116. <b>Link: </b><xsl:if test="link"><xsl:value-of select="link"/></xsl:if><br/>
  117. <b>Include:</b> <xsl:if test="include"><font color="red"><xsl:value-of select="include"/></font></xsl:if><br/>
  118. <b>Definition: </b><xsl:if test="definition"><xsl:value-of select="definition"/></xsl:if><br/>
  119. </p>
  120. <!-- Check if there are any properties -->
  121. <xsl:if test="property">
  122. <table border="1" rules="rows" width="100%"><font size="-1">
  123. <tr bgcolor="#336699" align="left" valign="middle">
  124. <th><font size="+1" color="white"><b>Name</b></font></th>
  125. <th><font size="+1" color="white"><b>Value</b></font></th>
  126. <th><font size="+1" color="white"><b>Unit</b></font></th>
  127. <th><font size="+1" color="white"><b>Type</b></font></th>
  128. <th><font size="+1" color="white"><b>Definition</b></font></th>
  129. <th><font size="+1" color="white"><b>Dependency</b></font></th>
  130. <th><font size="+1" color="white"><b>Dependency Value</b></font></th>
  131. </tr>
  132. <xsl:for-each select="property">
  133. <xsl:variable name="anchor">
  134. <xsl:value-of select ="name"/>
  135. </xsl:variable>
  136. <tr>
  137. <td width="15%"><a name="{$anchor}"/>
  138. <p><xsl:value-of select="name"/></p>
  139. </td>
  140. <td width="10%"><p><xsl:value-of select="value"/></p></td>
  141. <td width="5%"><p><xsl:value-of select="unit"/><br/></p></td>
  142. <td width="5%"><p><xsl:value-of select="type"/></p></td>
  143. <td width="22.5%"><p><xsl:value-of select="definition"/></p></td>
  144. <td width="5%"><p><xsl:value-of select="dependency"/></p></td>
  145. <td width="5%"><p><xsl:value-of select="dependencyValue"/></p></td>
  146. </tr>
  147. </xsl:for-each></font>
  148. </table>
  149. </xsl:if>
  150. <a href="#top"><tiny>top</tiny></a>
  151. <hr style="background-color:#336699; height:1px; margin-right:0; text-align:right;"/>
  152. <!-- recursive call if there are subsections -->
  153. <xsl:if test="section">
  154. <xsl:for-each select="section">
  155. <xsl:call-template name="sectionTemplate">
  156. <xsl:with-param name="navigation" select="$navigation"/>
  157. <xsl:with-param name="anchorBase" select="concat($anchorName,'SubSec')"/>
  158. <xsl:with-param name="url" select="$repository"/>
  159. </xsl:call-template>
  160. </xsl:for-each>
  161. </xsl:if>
  162. </xsl:otherwise>
  163. </xsl:choose>
  164. </xsl:template>
  165. </xsl:stylesheet>