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"
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-`.
+ 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: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>
<!--
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:copy>
+ </xslt:element>
+ </xslt:template>
+
+ <!--
+ Process template text; just make a copy.
+ -->
+ <xslt:template match="text()" mode="content">
+ <xslt:copy/>
</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">
- <xslt:copy>
- <xslt:for-each select="@*">
+ <html>
+ <xslt:for-each select="@*[not(starts-with(name(), 'xmlns'))]">
<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>
+ </html>
</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">
- <xslt:copy>
+ <head>
<xslt:for-each select="@*">
<xslt:copy/>
</xslt:for-each>
- <xslt:for-each select="exslt:node-set($source)//*[@slot='shrine-head']">
- <xslt:text>
</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>
</xslt:text>
+ <xslt:if test="not($source//html:title[@slot='shrine-head'])">
<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"/>
- </xslt:copy>
+ <xslt:for-each select="$source//*[@slot='shrine-head']">
+ <xslt:apply-templates select="." mode="content"/>
+ </xslt:for-each>
+ </head>
</xslt: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>
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>
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: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>