Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-04-06 14:56:47 -0400
committerShelly Shaver <shelly.shaver@rtspecialty.com>2018-04-06 15:03:32 -0400
commit8a17d0c6c575be59ace4d6b45fc59f972058a0ea (patch)
tree0d9bb490760199217efe2bfdc6f620cc51ccd122 /src
parent6d0f4fd458a0796af165a68b3c370715ec24074d (diff)
downloadtame-8a17d0c6c575be59ace4d6b45fc59f972058a0ea.tar.gz
tame-8a17d0c6c575be59ace4d6b45fc59f972058a0ea.tar.bz2
tame-8a17d0c6c575be59ace4d6b45fc59f972058a0ea.zip
c1map: Add lvm:whenv2.14.0
This allows for conditional nodes where lvm:if is not appropriate or cannot be used.
Diffstat (limited to 'src')
-rw-r--r--src/current/c1map.xsl28
-rw-r--r--src/current/c1map/render.xsl39
2 files changed, 65 insertions, 2 deletions
diff --git a/src/current/c1map.xsl b/src/current/c1map.xsl
index 9b95a8c..f6e1903 100644
--- a/src/current/c1map.xsl
+++ b/src/current/c1map.xsl
@@ -338,8 +338,27 @@
mode="lvmp:c1-node-result" priority="5">
<lvmp:for-each name="{@lvm:for-each}">
- <!-- proceed with processing as normal -->
- <xsl:apply-templates select="@*|*" />
+ <xsl:choose>
+ <xsl:when test="lvm:when">
+ <lvmp:condition when="true">
+ <lvmp:when>
+ <xsl:call-template name="lvmp:gen-val">
+ <xsl:with-param name="name" select="lvm:when/@name" />
+ </xsl:call-template>
+ </lvmp:when>
+ <lvmp:cmp>
+ <xsl:apply-templates mode="lvm:valparse"
+ select="lvm:when/@eq" />
+ </lvmp:cmp>
+
+ <xsl:apply-templates select="@*|*" />
+ </lvmp:condition>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:apply-templates select="@*|*" />
+ </xsl:otherwise>
+ </xsl:choose>
</lvmp:for-each>
</xsl:template>
@@ -366,6 +385,11 @@
</xsl:template>
+<xsl:template match="lvm:when" priority="4">
+ <!-- handled as part of @lvm:for-each -->
+</xsl:template>
+
+
<!--
Unhandled node character data
diff --git a/src/current/c1map/render.xsl b/src/current/c1map/render.xsl
index 24740e0..ae12767 100644
--- a/src/current/c1map/render.xsl
+++ b/src/current/c1map/render.xsl
@@ -291,6 +291,25 @@
</xsl:template>
+<xsl:template match="lvmp:for-each[ lvmp:condition[ @when ] ]" mode="lvmp:render" priority="8">
+ <xsl:variable name="from">
+ <xsl:call-template name="lvmp:var-from">
+ <xsl:with-param name="name" select="@name" />
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:text>$contract->iterateValues( '</xsl:text>
+ <xsl:value-of select="$from" />
+ <xsl:text>', </xsl:text>
+ <xsl:text>function( $contract ) {</xsl:text>
+ <xsl:text> return </xsl:text>
+ <xsl:apply-templates mode="lvmp:render" select="lvmp:condition" />
+ <xsl:text>;</xsl:text>
+ <xsl:text>}</xsl:text>
+ <xsl:text>)</xsl:text>
+</xsl:template>
+
+
<!--
The C1 import system recognizes the following formats:
@@ -353,6 +372,26 @@
</xsl:template>
+
+<xsl:template mode="lvmp:render" priority="8" match="lvmp:condition[ @when ]">
+ <xsl:variable name="cond" select="." />
+
+ <xsl:text>( ( </xsl:text>
+ <xsl:text>$contract->isTruthy( </xsl:text>
+ <xsl:apply-templates select="$cond/lvmp:when/lvmp:*" mode="lvmp:render" />
+ <xsl:if test="$cond/lvmp:cmp/*">
+ <xsl:text>,</xsl:text>
+ <xsl:apply-templates select="$cond/lvmp:cmp/lvmp:*" mode="lvmp:render" />
+ </xsl:if>
+ <xsl:text>)</xsl:text>
+ <xsl:text> ) ? array(</xsl:text>
+ <xsl:apply-templates mode="lvmp:render">
+ <xsl:with-param name="no-trailing-sep" select="true()" />
+ </xsl:apply-templates>
+ <xsl:text>) : null )</xsl:text>
+</xsl:template>
+
+
<xsl:template match="*" mode="lvmp:render" priority="1">
<xsl:message terminate="yes">
<xsl:text>[c1map] fatal: unexpected node during render: </xsl:text>