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