Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2017-12-08 13:53:12 -0500
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2017-12-08 13:53:12 -0500
commit2f8ce0f2340eb04c53d2c7602cbfc2a7f677aa96 (patch)
tree1479c2e793d695db3dc871eea6e265004d48549c
parent65890f7156b0201b54a8951c3288ed1d6bba053e (diff)
downloadtame-2f8ce0f2340eb04c53d2c7602cbfc2a7f677aa96.tar.gz
tame-2f8ce0f2340eb04c53d2c7602cbfc2a7f677aa96.tar.bz2
tame-2f8ce0f2340eb04c53d2c7602cbfc2a7f677aa96.zip
Mark toplevel nodes affected by template expansion
This allows for debugging expansions, which are otherwise confusing and difficult. This will be valuable information for the Summary Pages as well (see future commit). * src/current/include/preproc/template.xsl (preproc:expand-template): Mark toplevel nodes after expansion. (preproc:mark-tpl-expansion): Add templates.
-rw-r--r--src/current/include/preproc/template.xsl62
1 files changed, 49 insertions, 13 deletions
diff --git a/src/current/include/preproc/template.xsl b/src/current/include/preproc/template.xsl
index 0b6d248..7e80f59 100644
--- a/src/current/include/preproc/template.xsl
+++ b/src/current/include/preproc/template.xsl
@@ -2,7 +2,7 @@
<!--
Performs template processing and expansion
- Copyright (C) 2016 LoVullo Associates, Inc.
+ Copyright (C) 2016, 2017 LoVullo Associates, Inc.
This file is part of TAME.
@@ -304,19 +304,27 @@
<!-- replace this node with a copy of all the child nodes of the given
template; this inlines it as if it were copied and pasted directly
into the XML, much like a C macro -->
- <xsl:apply-templates
- select="$tpl[ 1 ]/*"
- mode="preproc:apply-template">
-
- <xsl:with-param name="apply" select="$context"
- tunnel="yes" />
- <xsl:with-param name="apply-tpl-name" select="$name"
- tunnel="yes" />
- <xsl:with-param name="params" select="$params"
- tunnel="yes" />
+ <xsl:variable name="apply-result">
+ <xsl:apply-templates
+ select="$tpl[ 1 ]/*"
+ mode="preproc:apply-template">
+
+ <xsl:with-param name="apply" select="$context"
+ tunnel="yes" />
+ <xsl:with-param name="apply-tpl-name" select="$name"
+ tunnel="yes" />
+ <xsl:with-param name="params" select="$params"
+ tunnel="yes" />
+
+ <xsl:with-param name="first-child" select="true()" />
+ <xsl:with-param name="src-root" select="$src-root"
+ tunnel="yes" />
+ </xsl:apply-templates>
+ </xsl:variable>
- <xsl:with-param name="first-child" select="true()" />
- <xsl:with-param name="src-root" select="$src-root"
+ <xsl:apply-templates mode="preproc:mark-tpl-expansion"
+ select="$apply-result">
+ <xsl:with-param name="tpl-name" select="$name"
tunnel="yes" />
</xsl:apply-templates>
@@ -329,6 +337,34 @@
<!--
+ Add nodes describing where the parent node came from.
+
+ This helps in debugging and understanding code created by templates.
+ This isn't the best way, but e.g. enclosing all expanded nodes in a parent
+ tag causes problems with the rest of the system. Adding an attribute to
+ the node is an option, but this implementation allows a node to be marked
+ by multiple templates, should such a thing ever occur.
+-->
+<xsl:template mode="preproc:mark-tpl-expansion" priority="5"
+ match="element()">
+ <xsl:param name="tpl-name" tunnel="yes" />
+
+ <xsl:copy>
+ <xsl:sequence select="@*" />
+
+ <preproc:from-template name="{$tpl-name}" />
+
+ <xsl:sequence select="node()" />
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template mode="preproc:mark-tpl-expansion" priority="3"
+ match="node()|attribute()">
+ <xsl:sequence select="." />
+</xsl:template>
+
+
+<!--
Inline templates depending on the symbol table must not be expanded
until the symbol table is actually available
-->