yet another fix for slowo_obce + refactor
authorJan Szejko <janek37@gmail.com>
Fri, 7 Sep 2018 10:31:49 +0000 (12:31 +0200)
committerJan Szejko <janek37@gmail.com>
Fri, 7 Sep 2018 10:31:49 +0000 (12:31 +0200)
librarian/pdf/wl2tex.xslt

index a61842e..58d2d81 100644 (file)
     <cmd name="nazwapodutworu">
         <parm><xsl:apply-templates mode="inline"/></parm>
         <parm>
-            <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
-                <xsl:choose>
-                    <xsl:when test="name() = 'nbsp'">
-                        <xsl:text> </xsl:text>
-                    </xsl:when>
-                    <xsl:when test="name() = 'dywiz'">
-                        <xsl:text>-</xsl:text>
-                    </xsl:when>
-                    <xsl:when test="name() = 'alien' or name() = 'slowo_obce'">
-                        <xsl:apply-templates mode="inline" />
-                    </xsl:when>
-                    <xsl:otherwise>
-                        <xsl:value-of select="."/>
-                    </xsl:otherwise>
-                </xsl:choose>
-            </xsl:for-each>
+            <xsl:call-template name="strip-for-toc" />
         </parm>
     </cmd>
 </xsl:template>
         </xsl:attribute>
         <parm><xsl:apply-templates mode="inline"/></parm>
         <parm>
-            <!-- osobny szablon? -->
-            <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
-                <xsl:choose>
-                    <xsl:when test="name() = 'nbsp'">
-                        <xsl:text> </xsl:text>
-                    </xsl:when>
-                    <xsl:when test="name() = 'dywiz'">
-                        <xsl:text>-</xsl:text>
-                    </xsl:when>
-                    <xsl:when test="name() = 'alien'">
-                        <xsl:apply-templates mode="inline" />
-                    </xsl:when>
-                    <xsl:when test="name() = 'slowo_obce'">
-                        <cmd name="slowoobce">
-                            <parm><xsl:value-of select="text()"/></parm>
-                        </cmd>
-                    </xsl:when>
-                    <xsl:otherwise>
-                        <xsl:value-of select="."/>
-                    </xsl:otherwise>
-                </xsl:choose>
-            </xsl:for-each>
+            <xsl:call-template name="strip-for-toc" />
         </parm>
     </cmd>
 </xsl:template>
     </xsl:if>
 </xsl:template>
 
+<xsl:template name="strip-for-toc">
+    <xsl:for-each select="./text() | nbsp | dywiz | alien | slowo_obce">
+        <xsl:choose>
+            <xsl:when test="name() = 'nbsp'">
+                <xsl:text> </xsl:text>
+            </xsl:when>
+            <xsl:when test="name() = 'dywiz'">
+                <xsl:text>-</xsl:text>
+            </xsl:when>
+            <xsl:when test="name() = 'alien'">
+                <xsl:apply-templates mode="inline" />
+            </xsl:when>
+            <xsl:when test="name() = 'slowo_obce'">
+                <xsl:call-template name="strip-for-toc" />
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="."/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:for-each>
+</xsl:template>
+
 <xsl:template match="data-sponsor" mode="sponsor">
     <cmd name="par"><parm>
     <xsl:choose>