1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"
3 xmlns="http://www.w3.org/1999/xhtml"
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5 <xsl:output method="html" omit-xml-declaration="yes" encoding="utf-8" indent="no" />
8 Base tag for rendering a fragment of text
10 <xsl:template match="chunk">
11 <xsl:apply-templates select="child::node()">
12 <xsl:with-param name="mixed" select="true()" />
13 </xsl:apply-templates>
16 <xsl:template match="utwor">
18 <xsl:call-template name="standard-attributes" />
19 <xsl:apply-templates select="child::node()">
20 <xsl:with-param name="mixed" select="false()" />
21 </xsl:apply-templates>
26 <!-- nieedytowany - zawiera bloki section-->
27 <xsl:template match="{{ tags.section|join:"|" }}">
28 <xsl:param name="mixed" />
30 <xsl:call-template name="standard-attributes" />
31 <xsl:apply-templates select="child::node()">
32 <xsl:with-param name="mixed" select="false()" />
33 </xsl:apply-templates>
37 <!-- edytowalny - zawiera tekst div -->
38 <xsl:template match="{{ tags.div|join:"|" }}">
39 <xsl:param name="mixed" />
40 <div x-editable="true">
41 <xsl:call-template name="standard-attributes" />
42 <xsl:apply-templates select="child::node()">
43 <xsl:with-param name="mixed" select="true()" />
44 </xsl:apply-templates>
48 <xsl:template match="ilustr">
50 <xsl:call-template name="standard-attributes" />
52 <xsl:attribute name="src">
53 <xsl:value-of select="@src" />
56 <p class="alt"><xsl:value-of select="@alt"/></p>
65 <xsl:template match="strofa">
66 <div x-editable="true">
67 <xsl:call-template name="standard-attributes" />
70 <xsl:when test="count(br) > 0">
71 <xsl:variable name="first-verse" select="br[1]/preceding-sibling::node()" />
72 <xsl:call-template name="verse">
73 <xsl:with-param name="verse-content" select="$first-verse" />
75 <xsl:for-each select="br">
76 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
77 <!-- select all nodes up to the next br or end of stanza -->
78 <xsl:variable name="current-verse"
79 select="following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
80 <xsl:call-template name="verse">
81 <xsl:with-param name="verse-content" select="$current-verse" />
86 <xsl:call-template name="verse">
87 <xsl:with-param name="verse-content" select="child::node()" />
94 <xsl:template name="verse">
95 <!-- the verse contents including the last br (if any) -->
96 <xsl:param name="verse-content" />
97 <xsl:variable name="first-tag-name" select="name($verse-content/self::*)" />
98 <!-- name of text nodes is '' == false -->
100 <!-- THIS IS A HORROR!!! -->
101 <!-- Possible variants: -->
103 <!-- Simple verse == not wers_ tags anywhere until the ending br -->
104 <xsl:when test="not($verse-content[starts-with(name(), 'wers')])">
105 <div class="wers" x-node="wers" x-verse="true" x-auto-node="true">
106 <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
107 <xsl:with-param name="mixed" select="true()" />
108 </xsl:apply-templates>
113 <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
114 <xsl:with-param name="mixed" select="false()" />
115 </xsl:apply-templates>
121 <xsl:template match="{{ tags.verse|join:"|" }}">
122 <xsl:param name="mixed" />
124 <xsl:call-template name="standard-attributes" />
125 <xsl:apply-templates select="child::node()">
126 <xsl:with-param name="mixed" select="true()" />
127 </xsl:apply-templates>
132 <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
135 <!-- Style znakowe span -->
136 <xsl:template match="{{ tags.span|join:"|" }}">
137 <xsl:param name="mixed" />
139 <xsl:call-template name="standard-attributes" />
140 <xsl:apply-templates select="child::node()">
141 <xsl:with-param name="mixed" select="true()" />
142 </xsl:apply-templates>
148 <!-- Separatory sep -->
149 <xsl:template match="{{ tags.sep|join:"|" }}">
150 <xsl:param name="mixed" />
151 <hr><xsl:call-template name="standard-attributes" /></hr>
156 <!-- Przypisy i motywy aside -->
157 <xsl:template match="{{ tags.aside|join:"|" }}">
158 <span x-editable="true">
159 <xsl:call-template name="standard-attributes">
160 <xsl:with-param name="extra-class" select="'annotation-inline-box'" />
162 <a name="anchor-{generate-id(.)}" />
163 <!-- the link to the non-inline version -->
164 <a href="#annotation-{generate-id(.)}" class="annotation"></a>
165 <!-- inline contents -->
166 <span x-annotation-box="true" x-pass-thru="true">
167 <xsl:apply-templates select="node()">
168 <xsl:with-param name="mixed" select="true()" />
169 </xsl:apply-templates>
175 <xsl:template match="ref">
176 <span x-editable="true" x-edit-no-format="true" x-edit-attribute="href">
177 <xsl:call-template name="standard-attributes">
178 <xsl:with-param name="extra-class" select="'reference-inline-box'" />
180 <a class="reference">📌</a>
184 <xsl:template match="begin">
186 <xsl:call-template name="standard-attributes" />
187 <xsl:attribute name="theme-class">
188 <xsl:value-of select="substring-after(@id, 'b')" />
193 <xsl:template match="motyw">
194 <span x-editable="true" x-edit-no-format="true">
195 <xsl:call-template name="standard-attributes" />
196 <xsl:attribute name="theme-class">
197 <xsl:value-of select="substring-after(@id, 'm')" />
199 <span x-pass-thru="true" class="theme-text-list"><xsl:value-of select=".|node()" /></span>
203 <xsl:template match="end">
205 <xsl:call-template name="standard-attributes" />
206 <xsl:attribute name="theme-class">
207 <xsl:value-of select="substring-after(@id, 'e')" />
214 <xsl:template match="text()">
215 <!-- <xsl:value-of select="." /> -->
216 <xsl:param name="mixed" />
218 <xsl:when test="normalize-space(.) = ''">
219 <xsl:value-of select="." />
221 <xsl:when test="not($mixed)">
222 <span x-node="out-of-flow-text" class="out-of-flow-text" x-editable="true">
223 <xsl:value-of select="." />
226 <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
230 <xsl:template match="comment()">
231 <xsl:comment><xsl:value-of select="." /></xsl:comment>
234 <xsl:template match="*[name() != local-name()]">
236 <xsl:call-template name="standard-attributes" />
237 <xsl:apply-templates select="child::node()">
238 <xsl:with-param name="mixed" select="true()" />
239 </xsl:apply-templates>
243 <xsl:template match="*">
245 <xsl:call-template name="standard-attributes">
246 <xsl:with-param name="extra-class">unknown-tag</xsl:with-param>
248 <xsl:apply-templates select="child::node()">
249 <xsl:with-param name="mixed" select="true()" />
250 </xsl:apply-templates>
254 <xsl:template name="standard-attributes">
255 <xsl:param name="extra-class" />
256 <xsl:attribute name="class"><xsl:value-of select="$extra-class" /></xsl:attribute>
258 <xsl:attribute name="x-node"><xsl:value-of select="local-name()" /></xsl:attribute>
260 <xsl:if test="local-name() != name()">
261 <xsl:attribute name="x-ns"><xsl:value-of select="namespace-uri()" /></xsl:attribute>
264 <xsl:for-each select="@*">
265 <xsl:variable name="id" select="generate-id()" />
266 <xsl:attribute name="x-attr-value-{$id}"><xsl:value-of select="."/></xsl:attribute>
267 <xsl:attribute name="x-attr-name-{$id}"><xsl:value-of select="local-name()"/></xsl:attribute>
269 <xsl:when test="namespace-uri()">
270 <xsl:attribute name="x-attr-ns-{$id}"><xsl:value-of select="namespace-uri()"/></xsl:attribute>
272 <!-- if the element belongs to default namespace and attribut has no namespace -->
273 <xsl:when test="not(namespace-uri(.))">
274 <xsl:attribute name="data-wlf-{local-name()}"><xsl:value-of select="."/></xsl:attribute>
280 <xsl:template match="alien">
281 <span class="alien" x-pass-thru="true">
282 <xsl:apply-templates select="node()">
283 <xsl:with-param name="mixed" select="true()" />
284 </xsl:apply-templates>
288 <xsl:template match="comment()">
289 <xsl:comment><xsl:value-of select="."/></xsl:comment>