]> Lady’s Gitweb - Shrine-XSLT/blobdiff - transform.xslt
Copy over data files from sources/
[Shrine-XSLT] / transform.xslt
index 0bd34a83758041a036fc0fca43a89aa7435197c5..0919121f56192ea1934cd58726d8f19c7db478df 100644 (file)
@@ -23,8 +23,6 @@ This Source Code Form is subject to the terms of the Mozilla Public License, v.
 If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
 -->
 <xslt:transform
 If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
 -->
 <xslt:transform
-       xmlns="http://www.w3.org/1999/xhtml"
-       xmlns:exslt="http://exslt.org/common"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
        version="1.0"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
        version="1.0"
@@ -36,15 +34,16 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h
                Instead of actually processing the root node, process the template in `template` mode.
        -->
        <xslt:template match="/">
                Instead of actually processing the root node, process the template in `template` mode.
        -->
        <xslt:template match="/">
-               <xslt:apply-templates select="exslt:node-set($template)" mode="template"/>
+               <xslt:apply-templates select="$template" mode="template"/>
        </xslt:template>
 
        <!--
                Process non‐template elements.
                By default, just copy the element, but remove any `@data-shrine-*` attribuets or `@slot` attributes with a value that begins with `shrine-`.
        </xslt:template>
 
        <!--
                Process non‐template elements.
                By default, just copy the element, but remove any `@data-shrine-*` attribuets or `@slot` attributes with a value that begins with `shrine-`.
+               Some elements may have special treatment.
        -->
        -->
-       <xslt:template match="*|text()" mode="content">
-               <xslt:copy>
+       <xslt:template match="*" mode="content">
+               <xslt:element name="{local-name()}">
                        <xslt:for-each select="@*[not(starts-with(name(), 'data-shrine-')) and not(name()='slot' and starts-with(., 'shrine-'))]">
                                <xslt:copy/>
                        </xslt:for-each>
                        <xslt:for-each select="@*[not(starts-with(name(), 'data-shrine-')) and not(name()='slot' and starts-with(., 'shrine-'))]">
                                <xslt:copy/>
                        </xslt:for-each>
@@ -60,7 +59,14 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h
                                        </xslt:otherwise>
                                </xslt:choose>
                        </xslt:for-each>
                                        </xslt:otherwise>
                                </xslt:choose>
                        </xslt:for-each>
-               </xslt:copy>
+               </xslt:element>
+       </xslt:template>
+
+       <!--
+               Process text content; just make a copy.
+       -->
+       <xslt:template match="text()" mode="content">
+               <xslt:copy/>
        </xslt:template>
 
        <!--
        </xslt:template>
 
        <!--
@@ -68,54 +74,59 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h
                By default, just copy the element.
                This behaviour will be overridden for certain elements to insert the page content.
        -->
                By default, just copy the element.
                This behaviour will be overridden for certain elements to insert the page content.
        -->
-       <xslt:template match="*|text()" mode="template">
-               <xslt:copy>
+       <xslt:template match="*" mode="template">
+               <xslt:element name="{local-name()}">
                        <xslt:for-each select="@*">
                                <xslt:copy/>
                        </xslt:for-each>
                        <xslt:apply-templates mode="template"/>
                        <xslt:for-each select="@*">
                                <xslt:copy/>
                        </xslt:for-each>
                        <xslt:apply-templates mode="template"/>
-               </xslt:copy>
+               </xslt:element>
+       </xslt:template>
+
+       <!--
+               Process template text; just make a copy.
+       -->
+       <xslt:template match="text()" mode="content">
+               <xslt:copy/>
        </xslt:template>
 
        <!--
        </xslt:template>
 
        <!--
-               Process the template `<html>`.
+               Process the template `<html>` elements.
                This copies over `@lang` and non‐shrine `@data-*` attributes from the root node.
        -->
        <xslt:template match="html:html" mode="template">
                This copies over `@lang` and non‐shrine `@data-*` attributes from the root node.
        -->
        <xslt:template match="html:html" mode="template">
-               <xslt:copy>
-                       <xslt:for-each select="@*">
+               <html>
+                       <xslt:for-each select="@*[not(starts-with(name(), 'xmlns'))]">
                                <xslt:copy/>
                        </xslt:for-each>
                                <xslt:copy/>
                        </xslt:for-each>
-                       <xslt:for-each select="exslt:node-set($source)/*/@*[name()='lang' or name()='xml:lang' or starts-with(name(), 'data-') and not(starts-with(name(), 'data-shrine-'))]">
-                               <xslt:if test="not(exslt:node-set($template)/*/@*[name()=name(current())])">
+                       <xslt:for-each select="$source/*/@*[name()='lang' or starts-with(name(), 'data-') and not(starts-with(name(), 'data-shrine-'))]">
+                               <xslt:if test="not($template/*/@*[name()=name(current())])">
                                        <xslt:copy/>
                                </xslt:if>
                        </xslt:for-each>
                        <xslt:apply-templates mode="template"/>
                                        <xslt:copy/>
                                </xslt:if>
                        </xslt:for-each>
                        <xslt:apply-templates mode="template"/>
