Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGreg Torbenson <gregory.torbenson@ryansg.com>2018-07-02 10:27:53 -0400
committerGreg Torbenson <gregory.torbenson@ryansg.com>2018-07-02 10:27:53 -0400
commit84f9321a4d4bc0ee476ca729de362db1f655e61e (patch)
tree10171ff84777bf552600bd48d9347b317f6dde8f /src
parent5cbffa9c1098e6eb358c5376b62ad2ae17e31d2f (diff)
downloadtame-84f9321a4d4bc0ee476ca729de362db1f655e61e.tar.gz
tame-84f9321a4d4bc0ee476ca729de362db1f655e61e.tar.bz2
tame-84f9321a4d4bc0ee476ca729de362db1f655e61e.zip
[DEV-3251] factor escape check out to a function, and also fix a bug.
Diffstat (limited to 'src')
-rw-r--r--src/current/c1map/c1nodes.xsl2
-rw-r--r--src/current/c1map/render.xsl23
2 files changed, 17 insertions, 8 deletions
diff --git a/src/current/c1map/c1nodes.xsl b/src/current/c1map/c1nodes.xsl
index 02c287c..23dfafc 100644
--- a/src/current/c1map/c1nodes.xsl
+++ b/src/current/c1map/c1nodes.xsl
@@ -61,7 +61,7 @@
<xsl:template match="c1:*" mode="lvmp:c1-node-result" priority="1">
<xsl:text>array( </xsl:text>
<xsl:apply-templates select="@*|*" />
- <xsl:if test="text() != '' and not(.[*])">
+ <xsl:if test="text() and not( element() )">
<xsl:text>'text()' => </xsl:text>
<xsl:apply-templates select="text()" mode="lvm:valparse" />
<xsl:text></xsl:text>
diff --git a/src/current/c1map/render.xsl b/src/current/c1map/render.xsl
index cbce134..7675621 100644
--- a/src/current/c1map/render.xsl
+++ b/src/current/c1map/render.xsl
@@ -22,6 +22,7 @@
-->
<xsl:stylesheet version="2.0"
xmlns:c1="http://www.epic-premier.com/XMLSchema"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lvm="http://www.lovullo.com/rater/map/c1"
xmlns:lvmp="http://www.lovullo.com/rater/map/c1/pp">
@@ -29,6 +30,16 @@
<xsl:import href="transform.xsl" />
+<xsl:function name="lvm:is-escaped-param" as="xs:boolean">
+ <xsl:param name="value" as="element( lvmp:value )"/>
+
+ <xsl:variable name="escape-param" as="xs:string?"
+ select="$value/ancestor-or-self::lvmp:node-boundary[1]/@escape-param[ 1 ]" />
+ <xsl:variable name="parent-value" as="element( lvmp:value )?"
+ select="$value/parent::lvmp:value[ 1 ]"/>
+
+ <xsl:sequence select="$escape-param and boolean($escape-param) and not( $parent-value )" />
+</xsl:function>
<xsl:template match="lvmp:root" mode="lvmp:render" priority="5">
<xsl:text>&lt;?php </xsl:text>
@@ -133,9 +144,8 @@
<xsl:param name="value" select="$var/@value" />
<xsl:param name="default" select="$var/lvmp:default" />
- <xsl:param name="escape-param" select="ancestor-or-self::*[@escape-param][ 1 ]/@escape-param" />
- <xsl:param name="parent-value" select="parent::lvmp:value[1]"/>
- <xsl:if test="$escape-param and $escape-param != '' and not($parent-value)">
+ <xsl:variable name="needs-escape" as="xs:boolean" select="lvm:is-escaped-param( . )"/>
+ <xsl:if test="$needs-escape">
<xsl:text>$contract-&gt;escapeValue(</xsl:text>
</xsl:if>
<xsl:text>$contract-&gt;getValueByContext( </xsl:text>
@@ -150,7 +160,7 @@
<xsl:text>' </xsl:text>
<xsl:text> )</xsl:text>
- <xsl:if test="$escape-param and $escape-param != '' and not($parent-value)">
+ <xsl:if test="$needs-escape">
<xsl:text> )</xsl:text>
</xsl:if>
</xsl:template>
@@ -185,10 +195,9 @@
</xsl:choose>
</xsl:param>
- <xsl:param name="escape-param" select="ancestor-or-self::*[@escape-param][ 1 ]/@escape-param" />
- <xsl:param name="parent-value" select="parent::lvmp:value[1]"/>
+ <xsl:variable name="needs-escape" as="xs:boolean" select="lvm:is-escaped-param( . )"/>
<xsl:choose>
- <xsl:when test="$escape-param and $escape-param != '' and not($parent-value)">
+ <xsl:when test="$needs-escape">
<xsl:text>$contract-&gt;escapeValue( $contract-&gt;getValue( '</xsl:text>
<xsl:value-of select="$from" />
<xsl:text>', $contract->getValueIndex( '</xsl:text>