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>
 
  60     <xsl:template match="numeracja">
 
  62         <xsl:call-template name="standard-attributes" />
 
  64           <xsl:attribute name="data-start">
 
  65             <xsl:value-of select="@start" />
 
  67           <xsl:attribute name="data-link">
 
  68             <xsl:value-of select="@link" />
 
  79     <xsl:template match="strofa">
 
  80         <div x-editable="true">
 
  81             <xsl:call-template name="standard-attributes" />
 
  84                 <xsl:when test="count(br) > 0">
 
  85                     <xsl:variable name="first-verse" select="br[1]/preceding-sibling::node()" />                    
 
  86                     <xsl:call-template name="verse">
 
  87                         <xsl:with-param name="verse-content" select="$first-verse" />                        
 
  89                     <xsl:for-each select="br">
 
  90                         <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
 
  91                         <!-- select all nodes up to the next br or end of stanza -->
 
  92                         <xsl:variable name="current-verse"
 
  93                             select="following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />                        
 
  94                         <xsl:call-template name="verse">
 
  95                             <xsl:with-param name="verse-content" select="$current-verse" />                            
 
 100                     <xsl:call-template name="verse">
 
 101                         <xsl:with-param name="verse-content" select="child::node()" />                        
 
 108     <xsl:template name="verse">
 
 109         <!-- the verse contents including the last br (if any) -->
 
 110         <xsl:param name="verse-content" />
 
 111         <xsl:variable name="first-tag-name" select="name($verse-content/self::*)" />
 
 112         <!-- name of text nodes is '' == false -->
 
 114         <!-- THIS IS A HORROR!!! -->
 
 115         <!-- Possible variants: -->
 
 117             <!-- Simple verse == not wers_ tags anywhere until the ending br -->
 
 118             <xsl:when test="not($verse-content[starts-with(name(), 'wers')])">
 
 119                 <div class="wers" x-node="wers" x-verse="true" x-auto-node="true">
 
 120                 <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
 
 121                     <xsl:with-param name="mixed" select="true()" />
 
 122                 </xsl:apply-templates>
 
 127             <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
 
 128                 <xsl:with-param name="mixed" select="false()" />
 
 129             </xsl:apply-templates>
 
 135     <xsl:template match="{{ tags.verse|join:"|" }}">
 
 136         <xsl:param name="mixed" />
 
 138                 <xsl:call-template name="standard-attributes" />
 
 139                 <xsl:apply-templates select="child::node()">
 
 140                         <xsl:with-param name="mixed" select="true()" />
 
 141                 </xsl:apply-templates>
 
 146     <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
 
 149     <!-- Style znakowe         span -->
 
 150     <xsl:template match="{{ tags.span|join:"|" }}">
 
 151         <xsl:param name="mixed" />
 
 153             <xsl:call-template name="standard-attributes" />
 
 154             <xsl:apply-templates select="child::node()">
 
 155                 <xsl:with-param name="mixed" select="true()" />
 
 156             </xsl:apply-templates>
 
 162     <!-- Separatory            sep -->
 
 163     <xsl:template match="{{ tags.sep|join:"|" }}">
 
 164         <xsl:param name="mixed" />
 
 165         <hr><xsl:call-template name="standard-attributes" /></hr>
 
 170     <!-- Przypisy i motywy     aside -->
 
 171     <xsl:template match="{{ tags.aside|join:"|" }}">
 
 172         <span x-editable="true">
 
 173             <xsl:call-template name="standard-attributes">
 
 174                 <xsl:with-param name="extra-class" select="'annotation-inline-box'" />
 
 176             <a name="anchor-{generate-id(.)}" />
 
 177             <!-- the link to the non-inline version -->
 
 178             <a href="#annotation-{generate-id(.)}" class="annotation"></a>
 
 179             <!-- inline contents -->
 
 180             <span x-annotation-box="true" x-pass-thru="true">
 
 181                 <xsl:apply-templates select="node()">
 
 182                     <xsl:with-param name="mixed" select="true()" />
 
 183                 </xsl:apply-templates>
 
 189     <xsl:template match="ref">
 
 190       <span x-editable="true" x-edit-no-format="true" x-edit-attribute="href">
 
 191         <xsl:call-template name="standard-attributes">
 
 192           <xsl:with-param name="extra-class" select="'reference-inline-box'" />
 
 194         <a class="reference">📌</a>
 
 195         <span x-preview="true" x-pass-thru="true">
 
 196           <a target="wiki" title="?">
 
 197             <xsl:attribute name="href">
 
 198               <xsl:value-of select="@href" />
 
 200             <xsl:value-of select="@href" />
 
 206     <xsl:template match="begin">        
 
 208             <xsl:call-template name="standard-attributes" />
 
 209             <xsl:attribute name="theme-class">
 
 210                 <xsl:value-of select="substring-after(@id, 'b')" />
 
 215     <xsl:template match="motyw">
 
 216         <span x-editable="true" x-edit-no-format="true">
 
 217             <xsl:call-template name="standard-attributes" />
 
 218             <xsl:attribute name="theme-class">
 
 219                 <xsl:value-of select="substring-after(@id, 'm')" />
 
 221             <span x-pass-thru="true" class="theme-text-list"><xsl:value-of select=".|node()" /></span>
 
 225     <xsl:template match="end">
 
 227             <xsl:call-template name="standard-attributes" />
 
 228             <xsl:attribute name="theme-class">
 
 229                 <xsl:value-of select="substring-after(@id, 'e')" />
 
 236     <xsl:template match="text()">
 
 237       <!-- <xsl:value-of select="." /> -->
 
 238       <xsl:param name="mixed" />
 
 240         <xsl:when test="normalize-space(.) = ''">
 
 241           <xsl:value-of select="." />
 
 243         <xsl:when test="not($mixed)">
 
 244           <span x-node="out-of-flow-text" class="out-of-flow-text" x-editable="true">
 
 245             <xsl:value-of select="." />
 
 248         <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
 
 252     <xsl:template match="comment()">
 
 253         <xsl:comment><xsl:value-of select="." /></xsl:comment>
 
 256     <xsl:template match="*[name() != local-name()]">
 
 258             <xsl:call-template name="standard-attributes" />
 
 259             <xsl:apply-templates select="child::node()">
 
 260                 <xsl:with-param name="mixed" select="true()" />
 
 261             </xsl:apply-templates>
 
 265     <xsl:template match="*">
 
 267             <xsl:call-template name="standard-attributes">
 
 268                 <xsl:with-param name="extra-class">unknown-tag</xsl:with-param>
 
 270             <xsl:apply-templates select="child::node()">
 
 271                 <xsl:with-param name="mixed" select="true()" />
 
 272             </xsl:apply-templates>        
 
 276     <xsl:template name="standard-attributes">
 
 277         <xsl:param name="extra-class" />
 
 278         <xsl:attribute name="class"><xsl:value-of select="$extra-class" /></xsl:attribute>
 
 280         <xsl:attribute name="x-node"><xsl:value-of select="local-name()" /></xsl:attribute>
 
 282         <xsl:if test="local-name() != name()">
 
 283             <xsl:attribute name="x-ns"><xsl:value-of select="namespace-uri()" /></xsl:attribute>
 
 286         <xsl:for-each select="@*">
 
 289             {% for namespace, prefix in namespaces.items %}
 
 290             <xsl:when test="namespace-uri() =  '{{ namespace }}'">
 
 291               <xsl:attribute name="x-a-{{ prefix }}-{local-name()}">
 
 292                 <xsl:value-of select="."/>
 
 298               <xsl:variable name="id" select="generate-id()" />
 
 299               <xsl:attribute name="x-attr-value-{$id}"><xsl:value-of select="."/></xsl:attribute>
 
 300               <xsl:attribute name="x-attr-name-{$id}"><xsl:value-of select="local-name()"/></xsl:attribute>
 
 301               <xsl:attribute name="x-attr-ns-{$id}"><xsl:value-of select="namespace-uri()"/></xsl:attribute>
 
 308     <xsl:template match="alien">
 
 309             <span class="alien" x-pass-thru="true">
 
 310                 <xsl:apply-templates select="node()">
 
 311                     <xsl:with-param name="mixed" select="true()" />
 
 312                 </xsl:apply-templates>
 
 316     <xsl:template match="comment()">
 
 317         <xsl:comment><xsl:value-of select="."/></xsl:comment>