annotations.xsl 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?xml version="1.0" encoding="ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML stylesheets.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
  5. <xsl:template name="add.annotation.links">
  6. <xsl:param name="scripts" select="normalize-space($annotation.js)"/>
  7. <xsl:choose>
  8. <xsl:when test="contains($scripts, ' ')">
  9. <script type="text/javascript" src="{substring-before($scripts, ' ')}"/>
  10. <xsl:call-template name="add.annotation.links">
  11. <xsl:with-param name="scripts" select="substring-after($scripts, ' ')"/>
  12. </xsl:call-template>
  13. </xsl:when>
  14. <xsl:otherwise>
  15. <script type="text/javascript" src="{$scripts}"/>
  16. </xsl:otherwise>
  17. </xsl:choose>
  18. </xsl:template>
  19. <xsl:template match="annotation"/>
  20. <xsl:template name="apply-annotations">
  21. <xsl:if test="$annotation.support != 0">
  22. <!-- do any annotations apply to the context node? -->
  23. <xsl:variable name="id" select="(@id|@xml:id)[1]"/>
  24. <xsl:variable name="aids">
  25. <xsl:for-each select="//annotation">
  26. <xsl:if test="@annotates=$id or starts-with(@annotates, concat($id, ' ')) or contains(@annotates, concat(' ', $id, ' ')) or substring(@annotates, string-length(@annotates)-3) = concat(' ', $id)">
  27. <xsl:value-of select="generate-id()"/>
  28. <xsl:text> </xsl:text>
  29. </xsl:if>
  30. </xsl:for-each>
  31. <xsl:if test="normalize-space(@annotations) != ''">
  32. <xsl:call-template name="annotations-pointed-to">
  33. <xsl:with-param name="annotations" select="normalize-space(@annotations)"/>
  34. </xsl:call-template>
  35. </xsl:if>
  36. </xsl:variable>
  37. <xsl:if test="$aids != ''">
  38. <xsl:call-template name="apply-annotations-by-gid">
  39. <xsl:with-param name="gids" select="normalize-space($aids)"/>
  40. </xsl:call-template>
  41. </xsl:if>
  42. </xsl:if>
  43. </xsl:template>
  44. <xsl:template name="annotations-pointed-to">
  45. <xsl:param name="annotations"/>
  46. <xsl:choose>
  47. <xsl:when test="contains($annotations, ' ')">
  48. <xsl:variable name="a" select="key('id', substring-before($annotations, ' '))"/>
  49. <xsl:if test="$a">
  50. <xsl:value-of select="generate-id($a)"/>
  51. <xsl:text> </xsl:text>
  52. </xsl:if>
  53. <xsl:call-template name="annotations-pointed-to">
  54. <xsl:with-param name="annotations" select="substring-after($annotations, ' ')"/>
  55. </xsl:call-template>
  56. </xsl:when>
  57. <xsl:otherwise>
  58. <xsl:variable name="a" select="key('id', $annotations)"/>
  59. <xsl:if test="$a">
  60. <xsl:value-of select="generate-id($a)"/>
  61. <xsl:text> </xsl:text>
  62. </xsl:if>
  63. </xsl:otherwise>
  64. </xsl:choose>
  65. </xsl:template>
  66. <xsl:template name="apply-annotations-by-gid">
  67. <xsl:param name="gids"/>
  68. <xsl:choose>
  69. <xsl:when test="contains($gids, ' ')">
  70. <xsl:variable name="gid" select="substring-before($gids, ' ')"/>
  71. <xsl:apply-templates select="key('gid', $gid)" mode="annotation-inline"/>
  72. <xsl:call-template name="apply-annotations-by-gid">
  73. <xsl:with-param name="gids" select="substring-after($gids, ' ')"/>
  74. </xsl:call-template>
  75. </xsl:when>
  76. <xsl:otherwise>
  77. <xsl:apply-templates select="key('gid', $gids)" mode="annotation-inline"/>
  78. </xsl:otherwise>
  79. </xsl:choose>
  80. </xsl:template>
  81. <xsl:template match="annotation" mode="annotation-inline">
  82. <xsl:variable name="title">
  83. <xsl:choose>
  84. <xsl:when test="title">
  85. <xsl:value-of select="title"/>
  86. </xsl:when>
  87. <xsl:otherwise>
  88. <xsl:text>[Annotation #</xsl:text>
  89. <xsl:number count="annotation" level="any" format="1"/>
  90. <xsl:text>]</xsl:text>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. </xsl:variable>
  94. <a id="anch-{generate-id(.)}" href="#annot-{generate-id(.)}" title="{$title}">
  95. <xsl:apply-templates select="." mode="class.attribute"/>
  96. <xsl:attribute name="onClick">
  97. <xsl:text>popup_</xsl:text>
  98. <xsl:value-of select="generate-id(.)"/>
  99. <xsl:text>.showPopup('anch-</xsl:text>
  100. <xsl:value-of select="generate-id(.)"/>
  101. <xsl:text>'); return false;</xsl:text>
  102. </xsl:attribute>
  103. <img src="{$annotation.graphic.open}" border="0" alt="{$title}"/>
  104. </a>
  105. </xsl:template>
  106. <xsl:template match="annotation" mode="annotation-popup">
  107. <div class="annotation-nocss">
  108. <p>
  109. <a id="annot-{generate-id(.)}"/>
  110. <xsl:text>Annotation #</xsl:text>
  111. <xsl:number count="annotation" level="any" format="1"/>
  112. <xsl:text>:</xsl:text>
  113. </p>
  114. </div>
  115. <div id="popup-{generate-id(.)}" class="annotation-popup">
  116. <xsl:if test="string-length(.) &gt; 300">
  117. <xsl:attribute name="style">width:400px</xsl:attribute>
  118. </xsl:if>
  119. <xsl:call-template name="annotation-title"/>
  120. <div class="annotation-body">
  121. <xsl:apply-templates select="*[local-name(.) != 'title']"/>
  122. </div>
  123. <div class="annotation-close">
  124. <a href="#" onclick="popup_{generate-id(.)}.hidePopup();return false;">
  125. <xsl:apply-templates select="." mode="class.attribute"/>
  126. <img src="{$annotation.graphic.close}" alt="X" border="0"/>
  127. </a>
  128. </div>
  129. </div>
  130. </xsl:template>
  131. <xsl:template name="annotation-title">
  132. <div class="annotation-title">
  133. <xsl:choose>
  134. <xsl:when test="title">
  135. <xsl:apply-templates select="title/node()"/>
  136. </xsl:when>
  137. <xsl:otherwise>
  138. <xsl:text>Annotation</xsl:text>
  139. </xsl:otherwise>
  140. </xsl:choose>
  141. </div>
  142. </xsl:template>
  143. </xsl:stylesheet>