Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShelly Shaver <shelly.shaver@rtspecialty.com>2018-06-19 10:06:19 -0400
committerGreg Torbenson <gregory.torbenson@ryansg.com>2018-06-29 17:14:57 -0400
commitc2504d89c04a0b92440398a9ecc0f740bf1d534f (patch)
treeeee906510e8ca376e0e57b96332e0ce365a51f2d /src
parentfc60f98908239a7d430a10ed26ab7a0461608bb2 (diff)
downloadtame-c2504d89c04a0b92440398a9ecc0f740bf1d534f.tar.gz
tame-c2504d89c04a0b92440398a9ecc0f740bf1d534f.tar.bz2
tame-c2504d89c04a0b92440398a9ecc0f740bf1d534f.zip
add support for escape-param attr
Diffstat (limited to 'src')
-rw-r--r--src/current/c1map/c1nodes.xsl73
-rw-r--r--src/current/c1map/render.xsl83
-rw-r--r--src/current/c1map/valparse.xsl9
3 files changed, 159 insertions, 6 deletions
diff --git a/src/current/c1map/c1nodes.xsl b/src/current/c1map/c1nodes.xsl
index a712bca..2fb8fbd 100644
--- a/src/current/c1map/c1nodes.xsl
+++ b/src/current/c1map/c1nodes.xsl
@@ -39,18 +39,43 @@
form:
'>Name' => array( <recurse> )
-->
+<!--
+<xsl:template match="c1:*[
+ node()
+ or ( @* and not( count( @* ) = count( @lvm:* )))]" priority="5">
+<xsl:template match="c1:*[(*) or ( @* and not( count( @* ) = count( @lvm:* )))]" priority="5">
+-->
<xsl:template match="c1:*[*|@*]" priority="5">
<!-- make the output a little bit sane -->
<xsl:value-of select="$lvmp:nl" />
<!-- defer node rendering; allows us to easily determine if there are
siblings of the same name within a node boundary -->
- <lvmp:node name="{name()}" />
+ <lvmp:node name="{name()}"/>
+<!--
+ <xsl:if test="not(@lvm:escape-param)">
+ <lvmp:node name="{name()}"/>
+ </xsl:if>
+ <xsl:if test="@lvm:escape-param">
+ <lvmp:node name="{name()}" escape-param="{@lvm:escape-param}"/>
+ </xsl:if>
+-->
<xsl:text> => </xsl:text>
- <lvmp:node-boundary>
- <xsl:apply-templates select="." mode="lvmp:c1-node-result" />
- </lvmp:node-boundary>
+<!--
+ <xsl:if test="not(@lvm:escape-param)">
+ <lvmp:node-boundary>
+ <xsl:apply-templates select="." mode="lvmp:c1-node-result" />
+ </lvmp:node-boundary>
+ </xsl:if>
+ <xsl:if test="@lvm:escape-param)">
+-->
+ <lvmp:node-boundary escape-param="{@lvm:escape-param}">
+ <xsl:apply-templates select="." mode="lvmp:c1-node-result" />
+ </lvmp:node-boundary>
+<!--
+ </xsl:if>
+-->
</xsl:template>
@@ -61,6 +86,11 @@
<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:text>'text()' => </xsl:text>
+ <xsl:apply-templates select="text()" mode="lvm:valparse" />
+ <xsl:text></xsl:text>
+ </xsl:if>
<xsl:text>) </xsl:text>
</xsl:template>
@@ -72,11 +102,22 @@
<xsl:template match="c1:*[text()]" priority="4">
<!-- defer node rendering; allows us to easily determine if there are
siblings of the same name within a node boundary -->
- <lvmp:node name="{name()}" />
+<!--
+-->
+<xsl:message select="'text-only node:'"/>
+<xsl:message select="."/>
+ <lvmp:node name="{name()}" escape-param="{@lvm:escape-param}"/>
<xsl:text> => </xsl:text>
<xsl:text></xsl:text>
<!-- TODO: escape single quotes -->
+<!--
+<xsl:message select="'{{{'"/>
+<xsl:message>
+ <xsl:apply-templates select="text()" mode="lvm:valparse"/>
+</xsl:message>
+<xsl:message select="'}}}'"/>
+-->
<xsl:apply-templates select="text()" mode="lvm:valparse" />
<xsl:text>, </xsl:text>
</xsl:template>
@@ -105,9 +146,31 @@
</xsl:template>
+
<xsl:template match="c1:*/@lvm:*" priority="6">
<!-- discard all system attributes -->
+ <xsl:message select="'\ndiscarding:'"/>
+ <xsl:message select="."/>
<!-- TODO: error once everything is properly implemented -->
+<!--
+ <xsl:text>'</xsl:text><xsl:value-of select="name()" />
+ <xsl:text>' => '[BLORT</xsl:text>
+ <xsl:apply-templates select="." mode="lvm:valparse"/>
+ <xsl:text>BLORT]' </xsl:text>
+-->
+</xsl:template>
+
+
+<!--
+<xsl:template match="c1:*[text()][ @lvm:escape-param ]" priority="7">
+ <lvmp:node name="{name()}" />
+ <xsl:text> => </xsl:text>
+
+ <xsl:text></xsl:text>
+ <xsl:apply-templates select="text()" mode="lvm:valparse" />
+ <xsl:text>, BLORT</xsl:text>
+
</xsl:template>
+-->
</xsl:stylesheet>
diff --git a/src/current/c1map/render.xsl b/src/current/c1map/render.xsl
index 2e8046c..01de88d 100644
--- a/src/current/c1map/render.xsl
+++ b/src/current/c1map/render.xsl
@@ -133,6 +133,11 @@
<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:text>$contract-&gt;escapeValue(</xsl:text>
+ </xsl:if>
<xsl:text>$contract-&gt;getValueByContext( </xsl:text>
<!-- recursive process contexts -->
<xsl:apply-templates select="lvmp:value" mode="lvmp:render">
@@ -145,6 +150,9 @@
<xsl:text>' </xsl:text>
<xsl:text> )</xsl:text>
+ <xsl:if test="$escape-param and $escape-param != '' and not($parent-value)">
+ <xsl:text> )</xsl:text>
+ </xsl:if>
</xsl:template>
@@ -177,11 +185,82 @@
</xsl:choose>
</xsl:param>
+
+ <!--<xsl:param name="escape-param" select="$scope/lvmp:var-escape[ @escape-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:message select="'====================='" />
+ <xsl:message select="$var/@name" />
+ <xsl:message select="ancestor-or-self::*[@escape-param]"/>
+ <xsl:message select="ancestor-or-self::*"/>
+ <xsl:message select="'\\\'"/>
+ <xsl:message select="$escape-param" />
+ <xsl:message select="'\\\\\\\\\\\\\\\\\\\\'"/>
+ -->
+<!--
+ <xsl:message select="parent::*/preceding-sibling::*"/>
+ <xsl:message select="'\\\\\\\\\\\\\\\\\\\\'"/>
+ <xsl:message select="parent::*"/>
+ <xsl:param name="escape-param" select="ancestor-or-self::*[ @escape-param ][ 1 ]" />
+ <xsl:message select="'====================='" />
+ <xsl:message select="ancestor-or-self::*" />
+ <xsl:text>*****</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$escape-param">
+ <xsl:text>$contract-&gt;escapeValue( $contract-&gt;getValue( '</xsl:text>
+ <xsl:value-of select="$from" />
+ <xsl:text>', $contract->getValueIndex( '</xsl:text>
+ <xsl:value-of select="$index-name" />
+ <xsl:text>' ) )</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>$contract-&gt;getValue( '</xsl:text>
+ <xsl:value-of select="$from" />
+ <xsl:text>', $contract->getValueIndex( '</xsl:text>
+ <xsl:value-of select="$index-name" />
+ <xsl:text>' )</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:message select="'======================'" />
+ <xsl:text>ooooooooooooo:</xsl:text>
+
+ <xsl:message select="$scope" />
+<xsl:message select="'==========================='"/>
+<xsl:message select="$scope"/>
+
<xsl:text>$contract-&gt;getValue( '</xsl:text>
<xsl:value-of select="$from" />
<xsl:text>', $contract->getValueIndex( '</xsl:text>
<xsl:value-of select="$index-name" />
<xsl:text>' )</xsl:text>
+-->
+<!--
+<xsl:message>===========</xsl:message>
+<xsl:message select=".[1]"/>
+<xsl:message select="$escape-param"/>
+<xsl:message select="parent::lvmp:value[1]"/>
+<xsl:message>===========</xsl:message>
+-->
+ <xsl:choose>
+ <xsl:when test="$escape-param and $escape-param != '' and not($parent-value)">
+<xsl:message select="'(escaping)'"/>
+ <xsl:text>$contract-&gt;escapeValue( $contract-&gt;getValue( '</xsl:text>
+ <xsl:value-of select="$from" />
+ <xsl:text>', $contract->getValueIndex( '</xsl:text>
+ <xsl:value-of select="$index-name" />
+ <xsl:text>' ) )</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+<xsl:message select="'(not escaping)'"/>
+ <xsl:text>$contract-&gt;getValue( '</xsl:text>
+ <xsl:value-of select="$from" />
+ <xsl:text>', $contract->getValueIndex( '</xsl:text>
+ <xsl:value-of select="$index-name" />
+ <xsl:text>' )</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:if test="$default">
<xsl:text>, </xsl:text>
@@ -241,6 +320,10 @@
<!-- no longer needed -->
</xsl:template>
+<xsl:template match="lvmp:var-escape" mode="lvmp:render" priority="5">
+ <!-- no longer needed -->
+</xsl:template>
+
<xsl:template match="lvmp:var/lvmp:default" mode="lvmp:render" priority="5">
<!-- render contents -->
<xsl:apply-templates mode="lvmp:render" />
diff --git a/src/current/c1map/valparse.xsl b/src/current/c1map/valparse.xsl
index e84b25d..e06de78 100644
--- a/src/current/c1map/valparse.xsl
+++ b/src/current/c1map/valparse.xsl
@@ -36,7 +36,6 @@
</xsl:call-template>
</xsl:template>
-
<xsl:template name="lvm:valparse">
<xsl:param name="str" />
@@ -143,6 +142,14 @@
) )
" />
+
+ <!--
+ <xsl:message select="$name,parent::c1:*" />
+ -->
+
+ <!--
+ <xsl:variable name="escape-param" select="ancestor::" />
+ -->
<lvmp:value ref="{$rightmost}" index-key="{$context}">
<xsl:call-template name="lvmp:gen-val">
<xsl:with-param name="name" select="$context" />