Project

General

Profile

1
<?xml version='1.0'?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
                version='1.0'>
4

    
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

    
20
<xsl:template match="annotation"/>
21

    
22
<xsl:template name="apply-annotations">
23
  <xsl:if test="$annotation.support != 0">
24
  <!-- do any annotations apply to the context node? -->
25
  <xsl:variable name="id" select="(@id|@xml:id)[1]"/>
26

    
27
  <xsl:variable name="aids">
28
    <xsl:for-each select="//annotation">
29
      <xsl:if test="@annotates=$id
30
                    or starts-with(@annotates, concat($id, ' '))
31
                    or contains(@annotates, concat(' ', $id, ' '))
32
                    or substring(@annotates, string-length(@annotates)-3)
33
                       = concat(' ', $id)">
34
        <xsl:value-of select="generate-id()"/>
35
        <xsl:text> </xsl:text>
36
      </xsl:if>
37
    </xsl:for-each>
38
    <xsl:if test="normalize-space(@annotations) != ''">
39
      <xsl:call-template name="annotations-pointed-to">
40
        <xsl:with-param name="annotations"
41
                        select="normalize-space(@annotations)"/>
42
      </xsl:call-template>
43
    </xsl:if>
44
  </xsl:variable>
45

    
46
  <xsl:if test="$aids != ''">
47
    <xsl:call-template name="apply-annotations-by-gid">
48
      <xsl:with-param name="gids" select="normalize-space($aids)"/>
49
    </xsl:call-template>
50
  </xsl:if>
51
  </xsl:if>
52
</xsl:template>
53

    
54
<xsl:template name="annotations-pointed-to">
55
  <xsl:param name="annotations"/>
56
  <xsl:choose>
57
    <xsl:when test="contains($annotations, ' ')">
58
      <xsl:variable name='a'
59
                    select="key('id', substring-before($annotations, ' '))"/>
60
      <xsl:if test="$a">
61
        <xsl:value-of select="generate-id($a)"/>
62
        <xsl:text> </xsl:text>
63
      </xsl:if>
64
      <xsl:call-template name="annotations-pointed-to">
65
        <xsl:with-param name="annotations"
66
                        select="substring-after($annotations, ' ')"/>
67
      </xsl:call-template>
68
    </xsl:when>
69
    <xsl:otherwise>
70
      <xsl:variable name='a'
71
                    select="key('id', $annotations)"/>
72
      <xsl:if test="$a">
73
        <xsl:value-of select="generate-id($a)"/>
74
        <xsl:text> </xsl:text>
75
      </xsl:if>
76
    </xsl:otherwise>
77
  </xsl:choose>
78
</xsl:template>
79

    
80
<xsl:template name="apply-annotations-by-gid">
81
  <xsl:param name="gids"/>
82

    
83
  <xsl:choose>
84
    <xsl:when test="contains($gids, ' ')">
85
      <xsl:variable name="gid" select="substring-before($gids, ' ')"/>
86
      <xsl:apply-templates select="key('gid', $gid)"
87
                           mode="annotation-inline"/>
88
      <xsl:call-template name="apply-annotations-by-gid">
89
        <xsl:with-param name="gids"
90
                        select="substring-after($gids, ' ')"/>
91
      </xsl:call-template>
92
    </xsl:when>
93
    <xsl:otherwise>
94
      <xsl:apply-templates select="key('gid', $gids)"
95
                           mode="annotation-inline"/>
96
    </xsl:otherwise>
97
  </xsl:choose>
98
</xsl:template>
99

    
100
<xsl:template match="annotation" mode="annotation-inline">
101
  <xsl:variable name="title">
102
    <xsl:choose>
103
      <xsl:when test="title">
104
        <xsl:value-of select="title"/>
105
      </xsl:when>
106
      <xsl:otherwise>
107
        <xsl:text>[Annotation #</xsl:text>
108
        <xsl:number count="annotation" level="any" format="1"/>
109
        <xsl:text>]</xsl:text>
110
      </xsl:otherwise>
111
    </xsl:choose>
112
  </xsl:variable>
113

    
114
  <a href="#annot-{generate-id(.)}" title="{$title}"
115
     name="anch-{generate-id(.)}" id="anch-{generate-id(.)}">
116
    <xsl:apply-templates select="." mode="class.attribute"/>
117
    <xsl:attribute name="onClick">
118
      <xsl:text>popup_</xsl:text>
119
      <xsl:value-of select="generate-id(.)"/>
120
      <xsl:text>.showPopup('anch-</xsl:text>
121
      <xsl:value-of select="generate-id(.)"/>
122
      <xsl:text>'); return false;</xsl:text>
123
    </xsl:attribute>
124
    <img src="{$annotation.graphic.open}" border="0" alt="{$title}"/>
125
  </a>
126
</xsl:template>
127

    
128
<xsl:template match="annotation" mode="annotation-popup">
129
  <div class="annotation-nocss">
130
    <p>
131
      <a name="annot-{generate-id(.)}"/>
132
      <xsl:text>Annotation #</xsl:text>
133
      <xsl:number count="annotation" level="any" format="1"/>
134
      <xsl:text>:</xsl:text>
135
    </p>
136
  </div>
137

    
138
  <div id="popup-{generate-id(.)}" class="annotation-popup">
139
    <xsl:if test="string-length(.) &gt; 300">
140
      <xsl:attribute name="style">width:400px</xsl:attribute>
141
    </xsl:if>
142

    
143
    <xsl:call-template name="annotation-title"/>
144
    <div class="annotation-body">
145
      <xsl:apply-templates select="*[local-name(.) != 'title']"/>
146
    </div>
147
    <div class="annotation-close">
148
      <a href="#" onclick="popup_{generate-id(.)}.hidePopup();return false;">
149
        <xsl:apply-templates select="." mode="class.attribute"/>
150
        <img src="{$annotation.graphic.close}" alt="X" border="0"/>
151
      </a>
152
    </div>
153
  </div>
154
</xsl:template>
155

    
156
<xsl:template name="annotation-title">
157
  <div class="annotation-title">
158
    <xsl:choose>
159
      <xsl:when test="title">
160
        <xsl:apply-templates select="title/node()"/>
161
      </xsl:when>
162
      <xsl:otherwise>
163
        <xsl:text>Annotation</xsl:text>
164
      </xsl:otherwise>
165
    </xsl:choose>
166
  </div>
167
</xsl:template>
168

    
169
</xsl:stylesheet>
(2-2/39)