-               </xslt:copy>
+               </html>
        </xslt:template>
 
        <!--
        </xslt:template>
 
        <!--
-               Process the template `<head>`.
+               Process the template `<head>` elements.
                This inserts appropriate metadata based on the document.
        -->
        <xslt:template match="html:head" mode="template">
                This inserts appropriate metadata based on the document.
        -->
        <xslt:template match="html:head" mode="template">
-               <xslt:copy>
+               <head>
                        <xslt:for-each select="@*">
                                <xslt:copy/>
                        </xslt:for-each>
                        <xslt:for-each select="@*">
                                <xslt:copy/>
                        </xslt:for-each>
-                       <xslt:for-each select="exslt:node-set($source)//*[@slot='shrine-head']">
-                               <xslt:text>&#x0A;</xslt:text>
-                               <xslt:apply-templates select="." mode="content"/>
-                       </xslt:for-each>
-                       <xslt:if test="not(exslt:node-set($source)//html:title[@slot='shrine-head'])">
-                               <xslt:text>&#x0A;</xslt:text>
+                       <xslt:if test="not($source//html:title[@slot='shrine-head'])">
                                <title>
                                <title>
-                                       <xslt:apply-templates select="exslt:node-set($source)//html:h1" mode="text"/>
+                                       <xslt:apply-templates select="$source//html:h1" mode="text"/>
                                </title>
                        </xslt:if>
                        <xslt:apply-templates mode="template"/>
                                </title>
                        </xslt:if>
                        <xslt:apply-templates mode="template"/>
-               </xslt:copy>
+                       <xslt:for-each select="$source//*[@slot='shrine-head']">
+                               <xslt:apply-templates select="." mode="content"/>
+                       </xslt:for-each>
+               </head>
        </xslt:template>
 
        <!--
        </xslt:template>
 
        <!--
@@ -124,7 +135,7 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h
                If no `@data-header` attribute is provided, no header is rendered.
        -->
        <xslt:template match="html:shrine-header" mode="template">
                If no `@data-header` attribute is provided, no header is rendered.
        -->
        <xslt:template match="html:shrine-header" mode="template">
-               <xslt:for-each select="exslt:node-set($source)/*/@data-shrine-header">
+               <xslt:for-each select="$source/*/@data-shrine-header">
                        <xslt:apply-templates select="document(concat('./', ., '-header.xml'), $template)/*" mode="content"/>
                </xslt:for-each>
        </xslt:template>
                        <xslt:apply-templates select="document(concat('./', ., '-header.xml'), $template)/*" mode="content"/>
                </xslt:for-each>
        </xslt:template>
@@ -135,7 +146,7 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h
                If no `@data-footer` attribute is provided, no footer is rendered.
        -->
        <xslt:template match="html:shrine-footer" mode="template">
                If no `@data-footer` attribute is provided, no footer is rendered.
        -->
        <xslt:template match="html:shrine-footer" mode="template">
-               <xslt:for-each select="exslt:node-set($source)/*/@data-shrine-footer">
+               <xslt:for-each select="$source/*/@data-shrine-footer">
                        <xslt:apply-templates select="document(concat('./', ., '-footer.xml'), $template)/*" mode="content"/>
                </xslt:for-each>
        </xslt:template>
                        <xslt:apply-templates select="document(concat('./', ., '-footer.xml'), $template)/*" mode="content"/>
                </xslt:for-each>
        </xslt:template>
@@ -144,7 +155,7 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h
                Process the content.
        -->
        <xslt:template match="html:shrine-content" mode="template">
                Process the content.
        -->
        <xslt:template match="html:shrine-content" mode="template">
-               <xslt:apply-templates select="exslt:node-set($source)/*" mode="content"/>
+               <xslt:apply-templates select="$source/*" mode="content"/>
        </xslt:template>
 
        <!--
        </xslt:template>
 
        <!--
@@ -160,4 +171,9 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h
                        </xslt:when>
                </xslt:choose>
        </xslt:template>
                        </xslt:when>
                </xslt:choose>
        </xslt:template>
+
+       <!--
+               Set the output mode to HTML.
+       -->
+       <xslt:output method="html" charset="UTF-8" doctype-system="about:legacy-compat" indent="no"/>
 </xslt:transform>
 </xslt:transform>
This page took 0.024122 seconds and 4 git commands to generate.