diff options
author | Mike Gerwitz <gerwitm@lovullo.com> | 2016-08-24 09:43:05 -0400 |
---|---|---|
committer | Mike Gerwitz <gerwitm@lovullo.com> | 2016-08-24 12:38:00 -0400 |
commit | ff01f39c1e8c9b9549d884a0db1f9a74799cf37e (patch) | |
tree | 35978db88a8d385250b1b47ad05966e19516373d /src/current/compiler/validate/param.xsl | |
parent | 6c0aa54bd1b7b49d736f0db3a8f48b7aa90b3b65 (diff) | |
download | tame-ff01f39c1e8c9b9549d884a0db1f9a74799cf37e.tar.gz tame-ff01f39c1e8c9b9549d884a0db1f9a74799cf37e.tar.bz2 tame-ff01f39c1e8c9b9549d884a0db1f9a74799cf37e.zip |
Liberate current implementation of "Calc DSL"
(Copyright headers will be added in the next commit; these are the
original files, unaltered in any way.)
The internal project name at LoVullo is simply "Calc DSL". This
liberates the entire thing. If anything was missed, I'll be added
later.
To continue building at LoVullo with this move, symlinks are used for
the transition; this is the exact code that is used in production.
There is a lot here---over 25,000 lines. Much of it is in disarray from
the environment surrounding its development, but it does work well for
what it was intended to do.
(LoVullo folks: fork point is 65723a0 in calcdsl.git.)
Diffstat (limited to 'src/current/compiler/validate/param.xsl')
-rw-r--r-- | src/current/compiler/validate/param.xsl | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/current/compiler/validate/param.xsl b/src/current/compiler/validate/param.xsl new file mode 100644 index 0000000..1d18d7a --- /dev/null +++ b/src/current/compiler/validate/param.xsl @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + Parameter validations +--> + +<xsl:stylesheet version="1.0" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:lv="http://www.lovullo.com/rater" + xmlns:c="http://www.lovullo.com/calc" + xmlns:lvv="http://www.lovullo.com/rater/validate" + xmlns:preproc="http://www.lovullo.com/rater/preproc"> + + +<!-- + Param type must be known + + TODO: Doesn't the symbol table lookup process handle this? +--> +<xsl:template match=" + lv:param[ + not( + @type=root(.)/preproc:symtable/preproc:sym[ + @type + ]/@name + ) + ]" + mode="lvv:validate" priority="5"> + + <xsl:call-template name="lvv:error"> + <xsl:with-param name="desc" select="'Unknown param type'" /> + <xsl:with-param name="refnode" select="." /> + <xsl:with-param name="content"> + <xsl:text>'</xsl:text> + <xsl:value-of select="@type" /> + <xsl:text>' is undefined for param </xsl:text> + <xsl:value-of select="@name" /> + </xsl:with-param> + </xsl:call-template> +</xsl:template> + + +<!-- + Default must be within the domain of the param + + Note that this template priority is less than the template that checks to + ensure that the param type exists in the first place. +--> +<xsl:template match="lv:param[ @default ]" + mode="lvv:validate" priority="4"> + + <xsl:variable name="type" select="@type" /> + + <!-- default must be within its domain --> + <xsl:variable name="result"> + <xsl:call-template name="lvv:domain-check"> + <xsl:with-param name="value" select="@default" /> + <xsl:with-param name="sym-domain" select=" + root(.)/preproc:symtable/preproc:sym[ + @name = $type + ]" /> + </xsl:call-template> + </xsl:variable> + + <xsl:if test="not( $result/lvv:ok )"> + <xsl:variable name="fail" select="$result/lvv:fail/lvv:chk" /> + + <!-- if we didn't succeed, but we didn't fail, then we did something we + weren't supposed to --> + <xsl:if test="not( $fail )"> + <xsl:message terminate="yes"> + <xsl:text>internal error: in limbo processing param `</xsl:text> + <xsl:value-of select="@name" /> + <xsl:text>' @default</xsl:text> + </xsl:message> + </xsl:if> + + <xsl:call-template name="lvv:error"> + <xsl:with-param name="desc" select="'param @default domain violation'" /> + <xsl:with-param name="refnode" select="." /> + <xsl:with-param name="content"> + <xsl:text>param `</xsl:text> + <xsl:value-of select="@name" /> + <xsl:text>' @default of `</xsl:text> + <xsl:value-of select="$fail/@value" /> + <xsl:text>' is not within its domain of </xsl:text> + <xsl:value-of select="$fail/preproc:sym/@src" /> + <xsl:text>/</xsl:text> + <xsl:value-of select="$fail/preproc:sym/@name" /> + </xsl:with-param> + </xsl:call-template> + </xsl:if> +</xsl:template> + + +<!-- + Fallback for no validation issues +--> +<xsl:template match="lv:param" mode="lvv:validate" priority="2"> +</xsl:template> + +</xsl:stylesheet> + |