* Readonly document view.
[redakcja.git] / platforma / static / xsl / wl2html_client.xsl
index 3df7359..6dd5080 100644 (file)
     -->
     <xsl:template match="motto">
         <xsl:param name="mixed" />
+        <div class="motto_container">
         <div x-editable="true">
             <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
-            </xsl:apply-templates>
+            </xsl:apply-templates>            
+        </div>
+        <xsl:apply-templates select="following-sibling::*[1][self::motto_podpis]" mode="motto">
+            <xsl:with-param name="mixed" select="true()" />
+        </xsl:apply-templates>
         </div>
     </xsl:template>
 
-    <xsl:template match="motto_podpis">
+    <!--  
+        Catch stand-alone "motto_podpis" and make then render properly.
+        If not, editing will fail :(.
+        
+        TODO: Make "motto" & "motto_podpis" one block in edit mode (like strofa) 
+    -->
+    <xsl:template match="motto_podpis[not(preceding-sibling::*[1][self::motto])]">
+       <xsl:apply-templates select="." mode="motto">
+            <xsl:with-param name="mixed" select="true()" />
+        </xsl:apply-templates>
+    </xsl:template>        
+        
+    <xsl:template match="motto_podpis" mode="motto">
         <xsl:param name="mixed" />
         <p x-editable="true">
             <xsl:call-template name="standard-attributes" />
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
         </p>
-    </xsl:template>
+    </xsl:template>    
+    
+    <xsl:template match="motto_podpis" />
+    
+    
 
     <!--
         Tagi obejmujące listę osób poprzedzającą tekst dramatu
         <xsl:choose>
             <!-- Simple verse == not wers_ tags anywhere until the ending br -->
             <xsl:when test="not($verse-content[starts-with(name(), 'wers_')])">
-                <p class="wers" x-node="wers">
+                <p class="wers" x-node="wers" x-verse="true">
                 <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
                     <xsl:with-param name="mixed" select="true()" />
                 </xsl:apply-templates>
 
     <xsl:template match="wers_cd|wers_akap|wers_wciety">
         <xsl:param name="mixed" />
-        <p>
-            <xsl:call-template name="standard-attributes" />
-            <xsl:apply-templates select="child::node()">
-                <xsl:with-param name="mixed" select="true()" />
-            </xsl:apply-templates>
-        </p>
+               <!-- <xsl:choose>
+               <xsl:when test="ancestor::*[0]/self::strofa"> -->
+               <p x-verse="true">
+               <xsl:call-template name="standard-attributes" />
+               <xsl:apply-templates select="child::node()">
+                       <xsl:with-param name="mixed" select="true()" />
+               </xsl:apply-templates>
+               </p>
+               <!-- </xsl:when> 
+               <xsl:choose> -->
     </xsl:template>
 
     <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
         Przypisy i motywy
     -->
     <xsl:template match="pr|pa|pe|pt">       
-        <span x-editable="true">
+        <span x-editable="true" x-common="common">
             <xsl:call-template name="standard-attributes">
                 <xsl:with-param name="extra-class" select="'annotation-inline-box'" />
             </xsl:call-template>
             <!-- the link to the non-inline version -->
             <a href="#annotation-{generate-id(.)}" class="annotation"></a>
             <!-- inline contents -->
-            <span x-annotation-box="true">
+            <span x-annotation-box="true" x-pass-thru="true">
                 <xsl:call-template name="context-menu" />
                 <xsl:apply-templates select="node()">
                     <xsl:with-param name="mixed" select="true()" />
     </xsl:template>
 
     <xsl:template match="extra|uwaga">
-        <span>
+        <span x-common="common">
             <xsl:call-template name="standard-attributes" />
-            <xsl:apply-templates select="node()" />
+            <xsl:apply-templates select="child::node()">
+                <xsl:with-param name="mixed" select="true()" />
+            </xsl:apply-templates>
         </span>
     </xsl:template>
 
     <xsl:template match="motyw">
-        <span x-editable="true">
+        <span x-editable="true" x-common="common">
             <xsl:call-template name="standard-attributes" />
             <xsl:attribute name="theme-class">
                 <xsl:value-of select="substring-after(@id, 'm')" />
             </xsl:attribute>
             <xsl:call-template name="context-menu" />
-            <span class="theme-text-list"><xsl:value-of select=".|node()" /></span>
+            <span x-pass-thru="true" class="theme-text-list"><xsl:value-of select=".|node()" /></span>
         </span>
     </xsl:template>
 
     </xsl:template>
 
     <xsl:template match="*[name() != local-name()]">
-        <div>
+        <span>
             <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
-        </div>
+        </span>
     </xsl:template>
+       
+       <!-- 
+               Earlier versions of html2wl introduced a BUG, that 'causes "out-of-flow-text" tag to appear.
+               Instead of marking it as "unknown", just pass thru it
+       -->
+       <xsl:template match="out-of-flow-text">
+               <xsl:param name="mixed" />
+               <xsl:apply-templates select="child::node()">
+                <xsl:with-param name="mixed" select="$mixed" />
+            </xsl:apply-templates>
+       </xsl:template> 
 
     <xsl:template match="*">
-        <div class="unknown-tag" x-node="{name()}">
+        <span class="unknown-tag" x-node="{name()}">
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>        
-        </div>
+        </span>
     </xsl:template>
 
     <xsl:template name="context-menu">
             <xsl:variable name="id" select="generate-id()" />
             <xsl:attribute name="x-attr-value-{$id}"><xsl:value-of select="."/></xsl:attribute>
             <xsl:attribute name="x-attr-name-{$id}"><xsl:value-of select="local-name()"/></xsl:attribute>
-            <xsl:if test="namespace-uri()">
+            <xsl:choose>
+               <xsl:when test="namespace-uri()">
                 <xsl:attribute name="x-attr-ns-{$id}"><xsl:value-of select="namespace-uri()"/></xsl:attribute>
-            </xsl:if>               
+                               </xsl:when>
+                               <!-- if the element belongs to default namespace and attribut has no namespace -->
+               <xsl:when test="not(namespace-uri(.))">
+                               <xsl:attribute name="data-wlf-{local-name()}"><xsl:value-of select="."/></xsl:attribute>
+                               </xsl:when>
+                       </xsl:choose>               
         </xsl:for-each>
     </xsl:template>