Strip xsl: namespace prefix from most files

Still left are files that I don't want to deal with testing right now.
master
Mike Gerwitz 2019-02-07 14:36:17 -05:00
parent e022a3133d
commit bd73ea0121
22 changed files with 3486 additions and 3517 deletions

View File

@ -23,97 +23,96 @@
Also performs validation.
-->
<xsl:stylesheet version="2.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:lvm="http://www.lovullo.com/rater/map"
xmlns:lvmc="http://www.lovullo.com/rater/map/compiler"
xmlns:c="http://www.lovullo.com/calc"
xmlns:w="http://www.lovullo.com/rater/worksheet"
xmlns:util="http://www.lovullo.com/util"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:compiler="http://www.lovullo.com/rater/compiler"
xmlns:calc-compiler="http://www.lovullo.com/calc/compiler"
xmlns:ext="http://www.lovullo.com/ext">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:lvm="http://www.lovullo.com/rater/map"
xmlns:lvmc="http://www.lovullo.com/rater/map/compiler"
xmlns:c="http://www.lovullo.com/calc"
xmlns:w="http://www.lovullo.com/rater/worksheet"
xmlns:util="http://www.lovullo.com/util"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:compiler="http://www.lovullo.com/rater/compiler"
xmlns:calc-compiler="http://www.lovullo.com/calc/compiler"
xmlns:ext="http://www.lovullo.com/ext">
<xsl:output
<output
indent="yes"
omit-xml-declaration="yes"
/>
<!-- processing utilities -->
<xsl:include href="include/util.xsl" />
<include href="include/util.xsl" />
<!-- compiler -> JS -->
<xsl:include href="include/preprocess.xsl" />
<xsl:include href="compiler/validate.xsl" />
<xsl:include href="compiler/js.xsl" />
<xsl:include href="compiler/map.xsl" />
<include href="include/preprocess.xsl" />
<include href="compiler/validate.xsl" />
<include href="compiler/js.xsl" />
<include href="compiler/map.xsl" />
<!-- TODO: move into compiler/ -->
<xsl:include href="c1map.xsl" />
<include href="c1map.xsl" />
<!-- contains get-symbol-map -->
<xsl:include href="include/display.xsl" />
<include href="include/display.xsl" />
<!-- allows disabling of time-consuming validation -->
<xsl:param name="preproc-cache-validate" select="'true'" />
<param name="preproc-cache-validate" select="'true'" />
<!--
Simply copy the preprocessor output; the caller is responsible for outputting
this to a document.
-->
<xsl:template match="/lv:rater|/lv:package" priority="5">
<template match="/lv:rater|/lv:package" priority="5">
<!-- XXX: Duplicate code; see summary -->
<xsl:variable name="processed">
<xsl:apply-templates select="." mode="preproc:compile" />
</xsl:variable>
<variable name="processed">
<apply-templates select="." mode="preproc:compile" />
</variable>
<!-- fail on preprocessor errors -->
<xsl:call-template name="preproc:err-chk">
<xsl:with-param name="processed" select="$processed" />
</xsl:call-template>
<call-template name="preproc:err-chk">
<with-param name="processed" select="$processed" />
</call-template>
<!-- validation must have passed; output the nodes -->
<xsl:copy-of select="$processed" />
</xsl:template>
<copy-of select="$processed" />
</template>
<xsl:template name="preproc:err-chk">
<xsl:param name="processed" />
<template name="preproc:err-chk">
<param name="processed" />
<xsl:for-each select="$processed//preproc:error">
<xsl:message terminate="yes">
<xsl:text>!!! preprocessor error: </xsl:text>
<xsl:value-of select="." />
</xsl:message>
</xsl:for-each>
</xsl:template>
<for-each select="$processed//preproc:error">
<message terminate="yes">
<text>!!! preprocessor error: </text>
<value-of select="." />
</message>
</for-each>
</template>
<xsl:template match="*" mode="preproc:handle-errors" priority="1">
<template match="*" mode="preproc:handle-errors" priority="1">
<!-- do nothing -->
</xsl:template>
</template>
<xsl:template match="lvm:program-map|lvm:return-map" priority="5">
<xsl:apply-templates select="." mode="lvmc:compile" />
</xsl:template>
<template match="lvm:program-map|lvm:return-map" priority="5">
<apply-templates select="." mode="lvmc:compile" />
</template>
<xsl:template match="w:worksheet" priority="5">
<xsl:apply-templates select="." mode="w:compile" />
</xsl:template>
<template match="w:worksheet" priority="5">
<apply-templates select="." mode="w:compile" />
</template>
<!-- any unhandled nodes should be an error -->
<xsl:template match="*" priority="1">
<xsl:message terminate="yes">
<xsl:text>fatal: source file is invalid: unexpected node </xsl:text>
<xsl:value-of select="name()" />
</xsl:message>
</xsl:template>
<template match="*" priority="1">
<message terminate="yes">
<text>fatal: source file is invalid: unexpected node </text>
<value-of select="name()" />
</message>
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -24,135 +24,134 @@
responsible for outputting the generated code in whatever manner is
appropriate (inline JS, a file, etc).
-->
<xsl:stylesheet version="2.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:preproc="http://www.lovullo.com/rater/preproc">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc"
xmlns:preproc="http://www.lovullo.com/rater/preproc">
<xsl:template match="lv:package" mode="preproc:compile-fragments">
<xsl:copy>
<xsl:sequence select="@*, *" />
<template match="lv:package" mode="preproc:compile-fragments">
<copy>
<sequence select="@*, *" />
<!-- compile each fragment in the symbol table -->
<preproc:fragments>
<xsl:for-each select="preproc:symtable/preproc:sym">
<xsl:variable name="result">
<xsl:apply-templates select="." mode="preproc:compile-fragments" />
</xsl:variable>
<for-each select="preproc:symtable/preproc:sym">
<variable name="result">
<apply-templates select="." mode="preproc:compile-fragments" />
</variable>
<xsl:if test="$result != ''">
<if test="$result != ''">
<preproc:fragment id="{@name}">
<xsl:value-of select="$result" />
<value-of select="$result" />
</preproc:fragment>
</xsl:if>
</xsl:for-each>
</if>
</for-each>
</preproc:fragments>
</xsl:copy>
</xsl:template>
</copy>
</template>
<xsl:template match="preproc:sym[ @src ]" mode="preproc:compile-fragments" priority="9">
<template match="preproc:sym[ @src ]" mode="preproc:compile-fragments" priority="9">
<!-- do not compile external symbols -->
</xsl:template>
</template>
<xsl:template match="preproc:sym" mode="preproc:compile-fragments" priority="1">
<xsl:message terminate="yes">
<xsl:text>[jsc] fatal: unknown symbol type for `</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>': </xsl:text>
<xsl:value-of select="@type" />
</xsl:message>
</xsl:template>
<template match="preproc:sym" mode="preproc:compile-fragments" priority="1">
<message terminate="yes">
<text>[jsc] fatal: unknown symbol type for `</text>
<value-of select="@name" />
<text>': </text>
<value-of select="@type" />
</message>
</template>
<xsl:template match="preproc:sym[ @type='rate' ]" mode="preproc:compile-fragments" priority="5">
<xsl:variable name="name" select="@name" />
<xsl:variable name="pkg" as="element( lv:package )"
<template match="preproc:sym[ @type='rate' ]" mode="preproc:compile-fragments" priority="5">
<variable name="name" select="@name" />
<variable name="pkg" as="element( lv:package )"
select="root(.)" />
<!-- could be one of two places -->
<xsl:apply-templates mode="compile" select="
<apply-templates mode="compile" select="
$pkg/lv:rate[ @yields=$name ]
, $pkg/lv:rate-group/lv:rate[ @yields=$name ]
" />
</xsl:template>
<xsl:template match="preproc:sym[ @type='gen' ]" mode="preproc:compile-fragments" priority="5">
</template>
<template match="preproc:sym[ @type='gen' ]" mode="preproc:compile-fragments" priority="5">
<!-- compiled by above -->
</xsl:template>
</template>
<xsl:template match="preproc:sym[ @type='class' ]" mode="preproc:compile-fragments" priority="5">
<template match="preproc:sym[ @type='class' ]" mode="preproc:compile-fragments" priority="5">
<!-- name is prefixed with :class: -->
<xsl:variable name="as" select="substring-after( @name, ':class:' )" />
<xsl:variable name="pkg" as="element( lv:package )"
<variable name="as" select="substring-after( @name, ':class:' )" />
<variable name="pkg" as="element( lv:package )"
select="root(.)" />
<xsl:apply-templates select="$pkg/lv:classify[ @as=$as ]" mode="compile" />
</xsl:template>
<xsl:template match="preproc:sym[ @type='cgen' ]" mode="preproc:compile-fragments" priority="5">
<apply-templates select="$pkg/lv:classify[ @as=$as ]" mode="compile" />
</template>
<template match="preproc:sym[ @type='cgen' ]" mode="preproc:compile-fragments" priority="5">
<!-- compiled by above -->
</xsl:template>
</template>
<xsl:template match="preproc:sym[ @type='func' ]" mode="preproc:compile-fragments" priority="5">
<xsl:variable name="name" select="@name" />
<xsl:variable name="pkg" as="element( lv:package )"
<template match="preproc:sym[ @type='func' ]" mode="preproc:compile-fragments" priority="5">
<variable name="name" select="@name" />
<variable name="pkg" as="element( lv:package )"
select="root(.)" />
<xsl:apply-templates select="$pkg/lv:function[ @name=$name ]" mode="compile" />
</xsl:template>
<apply-templates select="$pkg/lv:function[ @name=$name ]" mode="compile" />
</template>
<xsl:template match="preproc:sym[ @type='param' ]" mode="preproc:compile-fragments" priority="5">
<xsl:variable name="name" select="@name" />
<xsl:variable name="pkg" as="element( lv:package )"
<template match="preproc:sym[ @type='param' ]" mode="preproc:compile-fragments" priority="5">
<variable name="name" select="@name" />
<variable name="pkg" as="element( lv:package )"
select="root(.)" />
<xsl:apply-templates select="$pkg/lv:param[ @name=$name ]" mode="compile" />
</xsl:template>
<apply-templates select="$pkg/lv:param[ @name=$name ]" mode="compile" />
</template>
<xsl:template match="preproc:sym[ @type='type' ]" mode="preproc:compile-fragments" priority="5">
<xsl:variable name="name" select="@name" />
<xsl:variable name="pkg" as="element( lv:package )"
<template match="preproc:sym[ @type='type' ]" mode="preproc:compile-fragments" priority="5">
<variable name="name" select="@name" />
<variable name="pkg" as="element( lv:package )"
select="root(.)" />
<!-- a typedef can stand on its own or exist within another typedef -->
<xsl:apply-templates mode="compile" select="
<apply-templates mode="compile" select="
$pkg/lv:typedef[ @name=$name ]
, $pkg//lv:typedef//lv:typedef[ @name=$name ]
" />
</xsl:template>
</template>
<xsl:template match="preproc:sym[ @type='const' ]" mode="preproc:compile-fragments" priority="5">
<xsl:variable name="name" select="@name" />
<xsl:variable name="pkg" as="element( lv:package )"
<template match="preproc:sym[ @type='const' ]" mode="preproc:compile-fragments" priority="5">
<variable name="name" select="@name" />
<variable name="pkg" as="element( lv:package )"
select="root(.)" />
<xsl:apply-templates mode="compile"
<apply-templates mode="compile"
select="$pkg/lv:const[ @name=$name ],
$pkg/lv:typedef//lv:item[ @name=$name ]">
<xsl:with-param name="as-const" select="true()" />
</xsl:apply-templates>
</xsl:template>
<with-param name="as-const" select="true()" />
</apply-templates>
</template>
<xsl:template match="preproc:sym[ @type='tpl' ]" mode="preproc:compile-fragments" priority="5">
<template match="preproc:sym[ @type='tpl' ]" mode="preproc:compile-fragments" priority="5">
<!-- templates are for the preprocessor only -->
</xsl:template>
</template>
<xsl:template match="preproc:sym[ @type='lparam' ]" mode="preproc:compile-fragments" priority="5">
<template match="preproc:sym[ @type='lparam' ]" mode="preproc:compile-fragments" priority="5">
<!-- they're local and therefore compiled as part of the containing block -->
</xsl:template>
</template>
<xsl:template match="preproc:sym[ @type='meta' ]"
<template match="preproc:sym[ @type='meta' ]"
mode="preproc:compile-fragments" priority="5">
<xsl:variable name="name" select="substring-after( @name, ':meta:' )" />
<xsl:variable name="pkg" as="element( lv:package )"
<variable name="name" select="substring-after( @name, ':meta:' )" />
<variable name="pkg" as="element( lv:package )"
select="root(.)" />
<xsl:variable name="node" as="element( lv:prop )"
<variable name="node" as="element( lv:prop )"
select="$pkg/lv:meta/lv:prop[ @name=$name ]" />
<xsl:apply-templates mode="compile"
<apply-templates mode="compile"
select="$node" />
</xsl:template>
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -24,89 +24,88 @@
responsible for outputting the generated code in whatever manner is
appropriate (inline JS, a file, etc).
-->
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:log="http://www.lovullo.com/logger">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:log="http://www.lovullo.com/logger">
<xsl:template name="log:info">
<xsl:param name="name" />
<xsl:param name="msg" />
<template name="log:info">
<param name="name" />
<param name="msg" />
<xsl:message>
<xsl:if test="$name">
<xsl:text>[</xsl:text>
<xsl:value-of select="$name" />
<xsl:text>] </xsl:text>
</xsl:if>
<message>
<if test="$name">
<text>[</text>
<value-of select="$name" />
<text>] </text>
</if>
<xsl:value-of select="$msg" />
</xsl:message>
</xsl:template>
<value-of select="$msg" />
</message>
</template>
<xsl:template name="log:debug">
<xsl:param name="name" />
<xsl:param name="msg" />
<template name="log:debug">
<param name="name" />
<param name="msg" />
<xsl:message>
<xsl:if test="$name">
<xsl:text>[</xsl:text>
<xsl:value-of select="$name" />
<xsl:text>] </xsl:text>
</xsl:if>
<message>
<if test="$name">
<text>[</text>
<value-of select="$name" />
<text>] </text>
</if>
<xsl:value-of select="$msg" />
</xsl:message>
</xsl:template>
<value-of select="$msg" />
</message>
</template>
<xsl:template name="log:warn">
<xsl:param name="name" />
<xsl:param name="msg" />
<template name="log:warn">
<param name="name" />
<param name="msg" />
<xsl:message>
<xsl:if test="$name">
<xsl:text>[</xsl:text>
<xsl:value-of select="$name" />
<xsl:text>] warning: </xsl:text>
</xsl:if>
<message>
<if test="$name">
<text>[</text>
<value-of select="$name" />
<text>] warning: </text>
</if>
<xsl:value-of select="$msg" />
</xsl:message>
</xsl:template>
<value-of select="$msg" />
</message>
</template>
<xsl:template name="log:error">
<xsl:param name="name" />
<xsl:param name="msg" />
<xsl:param name="terminate" select="'yes'" />
<template name="log:error">
<param name="name" />
<param name="msg" />
<param name="terminate" select="'yes'" />
<xsl:message terminate="{$terminate}">
<xsl:if test="$msg">
<xsl:if test="$name">
<xsl:text>[</xsl:text>
<xsl:value-of select="$name" />
<xsl:text>] error: </xsl:text>
</xsl:if>
<message terminate="{$terminate}">
<if test="$msg">
<if test="$name">
<text>[</text>
<value-of select="$name" />
<text>] error: </text>
</if>
<xsl:value-of select="$msg" />
</xsl:if>
</xsl:message>
</xsl:template>
<value-of select="$msg" />
</if>
</message>
</template>
<xsl:template name="log:internal-error">
<xsl:param name="name" />
<xsl:param name="msg" />
<xsl:param name="terminate" select="'yes'" />
<template name="log:internal-error">
<param name="name" />
<param name="msg" />
<param name="terminate" select="'yes'" />
<xsl:message terminate="{$terminate}">
<xsl:if test="$name">
<xsl:text>[</xsl:text>
<xsl:value-of select="$name" />
<xsl:text>] internal error: </xsl:text>
</xsl:if>
<message terminate="{$terminate}">
<if test="$name">
<text>[</text>
<value-of select="$name" />
<text>] internal error: </text>
</if>
<xsl:value-of select="$msg" />
</xsl:message>
</xsl:template>
<value-of select="$msg" />
</message>
</template>
</xsl:stylesheet>
</stylesheet>

File diff suppressed because it is too large Load Diff

View File

@ -23,13 +23,12 @@
TODO: For core domains, validate src package path as well. (Right now,
param types are polluting, and so this is not a problem.)
-->
<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">
<stylesheet version="2.0"
xmlns="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">
<!--
@ -37,32 +36,32 @@
SYM-DOMAIN should be a symbol resolving to the domain definition.
-->
<xsl:template name="lvv:domain-check">
<xsl:param name="value" />
<xsl:param name="sym-domain" />
<template name="lvv:domain-check">
<param name="value" />
<param name="sym-domain" />
<xsl:if test="not( $sym-domain )">
<xsl:message terminate="yes">
<xsl:text>internal error: no domain symbol provided; </xsl:text>
<xsl:text>caller: </xsl:text>
<xsl:copy-of select="." />
</xsl:message>
</xsl:if>
<if test="not( $sym-domain )">
<message terminate="yes">
<text>internal error: no domain symbol provided; </text>
<text>caller: </text>
<copy-of select="." />
</message>
</if>
<!-- generate node to simplify xpath expressions -->
<xsl:variable name="sym-validate">
<variable name="sym-validate">
<lvv:chk value="{$value}">
<xsl:copy-of select="$sym-domain" />
<copy-of select="$sym-domain" />
</lvv:chk>
</xsl:variable>
</variable>
<xsl:apply-templates mode="lvv:domain-check"
<apply-templates mode="lvv:domain-check"
select="$sym-validate/lvv:chk">
<xsl:with-param name="self-pkg" select="
<with-param name="self-pkg" select="
$sym-domain/ancestor::lv:package" />
</xsl:apply-templates>
</xsl:template>
</apply-templates>
</template>
<!--
@ -72,7 +71,7 @@
- Floats must be any type of number; and
- Booleans may be only 1 or 0.
-->
<xsl:template match="
<template match="
lvv:chk[
preproc:sym/@type = 'type'
and (
@ -99,14 +98,14 @@
]"
mode="lvv:domain-check" priority="5">
<xsl:call-template name="lvv:domain-fail" />
</xsl:template>
<call-template name="lvv:domain-fail" />
</template>
<!--
Domain assertions on user-defined types
-->
<xsl:template match="
<template match="
lvv:chk[
preproc:sym/@type='type'
and not (
@ -118,50 +117,50 @@
"
mode="lvv:domain-check" priority="5">
<xsl:param name="self-pkg" />
<param name="self-pkg" />
<xsl:variable name="chkval" select="@value" />
<variable name="chkval" select="@value" />
<xsl:variable name="domain">
<xsl:call-template name="lvv:get-domain-by-sym">
<xsl:with-param name="sym" select="preproc:sym" />
<xsl:with-param name="self-pkg" select="$self-pkg" />
</xsl:call-template>
</xsl:variable>
<variable name="domain">
<call-template name="lvv:get-domain-by-sym">
<with-param name="sym" select="preproc:sym" />
<with-param name="self-pkg" select="$self-pkg" />
</call-template>
</variable>
<xsl:choose>
<xsl:when test="$domain/lv:domain/lv:element[ @value = $chkval ]">
<choose>
<when test="$domain/lv:domain/lv:element[ @value = $chkval ]">
<lvv:ok type="domain-check" />
</xsl:when>
</when>
<xsl:otherwise>
<xsl:call-template name="lvv:domain-fail" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<otherwise>
<call-template name="lvv:domain-fail" />
</otherwise>
</choose>
</template>
<!--
No validation failure
-->
<xsl:template match="lvv:chk"
<template match="lvv:chk"
mode="lvv:domain-check" priority="2">
<lvv:ok type="domain-check" />
</xsl:template>
</template>
<!--
We passed ourselves something unexpected
-->
<xsl:template match="*"
<template match="*"
mode="lvv:domain-chk" priority="1">
<xsl:message terminate="yes">
<xsl:text>internal error: unexpected node for lvv:domain-chk: </xsl:text>
<xsl:copy-of select="." />
</xsl:message>
</xsl:template>
<message terminate="yes">
<text>internal error: unexpected node for lvv:domain-chk: </text>
<copy-of select="." />
</message>
</template>
<!--
@ -170,19 +169,19 @@
TODO: Once domains are used as the primary source instead of typedefs,
check to ensure that the symbol is an actual domain symbol.
-->
<xsl:template name="lvv:domain-fail">
<template name="lvv:domain-fail">
<lvv:fail type="domain-check">
<xsl:copy-of select="." />
<copy-of select="." />
</lvv:fail>
</xsl:template>
</template>
<xsl:template name="lvv:get-domain-by-sym">
<xsl:param name="sym" />
<xsl:param name="self-pkg" select="ancestor::lv:package" />
<template name="lvv:get-domain-by-sym">
<param name="sym" />
<param name="self-pkg" select="ancestor::lv:package" />
<!-- package containing symbol -->
<xsl:variable name="pkg" select="
<variable name="pkg" select="
if ( $sym/@src and not( $sym/@src='' ) ) then
document( concat( $sym/@src, '.xmlo' ), $__entry-root )
/lv:package
@ -191,20 +190,20 @@
" />
<!-- attempt to locate domain of the given name -->
<xsl:variable name="domain" select="
<variable name="domain" select="
$pkg/lv:domain[ @name = $sym/@name ]" />
<xsl:if test="not( $domain )">
<xsl:message terminate="yes">
<xsl:text>error: no domain found for </xsl:text>
<xsl:value-of select="$sym/@src" />
<xsl:text>/</xsl:text>
<xsl:value-of select="$sym/@name" />
</xsl:message>
</xsl:if>
<if test="not( $domain )">
<message terminate="yes">
<text>error: no domain found for </text>
<value-of select="$sym/@src" />
<text>/</text>
<value-of select="$sym/@name" />
</message>
</if>
<xsl:copy-of select="$domain" />
</xsl:template>
<copy-of select="$domain" />
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -20,13 +20,12 @@
along with this program. If not, see
<http://www.gnu.org/licenses/>.
-->
<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">
<stylesheet version="2.0"
xmlns="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">
<!--
@ -34,7 +33,7 @@
TODO: Doesn't the symbol table lookup process handle this?
-->
<xsl:template match="
<template match="
lv:param[
not(
@type=root(.)/preproc:symtable/preproc:sym[
@ -44,17 +43,17 @@
]"
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>
<call-template name="lvv:error">
<with-param name="desc" select="'Unknown param type'" />
<with-param name="refnode" select="." />
<with-param name="content">
<text>'</text>
<value-of select="@type" />
<text>' is undefined for param </text>
<value-of select="@name" />
</with-param>
</call-template>
</template>
<!--
@ -63,58 +62,58 @@
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 ]"
<template match="lv:param[ @default ]"
mode="lvv:validate" priority="4">
<xsl:variable name="type" select="@type" />
<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="
<variable name="result">
<call-template name="lvv:domain-check">
<with-param name="value" select="@default" />
<with-param name="sym-domain" select="
root(.)/preproc:symtable/preproc:sym[
@name = $type
]" />
</xsl:call-template>
</xsl:variable>
</call-template>
</variable>
<xsl:if test="not( $result/lvv:ok )">
<xsl:variable name="fail" select="$result/lvv:fail/lvv:chk" />
<if test="not( $result/lvv:ok )">
<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>
<if test="not( $fail )">
<message terminate="yes">
<text>internal error: in limbo processing param `</text>
<value-of select="@name" />
<text>' @default</text>
</message>
</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>
<call-template name="lvv:error">
<with-param name="desc" select="'param @default domain violation'" />
<with-param name="refnode" select="." />
<with-param name="content">
<text>param `</text>
<value-of select="@name" />
<text>' @default of `</text>
<value-of select="$fail/@value" />
<text>' is not within its domain of </text>
<value-of select="$fail/preproc:sym/@src" />
<text>/</text>
<value-of select="$fail/preproc:sym/@name" />
</with-param>
</call-template>
</if>
</template>
<!--
Fallback for no validation issues
-->
<xsl:template match="lv:param" mode="lvv:validate" priority="2">
</xsl:template>
<template match="lv:param" mode="lvv:validate" priority="2">
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -20,63 +20,61 @@
along with this program. If not, see
<http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:dot="http://www.lovullo.com/calc/dot">
xmlns:lv="http://www.lovullo.com/rater"
xmlns:dot="http://www.lovullo.com/calc/dot">
<xsl:import href="dot/depout.xsl" />
<xsl:import href="dot/defnode.xsl" />
<import href="dot/depout.xsl" />
<import href="dot/defnode.xsl" />
<!-- supported sources (entry points) -->
<xsl:include href="dot/pkg-obj.xsl" />
<xsl:include href="dot/pkg-exec.xsl" />
<include href="dot/pkg-obj.xsl" />
<include href="dot/pkg-exec.xsl" />
<xsl:output method="text" />
<output method="text" />
<!--
Newline character
-->
<xsl:variable name="dot:nl" select="'&#10;'" />
<variable name="dot:nl" select="'&#10;'" />
<!--
Immediately fails on unrecognized source type
-->
<xsl:template match="lv:package" priority="1">
<xsl:message terminate="yes">
<xsl:text>[dot] fatal: this is not an object/executable file: </xsl:text>
<xsl:text>no symbol dependencies found</xsl:text>
</xsl:message>
</xsl:template>
<template match="lv:package" priority="1">
<message terminate="yes">
<text>[dot] fatal: this is not an object/executable file: </text>
<text>no symbol dependencies found</text>
</message>
</template>
<!--
Beginning of a DOT document
-->
<xsl:template match="lv:package" mode="dot:head">
<xsl:text>/* dependency graph of </xsl:text>
<xsl:value-of select="@name" />
<xsl:text> */</xsl:text>
<template match="lv:package" mode="dot:head">
<text>/* dependency graph of </text>
<value-of select="@name" />
<text> */</text>
<xsl:text>digraph "</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>" { </xsl:text>
<text>digraph "</text>
<value-of select="@name" />
<text>" { </text>
<xsl:text>graph [rankdir="LR", ranksep="2"]; </xsl:text>
</xsl:template>
<text>graph [rankdir="LR", ranksep="2"]; </text>
</template>
<!--
End of a DOT document
-->
<xsl:template match="lv:package" mode="dot:tail">
<xsl:text>}</xsl:text>
</xsl:template>
<template match="lv:package" mode="dot:tail">
<text>}</text>
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -23,14 +23,12 @@
Nodes do not need to be defined (DOT will generate them upon first reference);
this defines nodes that require additional data associated with them.
-->
<xsl:stylesheet version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:dot="http://www.lovullo.com/calc/dot"
xmlns:preproc="http://www.lovullo.com/rater/preproc">
xmlns:dot="http://www.lovullo.com/calc/dot"
xmlns:preproc="http://www.lovullo.com/rater/preproc">
<xsl:import href="./defnode-attr.xsl" />
<import href="./defnode-attr.xsl" />
<!--
@ -38,7 +36,7 @@
XXX: Duplicated logic from smy-ref!
-->
<xsl:template mode="dot:defnode" priority="9" match="
<template mode="dot:defnode" priority="9" match="
preproc:sym[
@type='const'
or @type='map' or @type='retmap'
@ -56,7 +54,7 @@
or @preproc:generated='true'
]
">
</xsl:template>
</template>
<!--
@ -65,13 +63,13 @@
Symbols with defined parents are generated as part of that parent and will
therefore be treated as a single unit.
-->
<xsl:template match="preproc:sym[ @parent ]" mode="dot:defnode" priority="7">
<xsl:variable name="parent" select="@parent" />
<template match="preproc:sym[ @parent ]" mode="dot:defnode" priority="7">
<variable name="parent" select="@parent" />
<xsl:apply-templates select="
<apply-templates select="
parent::preproc:symtable/preproc:sym[ @name=$parent ]
" />
</xsl:template>
</template>
<!--
@ -80,44 +78,44 @@
If no attributes are generated, then the node will be entirely omitted (it'll
be created automatically by DOT when referenced).
-->
<xsl:template match="preproc:sym" mode="dot:defnode" priority="1">
<xsl:variable name="attr">
<xsl:call-template name="dot:render-attr-list">
<xsl:with-param name="attr-list">
<template match="preproc:sym" mode="dot:defnode" priority="1">
<variable name="attr">
<call-template name="dot:render-attr-list">
<with-param name="attr-list">
<!-- this kluge exists because of XSLT limitiations and the confusion
that would result (in this particular situation) from
xsl:apply-imports
apply-imports
-->
<xsl:apply-templates select="." mode="dot:defnode-attr" />
<xsl:apply-templates select="." mode="dot:attr-extern" />
<xsl:apply-templates select="." mode="dot:attr-color" />
<xsl:apply-templates select="." mode="dot:attr-shape" />
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<apply-templates select="." mode="dot:defnode-attr" />
<apply-templates select="." mode="dot:attr-extern" />
<apply-templates select="." mode="dot:attr-color" />
<apply-templates select="." mode="dot:attr-shape" />
</with-param>
</call-template>
</variable>
<xsl:if test="not( $attr = '' )">
<xsl:text>"</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>" [</xsl:text>
<xsl:value-of select="$attr" />
<if test="not( $attr = '' )">
<text>"</text>
<value-of select="@name" />
<text>" [</text>
<value-of select="$attr" />
<xsl:if test="@src and not( @src='' )">
<xsl:if test="$attr">
<xsl:text>,</xsl:text>
</xsl:if>
<if test="@src and not( @src='' )">
<if test="$attr">
<text>,</text>
</if>
<!-- link to other packages in the graph for navigation -->
<xsl:text>href="</xsl:text>
<xsl:value-of select="concat( @src, '.svg' )" />
<xsl:text>"</xsl:text>
</xsl:if>
<xsl:text>];</xsl:text>
<text>href="</text>
<value-of select="concat( @src, '.svg' )" />
<text>"</text>
</if>
<text>];</text>
<xsl:value-of select="$dot:nl" />
</xsl:if>
</xsl:template>
<value-of select="$dot:nl" />
</if>
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -20,14 +20,12 @@
along with this program. If not, see
<http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet version="2.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:l="http://www.lovullo.com/rater/linker"
xmlns:dot="http://www.lovullo.com/calc/dot"
xmlns:preproc="http://www.lovullo.com/rater/preproc">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:l="http://www.lovullo.com/rater/linker"
xmlns:dot="http://www.lovullo.com/calc/dot"
xmlns:preproc="http://www.lovullo.com/rater/preproc">
<!--
@ -45,22 +43,22 @@
Lord Jesus it's a fire.
-->
<xsl:template match="lv:package[ l:dep ]" priority="9">
<xsl:apply-templates select="." mode="dot:head" />
<template match="lv:package[ l:dep ]" priority="9">
<apply-templates select="." mode="dot:head" />
<!-- we know that all symbols in the linker symbol table are used, so we can
immediately generate the node definitions -->
<xsl:apply-templates mode="dot:defnode"
<apply-templates mode="dot:defnode"
select="l:dep/preproc:sym" />
<!-- outputting the dependencies of those symbols is more involved and
requires processing data from each object file -->
<xsl:apply-templates select="l:dep/preproc:sym" mode="dot:ldep-sym-deps">
<xsl:with-param name="exec-name" select="concat( @__rootpath, @name )" />
</xsl:apply-templates>
<apply-templates select="l:dep/preproc:sym" mode="dot:ldep-sym-deps">
<with-param name="exec-name" select="concat( @__rootpath, @name )" />
</apply-templates>
<xsl:apply-templates select="." mode="dot:tail" />
</xsl:template>
<apply-templates select="." mode="dot:tail" />
</template>
<!--
@ -70,9 +68,9 @@
be a single unit. Since the parent will also be in the symbol table (it is,
after all, a dependency), we don't have to worry about these at all.
-->
<xsl:template match="preproc:sym[ @parent ]" mode="dot:ldep-sym-deps" priority="5">
<template match="preproc:sym[ @parent ]" mode="dot:ldep-sym-deps" priority="5">
<!-- ignore -->
</xsl:template>
</template>
<!--
@ -81,36 +79,36 @@
The linker symbol table only stores a flattened symbol list; to get the
symbol's dependencies, we must consult the source object file.
-->
<xsl:template match="preproc:sym" mode="dot:ldep-sym-deps" priority="1">
<xsl:param name="exec-name" />
<template match="preproc:sym" mode="dot:ldep-sym-deps" priority="1">
<param name="exec-name" />
<xsl:variable name="name" select="@name" />
<variable name="name" select="@name" />
<!-- empty @src implies program package -->
<xsl:variable name="pkg" select="
<variable name="pkg" select="
if ( @src and not( @src='' ) ) then
document( concat( @src, '.xmlo' ), / )/lv:package
else
document( concat( $exec-name, '.xmlo' ), / )/lv:package
" />
<xsl:variable name="sym-dep" select="
<variable name="sym-dep" select="
$pkg/preproc:sym-deps/preproc:sym-dep[
@name=$name
]
" />
<xsl:if test="not( $sym-dep )">
<xsl:message terminate="yes">
<xsl:text>error: cannot locate symbol dependencies for `</xsl:text>
<xsl:value-of select="concat( @src, '/', @name )" />
<xsl:text>'</xsl:text>
</xsl:message>
</xsl:if>
<if test="not( $sym-dep )">
<message terminate="yes">
<text>error: cannot locate symbol dependencies for `</text>
<value-of select="concat( @src, '/', @name )" />
<text>'</text>
</message>
</if>
<xsl:apply-templates select="$sym-dep" mode="dot:depout" />
</xsl:template>
<apply-templates select="$sym-dep" mode="dot:depout" />
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -25,22 +25,21 @@
TODO: dependency symbols should not duplicate metadata
-->
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:lvm="http://www.lovullo.com/rater/map"
xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:c="http://www.lovullo.com/calc"
xmlns:ext="http://www.lovullo.com/ext"
xmlns:util="http://www.lovullo.com/util"
exclude-result-prefixes="ext util xs">
<stylesheet version="1.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:lvm="http://www.lovullo.com/rater/map"
xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:c="http://www.lovullo.com/calc"
xmlns:ext="http://www.lovullo.com/ext"
xmlns:util="http://www.lovullo.com/util"
exclude-result-prefixes="ext util xs">
<xsl:variable name="tex-defaults">
<variable name="tex-defaults">
<preproc:syms>
<preproc:sym value="\alpha" vec="A" />
<preproc:sym value="\beta" vec="B" />
@ -49,127 +48,127 @@
<preproc:sym value="y" vec="Y" />
<preproc:sym value="z" vec="Z" />
</preproc:syms>
</xsl:variable>
</variable>
<!-- simply allows invoking the template with dynamic input -->
<xsl:template name="preproc:gen-deps">
<xsl:param name="pkg" as="element( lv:package )" />
<xsl:apply-templates select="$pkg" mode="preproc:gen-deps" />
</xsl:template>
<template name="preproc:gen-deps">
<param name="pkg" as="element( lv:package )" />
<apply-templates select="$pkg" mode="preproc:gen-deps" />
</template>
<xsl:template match="*" mode="preproc:gen-deps">
<xsl:copy>
<xsl:sequence select="@*" />
<template match="*" mode="preproc:gen-deps">
<copy>
<sequence select="@*" />
<xsl:message>
<xsl:text>[depgen] *determining symbol dependencies...</xsl:text>
</xsl:message>
<message>
<text>[depgen] *determining symbol dependencies...</text>
</message>
<xsl:apply-templates select="preproc:symtable" mode="preproc:depgen" />
<apply-templates select="preproc:symtable" mode="preproc:depgen" />
<xsl:sequence select="*" />
</xsl:copy>
</xsl:template>
<sequence select="*" />
</copy>
</template>
<xsl:template match="preproc:symtable" mode="preproc:depgen" priority="9">
<xsl:variable name="symtable" select="." />
<template match="preproc:symtable" mode="preproc:depgen" priority="9">
<variable name="symtable" select="." />
<xsl:variable name="symtable-map" as="map( xs:string, element( preproc:sym ) )"
<variable name="symtable-map" as="map( xs:string, element( preproc:sym ) )"
select="map:merge( for $sym in $symtable/preproc:sym
return map{ string( $sym/@name ) : $sym } )" />
<preproc:sym-deps>
<xsl:variable name="deps" as="element( preproc:sym-dep )*">
<xsl:apply-templates mode="preproc:depgen"
<variable name="deps" as="element( preproc:sym-dep )*">
<apply-templates mode="preproc:depgen"
select="root(.)/lv:*,
root(.)/lvm:*">
<xsl:with-param name="symtable-map" select="$symtable-map"
<with-param name="symtable-map" select="$symtable-map"
tunnel="yes" />
</xsl:apply-templates>
</xsl:variable>
</apply-templates>
</variable>
<!-- preproc:sym-deps may be nested -->
<xsl:for-each select="$deps, $deps//preproc:sym-dep">
<xsl:variable name="sym-name" as="xs:string"
<for-each select="$deps, $deps//preproc:sym-dep">
<variable name="sym-name" as="xs:string"
select="@name" />
<xsl:variable name="cursym" as="element( preproc:sym )?"
<variable name="cursym" as="element( preproc:sym )?"
select="$symtable-map( $sym-name )" />
<xsl:if test="not( $cursym )">
<xsl:message select="." />
<xsl:message terminate="yes"
<if test="not( $cursym )">
<message select="." />
<message terminate="yes"
select="concat( 'internal error: ',
'cannot find symbol in symbol table: ',
'`', $sym-name, '''' )" />
</xsl:if>
</if>
<!-- do not output duplicates (we used to not output references
to ourselves, but we are now retaining them, since those
data are useful) -->
<xsl:variable name="uniq" select="
<variable name="uniq" select="
preproc:sym-ref[
not( @name=preceding-sibling::preproc:sym-ref/@name )
]
" />
<!-- symbols must not have themselves as their own dependency -->
<xsl:if test="$uniq[ not( $cursym/@allow-circular = 'true' )
<if test="$uniq[ not( $cursym/@allow-circular = 'true' )
and ( @name = $cursym/@name
or @parent = $cursym/@name ) ]">
<xsl:message terminate="yes"
<message terminate="yes"
select="concat( '[preproc] !!! fatal: symbol ',
$cursym/@name,
' references itself ',
'(circular dependency)' )" />
</xsl:if>
</if>
<!-- grab the original source symbol for these references and augment them
with any additional dependency metadata -->
<xsl:variable name="syms-rtf">
<xsl:for-each select="$uniq">
<xsl:variable name="name" select="@name" />
<xsl:variable name="sym" as="element( preproc:sym )?"
<variable name="syms-rtf">
<for-each select="$uniq">
<variable name="name" select="@name" />
<variable name="sym" as="element( preproc:sym )?"
select="$symtable-map( $name )" />
<!-- we should never have this problem. -->
<xsl:if test="not( $sym ) and not( @lax='true' )">
<xsl:message terminate="yes">
<xsl:text>[depgen] internal error: </xsl:text>
<xsl:text>could not locate dependency symbol `</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>' in local symbol table; needed by </xsl:text>
<xsl:value-of select="$cursym/@name" />
</xsl:message>
</xsl:if>
<if test="not( $sym ) and not( @lax='true' )">
<message terminate="yes">
<text>[depgen] internal error: </text>
<text>could not locate dependency symbol `</text>
<value-of select="@name" />
<text>' in local symbol table; needed by </text>
<value-of select="$cursym/@name" />
</message>
</if>
<!-- copy and augment (we set @name because $sym/@name may not exist
if @lax) -->
<preproc:sym name="{@name}">
<xsl:if test="$sym">
<xsl:sequence select="$sym/@*" />
</xsl:if>
<if test="$sym">
<sequence select="$sym/@*" />
</if>
<preproc:meta>
<!-- retain type -->
<xsl:sequence select="$sym/@type" />
<xsl:sequence select="$sym/@dim" />
<sequence select="$sym/@type" />
<sequence select="$sym/@dim" />
<!-- copy any additional metadata -->
<xsl:sequence select="@*[ not( local-name() = 'name' ) ]" />
<sequence select="@*[ not( local-name() = 'name' ) ]" />
</preproc:meta>
</preproc:sym>
</xsl:for-each>
</xsl:variable>
</for-each>
</variable>
<xsl:variable name="syms" select="$syms-rtf/preproc:sym" />
<variable name="syms" select="$syms-rtf/preproc:sym" />
<!-- only applicable if the symbol is @lax and the symbol was not
found in the local symbol table -->
<xsl:variable name="lax" select="
<variable name="lax" select="
$uniq[
@lax='true'
and not( @name=$syms/@name )
@ -179,116 +178,116 @@
<preproc:sym-dep name="{@name}">
<!-- process symbols that have not been found in the local symbol
table (only applicable when cursym is @lax) -->
<xsl:for-each select="$lax">
<for-each select="$lax">
<!-- the @lax flag here is simply to denote that this symbol may not
actually exist and that ignoring the check was explicitly
requested (and not a bug in the depgen process) -->
<preproc:sym-ref name="{@name}" lax="true">
<xsl:sequence select="preproc:meta/@*" />
<sequence select="preproc:meta/@*" />
</preproc:sym-ref>
</xsl:for-each>
</for-each>
<!-- @tex provided an non-empty, or function -->
<xsl:for-each select="
<for-each select="
$syms[
( @tex and not( @tex='' ) )
or @type='func'
]">
<xsl:choose>
<choose>
<!-- even if function, @tex overrides symbol -->
<xsl:when test="@tex and not( @tex='' )">
<when test="@tex and not( @tex='' )">
<preproc:sym-ref tex="{@tex}">
<xsl:sequence select="@*" />
<xsl:sequence select="preproc:meta/@*" />
<sequence select="@*" />
<sequence select="preproc:meta/@*" />
</preproc:sym-ref>
</xsl:when>
</when>
<!-- must be a function; use its name -->
<xsl:otherwise>
<otherwise>
<preproc:sym-ref>
<xsl:sequence select="@*" />
<xsl:sequence select="preproc:meta/@*" />
<sequence select="@*" />
<sequence select="preproc:meta/@*" />
<xsl:attribute name="tex">
<xsl:text>\textrm{</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>}</xsl:text>
</xsl:attribute>
<attribute name="tex">
<text>\textrm{</text>
<value-of select="@name" />
<text>}</text>
</attribute>
</preproc:sym-ref>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</otherwise>
</choose>
</for-each>
<!-- no @tex, @tex empty, no function -->
<xsl:for-each select="
<for-each select="
$syms[
( not( @tex ) or @tex='' )
and not( @type='func' )
]">
<xsl:variable name="name" select="@name" />
<xsl:variable name="sym" select="." />
<variable name="name" select="@name" />
<variable name="sym" select="." />
<preproc:sym-ref>
<!-- minimal attribute copy (avoid data duplication as much as
possible to reduce modification headaches later on) -->
<xsl:sequence select="@name, @parent" />
<xsl:sequence select="preproc:meta/@*" />
<sequence select="@name, @parent" />
<sequence select="preproc:meta/@*" />
<!-- assign a symbol -->
<xsl:variable name="pos" select="position()" />
<xsl:attribute name="tex">
<xsl:variable name="texsym" select="
<variable name="pos" select="position()" />
<attribute name="tex">
<variable name="texsym" select="
$tex-defaults/preproc:syms/preproc:sym[
position() = $pos
]
" />
<xsl:choose>
<xsl:when test="$sym/@tex and not( $sym/@tex='' )">
<xsl:value-of select="$sym/@tex" />
</xsl:when>
<choose>
<when test="$sym/@tex and not( $sym/@tex='' )">
<value-of select="$sym/@tex" />
</when>
<!-- scalar/vector default -->
<xsl:when test="$texsym and number( $sym/@dim ) lt 2">
<xsl:value-of select="$texsym/@value" />
</xsl:when>
<when test="$texsym and number( $sym/@dim ) lt 2">
<value-of select="$texsym/@value" />
</when>
<!-- matrix default -->
<xsl:when test="$texsym">
<xsl:value-of select="$texsym/@vec" />
</xsl:when>
<when test="$texsym">
<value-of select="$texsym/@vec" />
</when>
<!-- no default available; generate one -->
<xsl:otherwise>
<xsl:value-of select="
<otherwise>
<value-of select="
if ( number( $sym/@dim ) lt 2 ) then '\theta'
else '\Theta'
" />
<xsl:text>_{</xsl:text>
<xsl:value-of select="$pos" />
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<text>_{</text>
<value-of select="$pos" />
<text>}</text>
</otherwise>
</choose>
</attribute>
</preproc:sym-ref>
</xsl:for-each>
</for-each>
</preproc:sym-dep>
</xsl:for-each>
</for-each>
</preproc:sym-deps>
</xsl:template>
</template>
<xsl:template mode="preproc:depgen" priority="7"
<template mode="preproc:depgen" priority="7"
match="lv:rate">
<preproc:sym-dep name="{@yields}">
<xsl:apply-templates mode="preproc:depgen" />
<apply-templates mode="preproc:depgen" />
</preproc:sym-dep>
</xsl:template>
</template>
<xsl:template mode="preproc:depgen" priority="7"
<template mode="preproc:depgen" priority="7"
match="c:sum[@generates]
|c:product[@generates]">
<preproc:sym-dep name="{@generates}">
@ -296,251 +295,251 @@
</preproc:sym-dep>
<!-- this may have other rules; see below -->
<xsl:next-match />
</xsl:template>
<next-match />
</template>
<xsl:template mode="preproc:depgen" priority="7"
<template mode="preproc:depgen" priority="7"
match="lv:classify">
<preproc:sym-dep name=":class:{@as}">
<xsl:apply-templates mode="preproc:depgen" />
<apply-templates mode="preproc:depgen" />
</preproc:sym-dep>
<xsl:if test="@yields">
<if test="@yields">
<preproc:sym-dep name="{@yields}">
<preproc:sym-ref name=":class:{@as}" />
</preproc:sym-dep>
</xsl:if>
</xsl:template>
</if>
</template>
<xsl:template mode="preproc:depgen" priority="8"
<template mode="preproc:depgen" priority="8"
match="lv:function/lv:param">
<xsl:variable name="fname" as="xs:string"
<variable name="fname" as="xs:string"
select="parent::lv:function/@name" />
<preproc:sym-dep name=":{$fname}:{@name}">
<preproc:sym-ref name="{$fname}" />
</preproc:sym-dep>
</xsl:template>
</template>
<xsl:template mode="preproc:depgen" priority="7"
<template mode="preproc:depgen" priority="7"
match="lv:param">
<preproc:sym-dep name="{@name}">
<preproc:sym-ref name="{@type}" />
<xsl:apply-templates mode="preproc:depgen" />
<apply-templates mode="preproc:depgen" />
</preproc:sym-dep>
</xsl:template>
</template>
<xsl:template mode="preproc:depgen" priority="7"
<template mode="preproc:depgen" priority="7"
match="lv:function">
<preproc:sym-dep name="{@name}">
<xsl:apply-templates mode="preproc:depgen" />
<apply-templates mode="preproc:depgen" />
</preproc:sym-dep>
</xsl:template>
</template>
<xsl:template mode="preproc:depgen" priority="7"
<template mode="preproc:depgen" priority="7"
match="lv:typedef">
<preproc:sym-dep name="{@name}">
<xsl:apply-templates mode="preproc:depgen" />
<apply-templates mode="preproc:depgen" />
</preproc:sym-dep>
</xsl:template>
</template>
<xsl:template match="lv:template"
<template match="lv:template"
mode="preproc:depgen" priority="8">
<!-- ignore symbols within templates -->
</xsl:template>
</template>
<xsl:template name="preproc:depgen-c-normal" match="c:value-of|c:when" mode="preproc:depgen" priority="5">
<xsl:param name="name" select="@name" />
<xsl:param name="symtable-map" as="map(*)" tunnel="yes" />
<template name="preproc:depgen-c-normal" match="c:value-of|c:when" mode="preproc:depgen" priority="5">
<param name="name" select="@name" />
<param name="symtable-map" as="map(*)" tunnel="yes" />
<xsl:variable name="pkg" as="element( lv:package )"
<variable name="pkg" as="element( lv:package )"
select="root(.)" />
<xsl:variable name="sym" as="element( preproc:sym )?"
<variable name="sym" as="element( preproc:sym )?"
select="$symtable-map( $name )" />
<!-- see if there is a c:let associated with this name -->
<xsl:variable name="let" select="
<variable name="let" select="
ancestor::c:let[ c:values/c:value/@name=$name ]
" />
<xsl:choose>
<choose>
<!-- c:let reference -->
<xsl:when test="$let">
<when test="$let">
<preproc:sym-ref name=":{$let/@name}:{$name}" />
</xsl:when>
</when>
<!-- scalar constant -->
<xsl:when test="( $sym/@type='const' ) and ( $sym/@dim='0' )">
<when test="( $sym/@type='const' ) and ( $sym/@dim='0' )">
<!-- while these are optimized away, they are still useful for evaluating
dependency trees and generating code -->
<preproc:sym-ref name="{$sym/@name}" />
</xsl:when>
</when>
<!-- function param reference -->
<xsl:when test="$name=ancestor::lv:function/lv:param/@name">
<xsl:variable name="fname" as="xs:string"
<when test="$name=ancestor::lv:function/lv:param/@name">
<variable name="fname" as="xs:string"
select="ancestor::lv:function/@name" />
<preproc:sym-ref name=":{$fname}:{$name}"
varname="{$name}"/>
</xsl:when>
</when>
<!-- index reference -->
<xsl:when test="$name=ancestor::c:*[ @of ]/@index" />
<when test="$name=ancestor::c:*[ @of ]/@index" />
<!-- unknown symbol (it is important to do this after the above checks) -->
<xsl:when test="not( $sym )">
<when test="not( $sym )">
<!-- do not terminate; validator can provide additional information -->
<xsl:message>
<xsl:text>[depgen] warning: unknown symbol `</xsl:text>
<xsl:value-of select="$name" />
<xsl:text>'</xsl:text>
</xsl:message>
</xsl:when>
<message>
<text>[depgen] warning: unknown symbol `</text>
<value-of select="$name" />
<text>'</text>
</message>
</when>
<xsl:when test="$sym/@parent">
<when test="$sym/@parent">
<preproc:sym-ref name="{$sym/@name}" parent="{$sym/@parent}" />
</xsl:when>
</when>
<!-- just an average 'ol symbol -->
<xsl:otherwise>
<otherwise>
<preproc:sym-ref name="{$name}" />
</xsl:otherwise>
</xsl:choose>
</otherwise>
</choose>
<xsl:apply-templates mode="preproc:depgen" />
</xsl:template>
<apply-templates mode="preproc:depgen" />
</template>
<xsl:template match="c:sum[@of]|c:product[@of]" mode="preproc:depgen" priority="5">
<template match="c:sum[@of]|c:product[@of]" mode="preproc:depgen" priority="5">
<!-- process using @of -->
<xsl:call-template name="preproc:depgen-c-normal">
<xsl:with-param name="name" select="@of" />
</xsl:call-template>
</xsl:template>
<call-template name="preproc:depgen-c-normal">
<with-param name="name" select="@of" />
</call-template>
</template>
<xsl:template match="c:apply" mode="preproc:depgen" priority="5">
<template match="c:apply" mode="preproc:depgen" priority="5">
<!-- no special treatment yet -->
<xsl:call-template name="preproc:depgen-c-normal" />
</xsl:template>
<call-template name="preproc:depgen-c-normal" />
</template>
<xsl:template match="c:apply/c:arg" mode="preproc:depgen" priority="5">
<template match="c:apply/c:arg" mode="preproc:depgen" priority="5">
<!-- arguments may have calculations, so we must recurse -->
<xsl:apply-templates mode="preproc:depgen" />
</xsl:template>
<apply-templates mode="preproc:depgen" />
</template>
<xsl:template name="preproc:depgen-match">
<xsl:param name="on" select="@on" />
<xsl:param name="symtable-map" as="map(*)" tunnel="yes" />
<template name="preproc:depgen-match">
<param name="on" select="@on" />
<param name="symtable-map" as="map(*)" tunnel="yes" />
<xsl:variable name="class" select="ancestor::lv:classify" />
<xsl:variable name="sym" as="element( preproc:sym )"
<variable name="class" select="ancestor::lv:classify" />
<variable name="sym" as="element( preproc:sym )"
select="$symtable-map( $on )" />
<!-- are we depending on another classification? -->
<xsl:if test="$sym/@type='cgen'">
<xsl:variable name="cname" select="substring-after( $sym/@parent, ':class:' )" />
<if test="$sym/@type='cgen'">
<variable name="cname" select="substring-after( $sym/@parent, ':class:' )" />
<!-- check if one of our dependencies wants to be external to the classifier,
but we're trying to pull them in...tug-of-war -->
<xsl:if test="$sym/@extclass='true' and not( $class/@external='true' )">
<xsl:message terminate="yes">
<xsl:text>[preproc] !!! fatal: internal classification `</xsl:text>
<xsl:value-of select="$class/@as" />
<xsl:text>' cannot pull in external classification `</xsl:text>
<xsl:value-of select="$cname" />
<xsl:text>'</xsl:text>
</xsl:message>
</xsl:if>
</xsl:if>
<if test="$sym/@extclass='true' and not( $class/@external='true' )">
<message terminate="yes">
<text>[preproc] !!! fatal: internal classification `</text>
<value-of select="$class/@as" />
<text>' cannot pull in external classification `</text>
<value-of select="$cname" />
<text>'</text>
</message>
</if>
</if>
<!-- process the @on -->
<xsl:call-template name="preproc:depgen-c-normal">
<xsl:with-param name="name" select="$on" />
</xsl:call-template>
</xsl:template>
<call-template name="preproc:depgen-c-normal">
<with-param name="name" select="$on" />
</call-template>
</template>
<xsl:template match="lv:match[ @value ]" mode="preproc:depgen" priority="5">
<template match="lv:match[ @value ]" mode="preproc:depgen" priority="5">
<!-- process the @value -->
<xsl:call-template name="preproc:depgen-c-normal">
<xsl:with-param name="name" select="@value" />
</xsl:call-template>
<call-template name="preproc:depgen-c-normal">
<with-param name="name" select="@value" />
</call-template>
<xsl:call-template name="preproc:depgen-match" />
</xsl:template>
<call-template name="preproc:depgen-match" />
</template>
<xsl:template match="lv:match[ @anyOf ]" mode="preproc:depgen" priority="6">
<template match="lv:match[ @anyOf ]" mode="preproc:depgen" priority="6">
<!-- process the "normal" match -->
<xsl:call-template name="preproc:depgen-match" />
<call-template name="preproc:depgen-match" />
<!-- we depend on the type -->
<preproc:sym-ref name="{@anyOf}" />
<xsl:call-template name="preproc:depgen-match" />
</xsl:template>
<call-template name="preproc:depgen-match" />
</template>
<xsl:template match="lv:match[ @pattern ]" mode="preproc:depgen" priority="5">
<template match="lv:match[ @pattern ]" mode="preproc:depgen" priority="5">
<!-- there are no pattern dependencies; process @on -->
<xsl:call-template name="preproc:depgen-match" />
</xsl:template>
<call-template name="preproc:depgen-match" />
</template>
<!-- match on calculated value -->
<xsl:template match="lv:match[ c:* ]" mode="preproc:depgen" priority="6">
<template match="lv:match[ c:* ]" mode="preproc:depgen" priority="6">
<!-- process the "normal" match -->
<xsl:call-template name="preproc:depgen-match" />
<call-template name="preproc:depgen-match" />
<!-- process the calculation dependencies -->
<xsl:apply-templates select="c:*" mode="preproc:depgen" />
</xsl:template>
<apply-templates select="c:*" mode="preproc:depgen" />
</template>
<xsl:template match="lv:template" mode="preproc:depgen" priority="9">
<template match="lv:template" mode="preproc:depgen" priority="9">
<!-- don't generate dependencies for templates (which may have been
generated inline in unexpected places) -->
</xsl:template>
</template>
<xsl:template match="lv:union" mode="preproc:depgen" priority="5">
<xsl:for-each select="lv:typedef">
<template match="lv:union" mode="preproc:depgen" priority="5">
<for-each select="lv:typedef">
<preproc:sym-ref name="{@name}" />
</xsl:for-each>
</for-each>
<!-- we still need to process the typedefs independently -->
<xsl:apply-templates mode="preproc:depgen" />
</xsl:template>
<apply-templates mode="preproc:depgen" />
</template>
<xsl:template match="lv:enum/lv:item" mode="preproc:depgen" priority="5">
<template match="lv:enum/lv:item" mode="preproc:depgen" priority="5">
<preproc:sym-ref name="{@name}" />
</xsl:template>
</template>
<!-- @class deps -->
<xsl:template match="lv:class" mode="preproc:depgen" priority="5">
<template match="lv:class" mode="preproc:depgen" priority="5">
<preproc:sym-ref name=":class:{@ref}" class-no="{@no}" />
</xsl:template>
</template>
<xsl:template match="c:*|lv:*" mode="preproc:depgen" priority="3">
<template match="c:*|lv:*" mode="preproc:depgen" priority="3">
<!-- ignore -->
<xsl:apply-templates mode="preproc:depgen" />
</xsl:template>
<apply-templates mode="preproc:depgen" />
</template>
<xsl:template match="node()" mode="preproc:depgen" priority="1">
<template match="node()" mode="preproc:depgen" priority="1">
<!-- skip -->
</xsl:template>
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -25,9 +25,8 @@
additional features that are defined/abstracted within this file; every
template that is intended for use with dslc should include this.
-->
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform">
<!--
Absolute path to root of TAME
@ -37,7 +36,7 @@
that a particular line of code is executing in). Using absolute paths
mitigates that definitively.
-->
<xsl:param name="__path-root" />
<param name="__path-root" />
<!--
@ -61,7 +60,7 @@
Consequently, no two files are able to have the same __srcpkg string; this
value may therefore be used for disambiguation.
-->
<xsl:param name="__srcpkg" />
<param name="__srcpkg" />
<!--
@ -70,7 +69,7 @@
The project root is determined entirely by __srcpath by repeating the string
"../" for the number of occurrances of "/".
-->
<xsl:param name="__relroot" />
<param name="__relroot" />
<!--
@ -79,7 +78,7 @@
XSLT is deterministic and does not offer support for generating random values;
its generate-id() function is not sufficient for cross-package generation.
-->
<xsl:param name="__rseed" />
<param name="__rseed" />
<!--
@ -89,7 +88,7 @@
important for `document' function calls, which use nodes as a reference
point for resolving relative paths.
-->
<xsl:variable name="__entry-root" select="/" />
<variable name="__entry-root" select="/" />
@ -100,19 +99,19 @@
with the leading path delimiter stripped; otherwise, it will be echoed
as-is.
-->
<xsl:template name="__apply-relroot">
<xsl:param name="path" />
<template name="__apply-relroot">
<param name="path" />
<xsl:choose>
<xsl:when test="starts-with( $path, '/' )">
<xsl:value-of select="$__relroot" />
<xsl:value-of select="substring-after( $path, '/' )" />
</xsl:when>
<choose>
<when test="starts-with( $path, '/' )">
<value-of select="$__relroot" />
<value-of select="substring-after( $path, '/' )" />
</when>
<xsl:otherwise>
<xsl:value-of select="$path" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<otherwise>
<value-of select="$path" />
</otherwise>
</choose>
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -23,13 +23,11 @@
The ultime goal is to implement typedefs as macros and move to a generic
domain system that is much more powerful.
-->
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc">
<!--
@ -37,9 +35,9 @@
TODO: We still want a domain generated.
-->
<xsl:template match="lv:typedef[ lv:base-type ]"
<template match="lv:typedef[ lv:base-type ]"
mode="preproc:mkdomain" priority="9">
</xsl:template>
</template>
<!--
@ -49,7 +47,7 @@
domain containing the union of all the subdomain elements. This is
intended to improve lookup performance and reduce algorithmic complexity.
-->
<xsl:template match="
<template match="
lv:typedef[
lv:union
]
@ -57,39 +55,39 @@
mode="preproc:mkdomain" priority="5">
<!-- generate all contained domains -->
<xsl:variable name="subdomains">
<xsl:variable name="union-types" select="
<variable name="subdomains">
<variable name="union-types" select="
lv:union/lv:typedef" />
<!-- if a union is empty, then somebody probably made an oopsie or wrote
a defective/deficient template -->
<xsl:if test="count( $union-types ) = 0">
<xsl:message>
<xsl:text>warning: union `</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>' has no subdomains; something is probably wrong</xsl:text>
</xsl:message>
</xsl:if>
<if test="count( $union-types ) = 0">
<message>
<text>warning: union `</text>
<value-of select="@name" />
<text>' has no subdomains; something is probably wrong</text>
</message>
</if>
<xsl:apply-templates mode="preproc:mkdomain"
<apply-templates mode="preproc:mkdomain"
select="$union-types" />
</xsl:variable>
</variable>
<!-- provide a denormalized domain for performance and to reduce
algorithmic complexity-->
<xsl:call-template name="preproc:mkdomain-union">
<xsl:with-param name="name" select="@name" />
<xsl:with-param name="subdomains" select="$subdomains" />
</xsl:call-template>
<call-template name="preproc:mkdomain-union">
<with-param name="name" select="@name" />
<with-param name="subdomains" select="$subdomains" />
</call-template>
<xsl:copy-of select="$subdomains" />
</xsl:template>
<copy-of select="$subdomains" />
</template>
<!--
Enumerated typedefs
-->
<xsl:template match="
<template match="
lv:typedef[
lv:enum
]
@ -97,22 +95,22 @@
mode="preproc:mkdomain" priority="5">
<lv:domain name="{@name}">
<xsl:variable name="items" select="lv:enum/lv:item" />
<variable name="items" select="lv:enum/lv:item" />
<!-- if a typedef is empty, then somebody probably made an oopsie or
wrote a defective/deficient template -->
<xsl:if test="count( $items ) = 0">
<xsl:message>
<xsl:text>warning: typedef `</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>' is empty; something is probably wrong</xsl:text>
</xsl:message>
</xsl:if>
<if test="count( $items ) = 0">
<message>
<text>warning: typedef `</text>
<value-of select="@name" />
<text>' is empty; something is probably wrong</text>
</message>
</if>
<xsl:apply-templates mode="preproc:mkdomain"
<apply-templates mode="preproc:mkdomain"
select="$items" />
</lv:domain>
</xsl:template>
</template>
<!--
@ -120,19 +118,19 @@
For the time being at least.
-->
<xsl:template match="
<template match="
lv:typedef[
lv:enum/lv:item[ @value ]
and lv:enum/lv:item[ not( @value ) ]
]"
mode="preproc:mkdomain" priority="2">
<xsl:message terminate="yes">
<xsl:text>error: typedef `</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>' must not contain both @value and non-@value items</xsl:text>
</xsl:message>
</xsl:template>
<message terminate="yes">
<text>error: typedef `</text>
<value-of select="@name" />
<text>' must not contain both @value and non-@value items</text>
</message>
</template>
<!--
@ -141,15 +139,15 @@
Well, we know that it is a typedef, but its format is unknown. This
wouldn't be surprising, since it is presently very limited.
-->
<xsl:template match="lv:typedef"
<template match="lv:typedef"
mode="preproc:mkdomain" priority="2">
<xsl:message terminate="yes">
<xsl:text>error: malformed typedef `</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>'</xsl:text>
</xsl:message>
</xsl:template>
<message terminate="yes">
<text>error: malformed typedef `</text>
<value-of select="@name" />
<text>'</text>
</message>
</template>
@ -161,25 +159,25 @@
be notified of this fact, as this allows domains to overlap in order to
interpret the same data in different manners.
-->
<xsl:template name="preproc:mkdomain-union">
<xsl:param name="name" />
<xsl:param name="subdomains" />
<template name="preproc:mkdomain-union">
<param name="name" />
<param name="subdomains" />
<xsl:variable name="union">
<variable name="union">
<preproc:elements>
<xsl:copy-of select="$subdomains/lv:domain/lv:element" />
<copy-of select="$subdomains/lv:domain/lv:element" />
</preproc:elements>
</xsl:variable>
</variable>
<!-- remove duplicate values (yes, this will take the first description if
there are duplicates; whatever, for now) -->
<lv:domain name="{@name}">
<xsl:copy-of select="
<copy-of select="
$union/preproc:elements/lv:element[
not( @value = preceding-sibling::lv:element/@value )
]" />
</lv:domain>
</xsl:template>
</template>
<!--
@ -188,19 +186,19 @@
Note the above validation that ensures that our value generation is
sufficient.
-->
<xsl:template match="lv:enum/lv:item[ not( @value ) ]"
<template match="lv:enum/lv:item[ not( @value ) ]"
mode="preproc:mkdomain" priority="5">
<xsl:variable name="augmented">
<xsl:copy>
<xsl:attribute name="value" select="position()" />
</xsl:copy>
</xsl:variable>
<variable name="augmented">
<copy>
<attribute name="value" select="position()" />
</copy>
</variable>
<!-- re-process using an augmented item with the value calculated -->
<xsl:apply-templates mode="preproc:mkdomain"
<apply-templates mode="preproc:mkdomain"
select="$augmented/lv:item" />
</xsl:template>
</template>
<!--
@ -212,32 +210,32 @@
We do not care about the name, since we use that to generate constants
elsewhere.
-->
<xsl:template match="lv:item"
<template match="lv:item"
mode="preproc:mkdomain" priority="4">
<!-- previous templates should have prevented this, but just in case -->
<xsl:if test="not( @value )">
<xsl:message terminate="yes">
<xsl:text>internal error: preproc:mkdomain on non-value item: </xsl:text>
<xsl:copy-of select="." />
</xsl:message>
</xsl:if>
<if test="not( @value )">
<message terminate="yes">
<text>internal error: preproc:mkdomain on non-value item: </text>
<copy-of select="." />
</message>
</if>
<lv:element value="{@value}" desc="{@desc}" />
</xsl:template>
</template>
<!--
Unexpected node; terminate
-->
<xsl:template match="*"
<template match="*"
mode="preproc:mkdomain" priority="1">
<xsl:message terminate="yes">
<xsl:text>internal error: unknown domain source: </xsl:text>
<xsl:copy-of select="." />
</xsl:message>
</xsl:template>
<message terminate="yes">
<text>internal error: unknown domain source: </text>
<copy-of select="." />
</message>
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -28,53 +28,52 @@
The goal of the eligibility classification is to create a cascading failure in
the event of bad data.
-->
<xsl:stylesheet version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc">
<!--
Trigger eligibility class generation
-->
<xsl:template match="lv:package[ not( @preproc:elig-class-yields ) ]"
<template match="lv:package[ not( @preproc:elig-class-yields ) ]"
as="element( lv:package )"
priority="5"
mode="preproc:expand-elig-class">
<xsl:param name="orig-root" as="element( lv:package )" />
<param name="orig-root" as="element( lv:package )" />
<xsl:variable name="elig-class" as="element( lv:classify )">
<xsl:apply-templates select="." mode="preproc:gen-elig-class">
<xsl:with-param name="orig-root" select="$orig-root" />
</xsl:apply-templates>
</xsl:variable>
<variable name="elig-class" as="element( lv:classify )">
<apply-templates select="." mode="preproc:gen-elig-class">
<with-param name="orig-root" select="$orig-root" />
</apply-templates>
</variable>
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<xsl:attribute name="preproc:elig-class"
<attribute name="preproc:elig-class"
select="$elig-class/@as" />
<xsl:attribute name="preproc:elig-class-yields"
<attribute name="preproc:elig-class-yields"
select="$elig-class/@yields" />
<xsl:sequence select="$elig-class" />
<xsl:apply-templates mode="preproc:macros" />
</xsl:copy>
</xsl:template>
<sequence select="$elig-class" />
<apply-templates mode="preproc:macros" />
</copy>
</template>
<xsl:template match="lv:package" as="element( lv:package )"
<template match="lv:package" as="element( lv:package )"
priority="1"
mode="preproc:expand-elig-class">
<!-- already processed -->
<xsl:sequence select="." />
</xsl:template>
<sequence select="." />
</template>
@ -84,17 +83,17 @@
The eligibility classification will yield a scalar.
-->
<xsl:template match="lv:package" as="element( lv:classify )"
<template match="lv:package" as="element( lv:classify )"
mode="preproc:gen-elig-class">
<xsl:param name="orig-root" as="element( lv:package )" />
<param name="orig-root" as="element( lv:package )" />
<xsl:message>[preproc/eligclass] generating eligibility class</xsl:message>
<message>[preproc/eligclass] generating eligibility class</message>
<!-- class-ify name -->
<xsl:variable name="as" as="xs:string"
<variable name="as" as="xs:string"
select="preproc:gen-elig-class-name( @name )" />
<xsl:variable name="yields" as="xs:string"
<variable name="yields" as="xs:string"
select="preproc:gen-elig-class-yields( @name )" />
@ -102,33 +101,33 @@
desc="{@name} package is eligible">
<!-- each of our imported packages' elig classes must be truthful -->
<xsl:apply-templates mode="preproc:gen-elig-class-matches"
<apply-templates mode="preproc:gen-elig-class-matches"
select="lv:import">
<xsl:with-param name="orig-root" select="$orig-root" />
</xsl:apply-templates>
<with-param name="orig-root" select="$orig-root" />
</apply-templates>
<!-- param values must be within their domain -->
<!-- XXX: does not work when param is undefined due to no mapping
<xsl:apply-templates mode="preproc:gen-elig-param-class"
<apply-templates mode="preproc:gen-elig-param-class"
select="lv:param" />
-->
<!-- terminating classifications must not have matched -->
<xsl:apply-templates mode="preproc:gen-elig-term-class"
<apply-templates mode="preproc:gen-elig-term-class"
select="preproc:symtable/preproc:sym[ @type='class' ]" />
</lv:classify>
</xsl:template>
</template>
<!--
Generate eligibility classification name for package
-->
<xsl:function name="preproc:gen-elig-class-name"
<function name="preproc:gen-elig-class-name"
as="xs:string">
<xsl:param name="name" />
<param name="name" />
<xsl:sequence select="
<sequence select="
concat( '--elig-',
translate(
translate( $name, '.', '' ),
@ -136,23 +135,23 @@
)
)
" />
</xsl:function>
</function>
<!--
Generate eligibility result scalar name for package
-->
<xsl:function name="preproc:gen-elig-class-yields"
<function name="preproc:gen-elig-class-yields"
as="xs:string">
<xsl:param name="name" />
<param name="name" />
<xsl:sequence select="
<sequence select="
concat(
'isElig',
translate(
translate( $name, '.', '' ),
'/-', '' ) )" />
</xsl:function>
</function>
<!--
@ -160,60 +159,60 @@
For each imported package, its eligibility classification must be true.
-->
<xsl:template match="lv:import[ @package ]"
<template match="lv:import[ @package ]"
as="element( lv:match )?"
priority="5"
mode="preproc:gen-elig-class-matches">
<xsl:param name="orig-root" as="element( lv:package )" />
<param name="orig-root" as="element( lv:package )" />
<!-- FIXME: path may not yet be resolved due to preprocessing order -->
<xsl:variable name="pkg-path" as="xs:string">
<xsl:call-template name="__apply-relroot">
<xsl:with-param name="path" select="@package" />
</xsl:call-template>
</xsl:variable>
<variable name="pkg-path" as="xs:string">
<call-template name="__apply-relroot">
<with-param name="path" select="@package" />
</call-template>
</variable>
<xsl:variable name="pkg" as="element( lv:package )"
<variable name="pkg" as="element( lv:package )"
select="document( concat( $pkg-path, '.xmlo' ),
$__entry-root )
/lv:package" />
<xsl:if test="not( $pkg )">
<xsl:message terminate="yes">
<xsl:text>[preproc/eligclass] error: could not load `</xsl:text>
<xsl:value-of select="$pkg-path" />
<xsl:text>' object file</xsl:text>
</xsl:message>
</xsl:if>
<if test="not( $pkg )">
<message terminate="yes">
<text>[preproc/eligclass] error: could not load `</text>
<value-of select="$pkg-path" />
<text>' object file</text>
</message>
</if>
<xsl:variable name="chk" as="xs:string?"
<variable name="chk" as="xs:string?"
select="$pkg/@preproc:elig-class-yields" />
<xsl:choose>
<xsl:when test="not( $chk ) or ( $chk = '' )">
<choose>
<when test="not( $chk ) or ( $chk = '' )">
<!-- TODO: make this an error once we make maps part of the
conventional build process -->
<xsl:message>
<xsl:text>[preproc/eligclass] internal: empty eligibility </xsl:text>
<xsl:text>class for `</xsl:text>
<xsl:value-of select="$pkg/@name" />
<xsl:text>'; skipping</xsl:text>
</xsl:message>
</xsl:when>
<message>
<text>[preproc/eligclass] internal: empty eligibility </text>
<text>class for `</text>
<value-of select="$pkg/@name" />
<text>'; skipping</text>
</message>
</when>
<xsl:otherwise>
<otherwise>
<!-- use eligibility class as stated by the package -->
<lv:match on="{$chk}" value="TRUE" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</otherwise>
</choose>
</template>
<xsl:template match="lv:import" priority="1"
<template match="lv:import" priority="1"
mode="preproc:gen-elig-class-matches">
<!-- do nothing -->
</xsl:template>
</template>
<!--
@ -221,7 +220,7 @@
This is a trivial operation.
-->
<xsl:template match="lv:param"
<template match="lv:param"
as="element( lv:any )"
mode="preproc:gen-elig-param-class" priority="5">
@ -229,11 +228,11 @@
<lv:match on="{@name}" anyOf="{@type}" />
<!-- TODO: defaults should always be within the domain! -->
<xsl:if test="@default">
<if test="@default">
<lv:match on="{@name}" anyOf="empty" />
</xsl:if>
</if>
</lv:any>
</xsl:template>
</template>
@ -248,7 +247,7 @@
classification marked as external to the classifier. There may or may not
be something we want to do about this in the future.
-->
<xsl:template match="preproc:sym[
<template match="preproc:sym[
not( @src )
and not( @pollute='true' )
and @type='class'
@ -260,14 +259,14 @@
mode="preproc:gen-elig-term-class">
<lv:match on="{@yields}" value="FALSE" />
</xsl:template>
</template>
<xsl:template match="preproc:sym" priority="1"
<template match="preproc:sym" priority="1"
mode="preproc:gen-elig-term-class">
<!-- do nothing -->
</xsl:template>
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -23,65 +23,63 @@
This process is responsible for expanding shorthand and various other data
into a consistent format for the compiler and other processes.
-->
<xsl:stylesheet
version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:c="http://www.lovullo.com/calc"
xmlns:w="http://www.lovullo.com/rater/worksheet">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:c="http://www.lovullo.com/calc"
xmlns:w="http://www.lovullo.com/rater/worksheet">
<xsl:include href="domain.xsl" />
<include href="domain.xsl" />
<xsl:template match="lv:package[ not( @preproc:name ) ]"
<template match="lv:package[ not( @preproc:name ) ]"
mode="preproc:expand" priority="5"
as="element( lv:package )">
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<!-- generate name from source package identifier -->
<xsl:attribute name="name" select="$__srcpkg" />
<attribute name="name" select="$__srcpkg" />
<!-- relative path to root src directory (for resolving absolute include
paths) -->
<xsl:attribute name="__rootpath" select="$__relroot" />
<attribute name="__rootpath" select="$__relroot" />
<!-- TODO: temporary; remove -->
<xsl:attribute name="preproc:name" select="$__srcpkg" />
<attribute name="preproc:name" select="$__srcpkg" />
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:expand" />
</copy>
</template>
<xsl:template match="*" mode="preproc:expand" priority="1">
<xsl:copy>
<xsl:sequence select="@*" />
<template match="*" mode="preproc:expand" priority="1">
<copy>
<sequence select="@*" />
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:expand" />
</copy>
</template>
<!-- imports relative to project root -->
<xsl:template match="lv:import[ starts-with( @package, '/' ) ]" mode="preproc:expand" priority="5">
<xsl:copy>
<xsl:sequence select="@*" />
<template match="lv:import[ starts-with( @package, '/' ) ]" mode="preproc:expand" priority="5">
<copy>
<sequence select="@*" />
<!-- resolve path into path relative to project root -->
<xsl:attribute name="package">
<xsl:call-template name="__apply-relroot">
<xsl:with-param name="path" select="@package" />
</xsl:call-template>
</xsl:attribute>
</xsl:copy>
</xsl:template>
<attribute name="package">
<call-template name="__apply-relroot">
<with-param name="path" select="@package" />
</call-template>
</attribute>
</copy>
</template>
<!--
@ -89,90 +87,90 @@
Eventually, the typedefs will be converted into templates and removed entirely.
-->
<xsl:template match="lv:typedef"
<template match="lv:typedef"
mode="preproc:expand" priority="5">
<xsl:apply-templates select="." mode="preproc:mkdomain" />
<apply-templates select="." mode="preproc:mkdomain" />
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<copy>
<sequence select="@*" />
<apply-templates mode="preproc:expand" />
</copy>
</template>
<!--
Infer primitive type if not provided.
-->
<xsl:template mode="preproc:expand"
<template mode="preproc:expand"
match="c:const[ not( @type ) ]
|lv:const[ not( @type ) ]"
priority="5">
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<xsl:attribute name="type"
<attribute name="type"
select="if ( substring-before( @value, '.' ) ) then
'float'
else
'integer'" />
<xsl:sequence select="*" />
</xsl:copy>
</xsl:template>
<sequence select="*" />
</copy>
</template>
<!--
Translate dimension aliases (e.g. scaler, vector, matrix) into respective
numeric representations.
-->
<xsl:template mode="preproc:expand" priority="8"
<template mode="preproc:expand" priority="8"
match="c:*[ @dim
and not( string( @dim ) castable as xs:integer ) ]">
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<!-- replace dim with numeric -->
<xsl:attribute name="dim">
<xsl:choose>
<xsl:when test="@dim = 'scaler' or @dim = ''">
<xsl:sequence select="0" />
</xsl:when>
<attribute name="dim">
<choose>
<when test="@dim = 'scaler' or @dim = ''">
<sequence select="0" />
</when>
<xsl:when test="@dim = 'vector'">
<xsl:sequence select="1" />
</xsl:when>
<when test="@dim = 'vector'">
<sequence select="1" />
</when>
<xsl:when test="@dim = 'matrix'">
<xsl:sequence select="2" />
</xsl:when>
<when test="@dim = 'matrix'">
<sequence select="2" />
</when>
<xsl:otherwise>
<xsl:message terminate="yes"
<otherwise>
<message terminate="yes"
select="concat(
'!!! [preproc] error: ',
'unknown dimension alias ''',
@dim, '''' )" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</otherwise>
</choose>
</attribute>
<xsl:apply-templates select="node()" mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates select="node()" mode="preproc:expand" />
</copy>
</template>
<!--
Give let's a name so that they may be easily referenced uniquely
-->
<xsl:template match="c:let[ not( @name ) ]" mode="preproc:expand" priority="5">
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:attribute name="name" select="generate-id(.)" />
<template match="c:let[ not( @name ) ]" mode="preproc:expand" priority="5">
<copy>
<sequence select="@*" />
<attribute name="name" select="generate-id(.)" />
<xsl:apply-templates select="*" mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates select="*" mode="preproc:expand" />
</copy>
</template>
<!--
@ -183,16 +181,16 @@
TODO: play well with others; if we change the priority back to 5, we introduce
match ambiguities
-->
<xsl:template match="c:let/c:values/c:value/c:*[1][ not( @label ) ]" mode="preproc:expand" priority="4">
<xsl:copy>
<xsl:sequence select="@*" />
<template match="c:let/c:values/c:value/c:*[1][ not( @label ) ]" mode="preproc:expand" priority="4">
<copy>
<sequence select="@*" />
<!-- default the label to the description of the parent c:value -->
<xsl:attribute name="label" select="../@desc" />
<attribute name="label" select="../@desc" />
<xsl:apply-templates select="*" mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates select="*" mode="preproc:expand" />
</copy>
</template>
<!--
@ -201,31 +199,31 @@
Note: we check for any children because we may have things like
template applications that we do not want wiped out.
-->
<xsl:template match="c:when[ not( * ) ]" mode="preproc:expand" priority="5">
<xsl:copy>
<xsl:sequence select="@*" />
<template match="c:when[ not( * ) ]" mode="preproc:expand" priority="5">
<copy>
<sequence select="@*" />
<c:gt>
<c:value-of name="FALSE" />
</c:gt>
</xsl:copy>
</xsl:template>
</copy>
</template>
<!--
c:when with multiple children
-->
<xsl:template match="c:when[ count( c:* ) gt 1 ]" mode="preproc:expand" priority="5">
<xsl:variable name="when" select="." />
<template match="c:when[ count( c:* ) gt 1 ]" mode="preproc:expand" priority="5">
<variable name="when" select="." />
<!-- expand into adjacent c:when's -->
<xsl:for-each select="c:*">
<for-each select="c:*">
<c:when>
<xsl:sequence select="$when/@*" />
<xsl:apply-templates select="." mode="preproc:expand" />
<sequence select="$when/@*" />
<apply-templates select="." mode="preproc:expand" />
</c:when>
</xsl:for-each>
</xsl:template>
</for-each>
</template>
<!--
@ -234,17 +232,17 @@
This exists simply because function application is so verbose and, when
recursing, generally only a small fraction of the arguments actually change.
-->
<xsl:template match="c:recurse" mode="preproc:expand" priority="5">
<xsl:variable name="self" select="." />
<xsl:variable name="fname" select="ancestor::lv:function/@name" />
<xsl:variable name="overrides" select="./c:arg" />
<template match="c:recurse" mode="preproc:expand" priority="5">
<variable name="self" select="." />
<variable name="fname" select="ancestor::lv:function/@name" />
<variable name="overrides" select="./c:arg" />
<c:apply name="{$fname}">
<!-- every non-@name attribute should be converted into an argument -->
<xsl:call-template name="preproc:arg-short-expand" />
<call-template name="preproc:arg-short-expand" />
<!-- include all non-overridden args -->
<xsl:for-each select="
<for-each select="
ancestor::lv:function/lv:param[
not(
@name=$overrides/@name
@ -257,149 +255,149 @@
<c:arg name="{@name}">
<c:value-of name="{@name}" />
</c:arg>
</xsl:for-each>
</for-each>
<!-- copy in the overrides -->
<xsl:apply-templates select="$overrides" mode="preproc:expand" />
<apply-templates select="$overrides" mode="preproc:expand" />
</c:apply>
</xsl:template>
</template>
<!-- metadata constants have different semantics -->
<!-- TODO: maybe ignore single-quoted? -->
<xsl:template mode="preproc:expand" priority="6"
<template mode="preproc:expand" priority="6"
match="lv:meta/lv:prop/lv:const">
<xsl:sequence select="." />
</xsl:template>
<sequence select="." />
</template>
<!-- anything with a '@' is likely a template variable reference, so we
should not attempt to perform constant expansion -->
<xsl:template mode="preproc:expand" priority="7"
<template mode="preproc:expand" priority="7"
match="c:const[ substring-after( @value, '@' ) ]
|lv:const[ substring-after( @value, '@' ) ]">
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:expand" />
</copy>
</template>
<!-- constants that contain 'e' (scientific notation) should be expanded; allows
for avoiding constants with many zeroes, which is hard to read -->
<xsl:template mode="preproc:expand" priority="6"
<template mode="preproc:expand" priority="6"
match="c:const[ substring-before( @value, 'e' ) ]
|lv:const[ substring-before( @value, 'e' ) ]">
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<xsl:attribute name="value">
<xsl:call-template name="preproc:expand-e">
<xsl:with-param name="number" select="@value" />
</xsl:call-template>
</xsl:attribute>
<attribute name="value">
<call-template name="preproc:expand-e">
<with-param name="number" select="@value" />
</call-template>
</attribute>
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:expand" />
</copy>
</template>
<xsl:template mode="preproc:expand" priority="6"
<template mode="preproc:expand" priority="6"
match="c:const[ substring-before( @value, 'm' ) ]
|lv:const[ substring-before( @value, 'm' ) ]">
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<xsl:attribute name="value">
<xsl:call-template name="preproc:expand-e">
<xsl:with-param name="number"
<attribute name="value">
<call-template name="preproc:expand-e">
<with-param name="number"
select="concat( substring-before( @value, 'm' ), 'e6' )" />
</xsl:call-template>
</xsl:attribute>
</call-template>
</attribute>
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:expand" />
</copy>
</template>
<xsl:template mode="preproc:expand" priority="6"
<template mode="preproc:expand" priority="6"
match="c:const[ substring-before( @value, 'k' ) ]
|lv:const[ substring-before( @value, 'k' ) ]">
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<xsl:attribute name="value">
<xsl:call-template name="preproc:expand-e">
<xsl:with-param name="number"
<attribute name="value">
<call-template name="preproc:expand-e">
<with-param name="number"
select="concat( substring-before( @value, 'k' ), 'e3' )" />
</xsl:call-template>
</xsl:attribute>
</call-template>
</attribute>
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:expand" />
</copy>
</template>
<!-- expand scientific notation -->
<!-- XXX: negatives not currently supported -->
<xsl:template name="preproc:expand-e">
<xsl:param name="number" />
<xsl:param name="whole" select="substring-before( $number, '.' )" />
<xsl:param name="dec" select="substring-before( substring-after( $number, '.' ), 'e' )" />
<xsl:param name="count" as="xs:double"
<template name="preproc:expand-e">
<param name="number" />
<param name="whole" select="substring-before( $number, '.' )" />
<param name="dec" select="substring-before( substring-after( $number, '.' ), 'e' )" />
<param name="count" as="xs:double"
select="number( substring-after( $number, 'e' ) )" />
<!-- output the whole number portion -->
<xsl:choose>
<xsl:when test="$whole and not( $whole = '' )">
<xsl:value-of select="$whole" />
</xsl:when>
<choose>
<when test="$whole and not( $whole = '' )">
<value-of select="$whole" />
</when>
<!-- if no decimal was provided, then use the entire number before 'e' -->
<xsl:when test="$number and not( $number = '' ) and ( $whole = '' )">
<xsl:value-of select="substring-before( $number, 'e' )" />
</xsl:when>
</xsl:choose>
<when test="$number and not( $number = '' ) and ( $whole = '' )">
<value-of select="substring-before( $number, 'e' )" />
</when>
</choose>
<xsl:choose>
<xsl:when test="$count > 0">
<xsl:choose>
<choose>
<when test="$count > 0">
<choose>
<!-- if we have a decimal, then use the first digit (as if we moved one
place to the right) -->
<xsl:when test="$dec and not( $dec = '' )">
<xsl:value-of select="substring( $dec, 1, 1 )" />
</xsl:when>
<when test="$dec and not( $dec = '' )">
<value-of select="substring( $dec, 1, 1 )" />
</when>
<!-- no decimal portion remaining; fill with 0 -->
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
<otherwise>
<text>0</text>
</otherwise>
</choose>
<!-- recursively expand -->
<xsl:call-template name="preproc:expand-e">
<call-template name="preproc:expand-e">
<!-- already processed the whole -->
<xsl:with-param name="whole" select="''" />
<with-param name="whole" select="''" />
<xsl:with-param name="dec">
<with-param name="dec">
<!-- move to the right one decimal place; otherwise, no decimal -->
<xsl:if test="$dec">
<xsl:value-of select="substring( $dec, 2 )" />
</xsl:if>
</xsl:with-param>
<if test="$dec">
<value-of select="substring( $dec, 2 )" />
</if>
</with-param>
<xsl:with-param name="count" select="$count - 1" />
</xsl:call-template>
</xsl:when>
<with-param name="count" select="$count - 1" />
</call-template>
</when>
<!-- output the remaining decimal, if any -->
<xsl:otherwise>
<xsl:if test="$dec and not( $dec = '' )">
<xsl:text>.</xsl:text>
<xsl:value-of select="$dec" />
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<otherwise>
<if test="$dec and not( $dec = '' )">
<text>.</text>
<value-of select="$dec" />
</if>
</otherwise>
</choose>
</template>
<!--
@ -412,7 +410,7 @@
Note that we should *not* perform these optimizations if there are templates
awaiting application or any other lv:* nodes that have not been expanded.
-->
<xsl:template mode="preproc:expand" priority="5" match="
<template mode="preproc:expand" priority="5" match="
c:cases[
not( lv:* or t:* )
and c:otherwise[
@ -423,8 +421,8 @@
<!-- just replace with the content of the otherwise block (do not explicitly
process c:*, since there may be templates) -->
<xsl:apply-templates select="c:otherwise/*" mode="preproc:expand" />
</xsl:template>
<apply-templates select="c:otherwise/*" mode="preproc:expand" />
</template>
<!--
@ -435,25 +433,25 @@
Note that we should *not* perform these optimizations if there are templates
awaiting application or any other lv:* nodes that have not been expanded.
-->
<xsl:template match="c:sum[ lv:*[ not( @preproc:*) ] or t:* ]
<template match="c:sum[ lv:*[ not( @preproc:*) ] or t:* ]
|c:product[ lv:*[ not( @preproc:* ) ] or t:* ]"
mode="preproc:expand" priority="7">
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<copy>
<sequence select="@*" />
<apply-templates mode="preproc:expand" />
</copy>
</template>
<xsl:template match="c:sum[ not( @of or @generates ) and count( c:* ) &lt; 2 ]" mode="preproc:expand" priority="5">
<xsl:apply-templates select="c:*" mode="preproc:expand" />
</xsl:template>
<xsl:template match="c:product[ not( @of or @generates ) and count( c:* ) &lt; 2 ]" mode="preproc:expand" priority="5">
<xsl:apply-templates select="c:*" mode="preproc:expand" />
</xsl:template>
<template match="c:sum[ not( @of or @generates ) and count( c:* ) &lt; 2 ]" mode="preproc:expand" priority="5">
<apply-templates select="c:*" mode="preproc:expand" />
</template>
<template match="c:product[ not( @of or @generates ) and count( c:* ) &lt; 2 ]" mode="preproc:expand" priority="5">
<apply-templates select="c:*" mode="preproc:expand" />
</template>
<!-- TODO: We could add shorthand for indexes too, e.g. name[i] or name[0] -->
<xsl:template match="
<template match="
c:apply[
@*[
not(
@ -465,20 +463,20 @@
"
mode="preproc:expand" priority="5">
<xsl:copy>
<copy>
<!-- keep the name attribute, which specifies what function to apply -->
<xsl:sequence select="@name, @label" />
<sequence select="@name, @label" />
<!-- every other attribute should be converted into an argument -->
<xsl:call-template name="preproc:arg-short-expand" />
<call-template name="preproc:arg-short-expand" />
<xsl:apply-templates select="c:arg" mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates select="c:arg" mode="preproc:expand" />
</copy>
</template>
<xsl:template name="preproc:arg-short-expand">
<xsl:for-each select="@*[
<template name="preproc:arg-short-expand">
<for-each select="@*[
not(
local-name() = 'name'
or local-name() = 'label'
@ -488,18 +486,18 @@
<c:arg name="{local-name()}">
<c:value-of name="{.}" />
</c:arg>
</xsl:for-each>
</xsl:template>
</for-each>
</template>
<xsl:template match="lv:rate[ lv:class ]|lv:function[ lv:class ]|lv:yield[ lv:class ]"
<template match="lv:rate[ lv:class ]|lv:function[ lv:class ]|lv:yield[ lv:class ]"
mode="preproc:expand" priority="9">
<!-- already processed -->
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<copy>
<sequence select="@*" />
<apply-templates mode="preproc:expand" />
</copy>
</template>
<!--
Add lv:class nodes containing the values of each individual class
@ -507,31 +505,31 @@
This eliminates the need to tokenize later and drastically simplifies xpath
queries.
-->
<xsl:template match="lv:rate|lv:function|lv:yield" mode="preproc:expand" priority="5">
<xsl:variable name="self" select="." />
<template match="lv:rate|lv:function|lv:yield" mode="preproc:expand" priority="5">
<variable name="self" select="." />
<xsl:variable name="classes" select="tokenize( @class, ' ' )" />
<xsl:variable name="no-classes" select="tokenize( @no, ' ' )" />
<variable name="classes" select="tokenize( @class, ' ' )" />
<variable name="no-classes" select="tokenize( @no, ' ' )" />
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<!-- convert classes into nodes to make life easier down the road (if any) -->
<xsl:for-each select="$classes">
<xsl:if test=".">
<for-each select="$classes">
<if test=".">
<lv:class ref="{.}" no="false" />
</xsl:if>
</xsl:for-each>
</if>
</for-each>
<xsl:for-each select="$no-classes">
<xsl:if test=".">
<for-each select="$no-classes">
<if test=".">
<lv:class ref="{.}" no="true" />
</xsl:if>
</xsl:for-each>
</if>
</for-each>
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:expand" />
</copy>
</template>
@ -539,156 +537,156 @@
To make life a bit easier, calculate the set type of a classification @yields
and add it to the node as a @set attribute
-->
<xsl:template match="lv:classify" mode="preproc:expand" priority="5">
<xsl:variable name="self" select="." />
<template match="lv:classify" mode="preproc:expand" priority="5">
<variable name="self" select="." />
<xsl:copy>
<copy>
<!-- if there is no @yields attribute, then generate one -->
<xsl:if test="not( @yields )">
<xsl:attribute name="yields">
<xsl:text>__is</xsl:text>
<if test="not( @yields )">
<attribute name="yields">
<text>__is</text>
<!-- certain characters are not valid for @yields -->
<xsl:value-of select="translate( @as, '-', '' )" />
</xsl:attribute>
<value-of select="translate( @as, '-', '' )" />
</attribute>
<xsl:attribute name="preproc:yields-generated"
<attribute name="preproc:yields-generated"
select="'true'" />
</xsl:if>
</if>
<xsl:apply-templates mode="preproc:expand"
<apply-templates mode="preproc:expand"
select="@*" />
<!-- copy everything else -->
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:expand" />
</copy>
</template>
<!--
Normalize whitespace for class descriptions
-->
<xsl:template mode="preproc:expand" priority="5"
<template mode="preproc:expand" priority="5"
match="lv:classify/@desc">
<xsl:attribute name="desc"
<attribute name="desc"
select="normalize-space( . )" />
</xsl:template>
</template>
<!--
All other class attributes are copied verbatim
-->
<xsl:template mode="preproc:expand" priority="1"
<template mode="preproc:expand" priority="1"
match="lv:classify/@*">
<xsl:sequence select="." />
</xsl:template>
<sequence select="." />
</template>
<!-- default lv:match/@on short-hand to assert on a value of TRUE -->
<xsl:template match="lv:match[ not( @value
<template match="lv:match[ not( @value
or @anyOf
or @pattern
or * ) ]"
mode="preproc:expand" priority="7">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:attribute name="value"
<copy>
<copy-of select="@*" />
<attribute name="value"
select="'TRUE'" />
</xsl:copy>
</xsl:template>
</copy>
</template>
<xsl:template mode="preproc:expand"
<template mode="preproc:expand"
match="lv:join[ @all='true' ]"
priority="8">
<xsl:call-template name="preproc:mk-class-join-contents" />
</xsl:template>
<call-template name="preproc:mk-class-join-contents" />
</template>
<xsl:template mode="preproc:expand"
<template mode="preproc:expand"
match="lv:join"
priority="7">
<lv:any>
<xsl:call-template name="preproc:mk-class-join-contents" />
<call-template name="preproc:mk-class-join-contents" />
</lv:any>
</xsl:template>
</template>
<xsl:template name="preproc:mk-class-join-contents">
<xsl:variable name="prefix" select="@prefix" />
<template name="preproc:mk-class-join-contents">
<variable name="prefix" select="@prefix" />
<!-- TODO: remove lv:template nodes in a pass before this so that this
check is not necessary -->
<xsl:for-each select="root(.)/lv:classify[
<for-each select="root(.)/lv:classify[
starts-with( @as, $prefix )
and not( ancestor::lv:template )
]">
<lv:match value="TRUE">
<xsl:attribute name="on">
<xsl:choose>
<xsl:when test="@yields">
<xsl:value-of select="@yields" />
</xsl:when>
<attribute name="on">
<choose>
<when test="@yields">
<value-of select="@yields" />
</when>
<xsl:otherwise>
<xsl:text>__is</xsl:text>
<xsl:value-of select="@as" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<otherwise>
<text>__is</text>
<value-of select="@as" />
</otherwise>
</choose>
</attribute>
</lv:match>
</xsl:for-each>
</xsl:template>
</for-each>
</template>
<!-- enums have implicit values (as they are, well, enumerated; @value overrides) -->
<!-- TODO: should @value set the next implicit index? -->
<xsl:template match="lv:item[ not( @value ) ]" mode="preproc:expand" priority="5">
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:attribute name="value" select="count( preceding-sibling::* )" />
<xsl:apply-templates mode="preproc:expand" />
</xsl:copy>
</xsl:template>
<template match="lv:item[ not( @value ) ]" mode="preproc:expand" priority="5">
<copy>
<sequence select="@*" />
<attribute name="value" select="count( preceding-sibling::* )" />
<apply-templates mode="preproc:expand" />
</copy>
</template>
<xsl:template match="w:display[ @prefix ]" mode="preproc:expand" priority="5">
<xsl:variable name="prefix" select="@prefix" />
<xsl:variable name="children" select="w:*" />
<template match="w:display[ @prefix ]" mode="preproc:expand" priority="5">
<variable name="prefix" select="@prefix" />
<variable name="children" select="w:*" />
<xsl:for-each select="root(.)//lv:rate[ starts-with( @yields, $prefix ) ]">
<for-each select="root(.)//lv:rate[ starts-with( @yields, $prefix ) ]">
<w:display name="{@yields}">
<xsl:sequence select="$children" />
<sequence select="$children" />
</w:display>
</xsl:for-each>
</xsl:template>
</for-each>
</template>
<!-- remove templates that have been copied from an external source for
processing -->
<xsl:template match="lv:template[
<template match="lv:template[
@name=root()
/preproc:symtable/preproc:sym[ @src ]/@name ]"
mode="preproc:expand" priority="5">
</xsl:template>
</template>
<!-- IMPORTANT: do not process unexpanded templates -->
<xsl:template match="lv:template" mode="preproc:expand" priority="4">
<xsl:sequence select="." />
</xsl:template>
<template match="lv:template" mode="preproc:expand" priority="4">
<sequence select="." />
</template>
<xsl:template match="preproc:symtable" mode="preproc:expand" priority="5">
<template match="preproc:symtable" mode="preproc:expand" priority="5">
<!-- ignore -->
<xsl:sequence select="." />
</xsl:template>
<sequence select="." />
</template>
<xsl:template match="lv:__external-data" mode="preproc:expand" priority="5">
<template match="lv:__external-data" mode="preproc:expand" priority="5">
<!-- intended for use by code generators; data is not retained in object file
unless some other process overrides this template -->
</xsl:template>
</template>
</xsl:stylesheet>
</stylesheet>
<!--
Footnotes

View File

@ -20,19 +20,18 @@
along with this program. If not, see
<http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:c="http://www.lovullo.com/calc"
xmlns:ext="http://www.lovullo.com/ext">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:c="http://www.lovullo.com/calc"
xmlns:ext="http://www.lovullo.com/ext">
<xsl:include href="template.xsl" />
<xsl:include href="eligclass.xsl" />
<include href="template.xsl" />
<include href="eligclass.xsl" />
<!--
@ -41,60 +40,60 @@
This will continue to recurse until no preproc:repass nodes are found; this
allos macros to expand into macros for further processing.
-->
<xsl:template match="*" mode="preproc:macropass" priority="1"
<template match="*" mode="preproc:macropass" priority="1"
as="node()+">
<xsl:variable name="result" as="node()+">
<xsl:apply-templates select="." mode="preproc:macros" />
</xsl:variable>
<variable name="result" as="node()+">
<apply-templates select="." mode="preproc:macros" />
</variable>
<xsl:variable name="nodeset" select="$result" />
<variable name="nodeset" select="$result" />
<xsl:variable name="repass"
<variable name="repass"
select="$nodeset//preproc:repass" />
<!-- halt if we are in error -->
<xsl:for-each select="$nodeset//preproc:error">
<xsl:message terminate="yes">
<xsl:text>!!! [preproc] error: </xsl:text>
<xsl:value-of select="." />
</xsl:message>
</xsl:for-each>
<for-each select="$nodeset//preproc:error">
<message terminate="yes">
<text>!!! [preproc] error: </text>
<value-of select="." />
</message>
</for-each>
<xsl:choose>
<choose>
<!-- if it was indicated that we must do so, recurse -->
<xsl:when test="$repass and not( $repass[ @need-sym ] )">
<when test="$repass and not( $repass[ @need-sym ] )">
<!-- record the repass to keep a count -->
<!-- TODO: reintroduce
<preproc:repass-record />
-->
<xsl:message>[preproc] *REPASS*</xsl:message>
<message>[preproc] *REPASS*</message>
<!-- perform the repass -->
<xsl:apply-templates select="$nodeset" mode="preproc:macropass">
<xsl:with-param name="clear-tpl-step"
<apply-templates select="$nodeset" mode="preproc:macropass">
<with-param name="clear-tpl-step"
tunnel="yes"
select="false()" />
</xsl:apply-templates>
</xsl:when>
</apply-templates>
</when>
<!-- no more passes needed; strip any cruft and we're done -->
<xsl:otherwise>
<xsl:apply-templates mode="preproc:strip-tpl-cruft"
<otherwise>
<apply-templates mode="preproc:strip-tpl-cruft"
select="$nodeset" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</otherwise>
</choose>
</template>
<xsl:template match="*" mode="preproc:macros" priority="1">
<xsl:copy>
<xsl:sequence select="@*" />
<template match="*" mode="preproc:macros" priority="1">
<copy>
<sequence select="@*" />
<xsl:apply-templates mode="preproc:macros" />
</xsl:copy>
</xsl:template>
<apply-templates mode="preproc:macros" />
</copy>
</template>
<!--
@ -102,38 +101,38 @@
Otherwise, we would recurse indefinately.
-->
<xsl:template match="preproc:repass" mode="preproc:macros" priority="5">
<template match="preproc:repass" mode="preproc:macros" priority="5">
<!-- remove; no longer needed -->
</xsl:template>
</template>
<xsl:template match="preproc:tpl-step" mode="preproc:macros" priority="5">
<xsl:param name="clear-tpl-step"
<template match="preproc:tpl-step" mode="preproc:macros" priority="5">
<param name="clear-tpl-step"
tunnel="yes"
select="true()" />
<xsl:choose>
<xsl:when test="$clear-tpl-step">
<choose>
<when test="$clear-tpl-step">
<!-- strip -->
</xsl:when>
</when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<otherwise>
<copy-of select="." />
</otherwise>
</choose>
</template>
<!--
lv:rater is just a special type of package
-->
<xsl:template match="lv:rater" mode="preproc:macros" priority="9">
<template match="lv:rater" mode="preproc:macros" priority="9">
<lv:package program="true">
<xsl:sequence select="@*, *" />
<sequence select="@*, *" />
</lv:package>
<preproc:repass src="lv:rater" />
</xsl:template>
</template>
@ -143,11 +142,11 @@
These nodes (usually) contain nothing that can be processed on the macro pass,
so recursion is unnecessary; note the low priority.
-->
<xsl:template match="lv:typedef"
<template match="lv:typedef"
mode="preproc:macros" priority="2">
<xsl:sequence select="." />
</xsl:template>
<sequence select="." />
</template>
<!--
@ -156,10 +155,10 @@
It is a nuisance to have separate params (e.g. templates) for constants
and values.
-->
<xsl:template mode="preproc:macros"
<template mode="preproc:macros"
match="c:value-of[ starts-with( @name, '#' ) ]"
priority="7">
<xsl:variable name="desc" as="xs:string"
<variable name="desc" as="xs:string"
select="if ( @label ) then
@label
else
@ -168,7 +167,7 @@
<c:const value="{substring-after( @name, '#' )}"
type="float"
desc="{$desc}" />
</xsl:template>
</template>
<!--
@ -177,110 +176,110 @@
It is a nuisance to have separate params (e.g. templates) for constants
and values.
-->
<xsl:template mode="preproc:macros"
<template mode="preproc:macros"
match="c:value-of[ starts-with( @index, '#' ) ]"
priority="7">
<xsl:copy>
<xsl:copy-of select="@*[ not( name() = 'index' ) ]" />
<copy>
<copy-of select="@*[ not( name() = 'index' ) ]" />
<c:index>
<c:const value="{substring-after( @index, '#' )}"
type="float"
desc="Generated short-hand constant" />
</c:index>
</xsl:copy>
</xsl:template>
</copy>
</template>
<!--
It does not make sense to try to take an index of a scalar
-->
<xsl:template mode="preproc:macros"
<template mode="preproc:macros"
match="c:value-of[
@index
and starts-with( @name, '#' ) ]"
priority="9">
<preproc:error>
<xsl:text>Cannot take index of scalar value: </xsl:text>
<xsl:value-of select="@name" />
<text>Cannot take index of scalar value: </text>
<value-of select="@name" />
</preproc:error>
</xsl:template>
</template>
<!--
We can't accurately determine how to rewrite classifications if tempaltes
have not yet been expanded.
-->
<xsl:template mode="preproc:macros" priority="9"
<template mode="preproc:macros" priority="9"
match="lv:classify[ t:* ]">
<xsl:copy>
<xsl:sequence select="@*" />
<copy>
<sequence select="@*" />
<xsl:apply-templates mode="preproc:macros"
<apply-templates mode="preproc:macros"
select="*" />
</xsl:copy>
</copy>
<preproc:repass src="lv:classify wait on template expansion" />
</xsl:template>
</template>
<!--
Classifications containing only an lv:any child node can be converted into
existential classifications
-->
<xsl:template mode="preproc:macros" priority="8"
<template mode="preproc:macros" priority="8"
match="lv:classify[
lv:any
and count( lv:* ) = 1
and not( preproc:tpl-barrier/lv:* ) ]">
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:attribute name="any" select="'true'" />
<copy>
<sequence select="@*" />
<attribute name="any" select="'true'" />
<xsl:sequence select="lv:any/*" />
</xsl:copy>
<sequence select="lv:any/*" />
</copy>
<preproc:repass src="lv:classify any" />
</xsl:template>
</template>
<xsl:template match="lv:classify[ .//lv:any|.//lv:all ]" mode="preproc:macros" priority="6">
<xsl:variable name="result">
<xsl:apply-templates select="." mode="preproc:class-groupgen" />
</xsl:variable>
<template match="lv:classify[ .//lv:any|.//lv:all ]" mode="preproc:macros" priority="6">
<variable name="result">
<apply-templates select="." mode="preproc:class-groupgen" />
</variable>
<xsl:apply-templates select="$result/lv:classify" mode="preproc:class-extract" />
<apply-templates select="$result/lv:classify" mode="preproc:class-extract" />
<preproc:repass src="lv:classify any|all" />
</xsl:template>
</template>
<xsl:template match="lv:classify" mode="preproc:class-groupgen" priority="5">
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:apply-templates mode="preproc:class-groupgen" />
</xsl:copy>
</xsl:template>
<template match="lv:classify" mode="preproc:class-groupgen" priority="5">
<copy>
<sequence select="@*" />
<apply-templates mode="preproc:class-groupgen" />
</copy>
</template>
<xsl:template mode="preproc:class-groupgen" priority="9"
<template mode="preproc:class-groupgen" priority="9"
match="lv:any[ not( element() ) ]
|lv:all[ not( element() ) ]">
<!-- useless; remove -->
</xsl:template>
</template>
<xsl:template match="lv:any|lv:all" mode="preproc:class-groupgen" priority="5">
<template match="lv:any|lv:all" mode="preproc:class-groupgen" priority="5">
<!-- this needs to be unique enough that there is unlikely to be a conflict
between generated ids in various packages; generate-id is not enough for
cross-package guarantees (indeed, I did witness conflicts), so there is
a random seed passed into the stylesheet externally -->
<xsl:variable name="id" select="concat( $__rseed, generate-id(.) )" />
<variable name="id" select="concat( $__rseed, generate-id(.) )" />
<xsl:variable name="parent-name" select="ancestor::lv:classify/@as" />
<xsl:variable name="yields" select="concat( 'is', $id )" />
<variable name="parent-name" select="ancestor::lv:classify/@as" />
<variable name="yields" select="concat( 'is', $id )" />
<xsl:variable name="external" as="xs:string?"
<variable name="external" as="xs:string?"
select="ancestor::lv:classify/@external" />
<!-- this will be raised outside of the parent classification during
@ -290,112 +289,112 @@
preproc:generated-from="{$parent-name}"
external="{$external}"
desc="(generated from predicate group of {$parent-name}">
<xsl:if test="local-name() = 'any'">
<xsl:attribute name="any" select="'true'" />
</xsl:if>
<if test="local-name() = 'any'">
<attribute name="any" select="'true'" />
</if>
<xsl:apply-templates mode="preproc:class-groupgen" />
<apply-templates mode="preproc:class-groupgen" />
</lv:classify>
<!-- this will remain in its place -->
<lv:match on="{$yields}" value="TRUE" preproc:generated="true" />
</xsl:template>
</template>
<!-- traverse through preproc nodes (e.g. preproc:tpl-barrier) -->
<xsl:template match="preproc:*" mode="preproc:class-groupgen" priority="2">
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:apply-templates select="node()" mode="preproc:class-groupgen" />
</xsl:copy>
</xsl:template>
<template match="preproc:*" mode="preproc:class-groupgen" priority="2">
<copy>
<sequence select="@*" />
<apply-templates select="node()" mode="preproc:class-groupgen" />
</copy>
</template>
<!-- retain everything else -->
<xsl:template match="*" mode="preproc:class-groupgen" priority="1">
<xsl:sequence select="." />
</xsl:template>
<template match="*" mode="preproc:class-groupgen" priority="1">
<sequence select="." />
</template>
<xsl:template match="lv:classify" mode="preproc:class-extract" priority="5">
<xsl:apply-templates select="lv:classify" mode="preproc:class-extract" />
<template match="lv:classify" mode="preproc:class-extract" priority="5">
<apply-templates select="lv:classify" mode="preproc:class-extract" />
<xsl:copy>
<xsl:sequence select="@*" />
<xsl:apply-templates mode="preproc:class-filter" />
</xsl:copy>
</xsl:template>
<copy>
<sequence select="@*" />
<apply-templates mode="preproc:class-filter" />
</copy>
</template>
<xsl:template match="*" mode="preproc:class-extract" priority="1">
<template match="*" mode="preproc:class-extract" priority="1">
<!-- ignore non-class -->
</xsl:template>
</template>
<xsl:template match="lv:classify" mode="preproc:class-filter" priority="5">
<template match="lv:classify" mode="preproc:class-filter" priority="5">
<!-- remove -->
</xsl:template>
</template>
<xsl:template match="*" mode="preproc:class-filter" priority="1">
<xsl:sequence select="." />
</xsl:template>
<template match="*" mode="preproc:class-filter" priority="1">
<sequence select="." />
</template>
<!--
Sections exist purely for organization and documentation. Move all
nodes out of it, so that we do not complicate parsing.
-->
<xsl:template mode="preproc:macros" priority="2"
<template mode="preproc:macros" priority="2"
match="lv:section">
<xsl:apply-templates select="*" mode="preproc:macros" />
</xsl:template>
<apply-templates select="*" mode="preproc:macros" />
</template>
<!--
lv:yield is simply another rate block with a special name that is recognized
by the linker
-->
<xsl:template match="lv:yield" mode="preproc:macros" priority="5">
<template match="lv:yield" mode="preproc:macros" priority="5">
<lv:rate yields="___yield" local="true">
<xsl:apply-templates mode="preproc:macros" />
<apply-templates mode="preproc:macros" />
</lv:rate>
</xsl:template>
</template>
<!-- this situation may occur both manually and from lv:rate-each-template -->
<xsl:template match="lv:rate-each[ lv:apply-template ]" mode="preproc:macros" priority="9">
<xsl:variable name="apply">
<template match="lv:rate-each[ lv:apply-template ]" mode="preproc:macros" priority="9">
<variable name="apply">
<preproc:apply>
<xsl:apply-templates select="lv:apply-template" mode="preproc:macros" />
<apply-templates select="lv:apply-template" mode="preproc:macros" />
</preproc:apply>
</xsl:variable>
</variable>
<xsl:choose>
<choose>
<!-- did the template apply? (note that we only check for a single one,
since that's all that we should have) -->
<xsl:when test="$apply/preproc:apply/lv:apply-template">
<xsl:sequence select="." />
<when test="$apply/preproc:apply/lv:apply-template">
<sequence select="." />
<xsl:message>
<xsl:text>[preproc] waiting to expand rate-each </xsl:text>
<xsl:value-of select="@yields" />
<xsl:text> (immediate template(s) need expansion)...</xsl:text>
</xsl:message>
</xsl:when>
<message>
<text>[preproc] waiting to expand rate-each </text>
<value-of select="@yields" />
<text> (immediate template(s) need expansion)...</text>
</message>
</when>
<xsl:otherwise>
<otherwise>
<!-- it applied! -->
<xsl:copy>
<xsl:sequence select="@*, *[ not( local-name()='apply-template' ) ]" />
<xsl:sequence select="$apply/preproc:apply/*" />
</xsl:copy>
<copy>
<sequence select="@*, *[ not( local-name()='apply-template' ) ]" />
<sequence select="$apply/preproc:apply/*" />
</copy>
<!-- we'll process this block next time around -->
<preproc:repass src="lv:rate-each lv:apply-template" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</otherwise>
</choose>
</template>
<!--
@ -404,68 +403,68 @@
The intent here is to reduce highly repetitive code.
-->
<xsl:template match="lv:rate-each" mode="preproc:macros" priority="5">
<template match="lv:rate-each" mode="preproc:macros" priority="5">
<!-- TODO: debug flag
<xsl:message>
<xsl:text>[preproc] expanding rate-each </xsl:text>
<xsl:value-of select="@yields" />
<xsl:text>...</xsl:text>
</xsl:message>
<message>
<text>[preproc] expanding rate-each </text>
<value-of select="@yields" />
<text>...</text>
</message>
-->
<lv:rate preproc:gentle-no="true">
<xsl:sequence select="@*[
<sequence select="@*[
not( local-name() = 'index' )
and not( local-name() = 'generates' )
]" />
<xsl:if test="not( @yields )">
<if test="not( @yields )">
<!-- if @generates is not supplied either, then we cannot continue -->
<xsl:choose>
<xsl:when test="not( @generates )">
<choose>
<when test="not( @generates )">
<!-- TODO: some means of identifying this...the error isn't terribly
helpful... :x -->
<preproc:error>
<xsl:text>rate-each must provide either @yields or @generates</xsl:text>
<text>rate-each must provide either @yields or @generates</text>
</preproc:error>
</xsl:when>
</when>
<xsl:otherwise>
<xsl:attribute name="yields"
<otherwise>
<attribute name="yields"
select="concat( '_', @generates )" />
<xsl:attribute name="preproc:yields-generated"
<attribute name="preproc:yields-generated"
select="'true'" />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</otherwise>
</choose>
</if>
<xsl:sequence select="./lv:class" />
<sequence select="./lv:class" />
<c:sum of="_CMATCH_" index="{@index}" sym="{@gensym}">
<xsl:if test="@dim">
<xsl:copy-of select="@dim" />
</xsl:if>
<if test="@dim">
<copy-of select="@dim" />
</if>
<!-- copy @generates, if it exists (has the benefit of copying nothing
if it does not exist) -->
<xsl:sequence select="@generates" />
<sequence select="@generates" />
<xsl:attribute name="desc">
<xsl:text>Set of individual </xsl:text>
<xsl:value-of select="@yields" />
<xsl:text> premiums</xsl:text>
</xsl:attribute>
<attribute name="desc">
<text>Set of individual </text>
<value-of select="@yields" />
<text> premiums</text>
</attribute>
<c:product>
<c:value-of name="_CMATCH_" index="{@index}">
<xsl:attribute name="label">
<xsl:text>Zero if not </xsl:text>
<xsl:value-of select="@class" />
<xsl:text>, otherwise one</xsl:text>
</xsl:attribute>
<attribute name="label">
<text>Zero if not </text>
<value-of select="@class" />
<text>, otherwise one</text>
</attribute>
</c:value-of>
<xsl:apply-templates
<apply-templates
select="*[
not(
local-name() = 'class'
@ -475,6 +474,6 @@
</c:product>
</c:sum>
</lv:rate>
</xsl:template>
</template>
</xsl:stylesheet>
</stylesheet>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,43 +23,41 @@
This progress is aggressive; the resulting tree will follow the structure of
the original XML, but will be heavily augmented and some parts rewritten.
-->
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:c="http://www.lovullo.com/calc"
xmlns:w="http://www.lovullo.com/rater/worksheet"
xmlns:ext="http://www.lovullo.com/ext"
xmlns:util="http://www.lovullo.com/util">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:preproc="http://www.lovullo.com/rater/preproc"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:t="http://www.lovullo.com/rater/apply-template"
xmlns:c="http://www.lovullo.com/calc"
xmlns:w="http://www.lovullo.com/rater/worksheet"
xmlns:ext="http://www.lovullo.com/ext"
xmlns:util="http://www.lovullo.com/util">
<xsl:include href="depgen.xsl" />
<xsl:include href="preproc/package.xsl" />
<include href="depgen.xsl" />
<include href="preproc/package.xsl" />
<!--
Raters themselves get special treatment
-->
<xsl:template match="lv:rater" mode="preproc:compile" priority="9">
<xsl:param name="orig-root" select="." />
<xsl:param name="stopshort" />
<template match="lv:rater" mode="preproc:compile" priority="9">
<param name="orig-root" select="." />
<param name="stopshort" />
<xsl:message>
<xsl:text>[preproc] [rater]</xsl:text>
</xsl:message>
<message>
<text>[preproc] [rater]</text>
</message>
<!-- handle package preprocessing -->
<xsl:variable name="pkg-result">
<xsl:call-template name="preproc:pkg-compile">
<xsl:with-param name="orig-root" select="$orig-root" />
<xsl:with-param name="stopshort" select="$stopshort" />
</xsl:call-template>
</xsl:variable>
<variable name="pkg-result">
<call-template name="preproc:pkg-compile">
<with-param name="orig-root" select="$orig-root" />
<with-param name="stopshort" select="$stopshort" />
</call-template>
</variable>
<xsl:copy-of select="$pkg-result" />
</xsl:template>
<copy-of select="$pkg-result" />
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -20,86 +20,84 @@
along with this program. If not, see
<http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:util="http://www.lovullo.com/util"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:lvm="http://www.lovullo.com/rater/map"
xmlns:c="http://www.lovullo.com/calc"
xmlns:ext="http://www.lovullo.com/ext">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:util="http://www.lovullo.com/util"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:lvm="http://www.lovullo.com/rater/map"
xmlns:c="http://www.lovullo.com/calc"
xmlns:ext="http://www.lovullo.com/ext">
<xsl:variable name="_chrlower" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="_chrupper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<variable name="_chrlower" select="'abcdefghijklmnopqrstuvwxyz'" />
<variable name="_chrupper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<!--
Path to map directory
-->
<xsl:param name="map-root" select="'../map/'" />
<xsl:param name="retmap-root" select="concat( $map-root, 'return/' )" />
<param name="map-root" select="'../map/'" />
<param name="retmap-root" select="concat( $map-root, 'return/' )" />
<xsl:template name="util:load-package">
<xsl:param name="package" />
<xsl:param name="self" />
<template name="util:load-package">
<param name="package" />
<param name="self" />
<xsl:variable name="path" select="concat($package, '.xml')" />
<xsl:variable name="pkg" select="document( $path, $self )/lv:package" />
<variable name="path" select="concat($package, '.xml')" />
<variable name="pkg" select="document( $path, $self )/lv:package" />
<ext:package name="{$pkg/@name}">
<!-- path, including extension -->
<xsl:attribute name="path">
<xsl:value-of select="$path" />
</xsl:attribute>
<attribute name="path">
<value-of select="$path" />
</attribute>
<!-- path, excluding extension (as it appears in @package) -->
<xsl:attribute name="import-path">
<xsl:value-of select="@package" />
</xsl:attribute>
<attribute name="import-path">
<value-of select="@package" />
</attribute>
<xsl:copy-of select="$pkg" />
<copy-of select="$pkg" />
</ext:package>
</xsl:template>
</template>
<xsl:template match="lvm:*" mode="util:map-expand" priority="1">
<xsl:param name="path" select="'.'" />
<template match="lvm:*" mode="util:map-expand" priority="1">
<param name="path" select="'.'" />
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates mode="util:map-expand">
<xsl:with-param name="path" select="$path" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<copy>
<copy-of select="@*" />
<apply-templates mode="util:map-expand">
<with-param name="path" select="$path" />
</apply-templates>
</copy>
</template>
<!-- recursively inline imports -->
<xsl:template match="lvm:import" mode="util:map-expand" priority="5">
<xsl:param name="path" select="'.'" />
<template match="lvm:import" mode="util:map-expand" priority="5">
<param name="path" select="'.'" />
<xsl:apply-templates
<apply-templates
select="document( concat( @path, '.xml' ), . )/lvm:*/*"
mode="util:map-expand">
<xsl:with-param name="path" select="concat( $path, '/', @path )" />
</xsl:apply-templates>
</xsl:template>
<with-param name="path" select="concat( $path, '/', @path )" />
</apply-templates>
</template>
<!-- must be lower priority than lv:import -->
<xsl:template match="/lvm:*/lvm:*" mode="util:map-expand" priority="3">
<xsl:param name="path" select="'.'" />
<template match="/lvm:*/lvm:*" mode="util:map-expand" priority="3">
<param name="path" select="'.'" />
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:attribute name="__src" select="$path" />
<copy>
<copy-of select="@*" />
<attribute name="__src" select="$path" />
<xsl:apply-templates mode="util:map-expand">
<xsl:with-param name="path" select="$path" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<apply-templates mode="util:map-expand">
<with-param name="path" select="$path" />
</apply-templates>
</copy>
</template>
<!--
@ -111,93 +109,93 @@
@return string provided string with first character converted to uppercase
-->
<xsl:template name="util:ucfirst">
<xsl:param name="str" />
<template name="util:ucfirst">
<param name="str" />
<!-- convert first char to uppercase -->
<xsl:value-of
<value-of
select="translate( substring( $str, 1, 1 ), $_chrlower, $_chrupper )" />
<!-- remainder of string as it was provided -->
<xsl:value-of select="substring( $str, 2 )" />
</xsl:template>
<value-of select="substring( $str, 2 )" />
</template>
<!--
Converts a string to uppercase
-->
<xsl:template name="util:uppercase">
<xsl:param name="str" />
<xsl:value-of select="translate( $str, $_chrlower, $_chrupper )" />
</xsl:template>
<template name="util:uppercase">
<param name="str" />
<value-of select="translate( $str, $_chrlower, $_chrupper )" />
</template>
<!--
Converts a string to lowercase
-->
<xsl:template name="util:lowercase">
<xsl:param name="str" />
<xsl:value-of select="translate( $str, $_chrupper, $_chrlower )" />
</xsl:template>
<template name="util:lowercase">
<param name="str" />
<value-of select="translate( $str, $_chrupper, $_chrlower )" />
</template>
<xsl:template name="util:json">
<xsl:param name="id" />
<xsl:param name="value" />
<xsl:param name="obj" />
<xsl:param name="array" />
<template name="util:json">
<param name="id" />
<param name="value" />
<param name="obj" />
<param name="array" />
<xsl:if test="$id">
<xsl:text>"</xsl:text>
<xsl:call-template name="util:json-escape">
<xsl:with-param name="string" select="$id" />
</xsl:call-template>
<xsl:text>":</xsl:text>
</xsl:if>
<if test="$id">
<text>"</text>
<call-template name="util:json-escape">
<with-param name="string" select="$id" />
</call-template>
<text>":</text>
</if>
<xsl:choose>
<xsl:when test="$array">
<xsl:text>[</xsl:text>
<xsl:for-each select="$array/*">
<xsl:if test="position() > 1">
<xsl:text>,</xsl:text>
</xsl:if>
<choose>
<when test="$array">
<text>[</text>
<for-each select="$array/*">
<if test="position() > 1">
<text>,</text>
</if>
<xsl:value-of select="." />
</xsl:for-each>
<xsl:text>]</xsl:text>
</xsl:when>
<value-of select="." />
</for-each>
<text>]</text>
</when>
<xsl:when test="$obj">
<xsl:text>{</xsl:text>
<xsl:for-each select="$obj/*">
<xsl:if test="position() > 1">
<xsl:text>,</xsl:text>
</xsl:if>
<when test="$obj">
<text>{</text>
<for-each select="$obj/*">
<if test="position() > 1">
<text>,</text>
</if>
<xsl:value-of select="." />
</xsl:for-each>
<xsl:text>}</xsl:text>
</xsl:when>
<value-of select="." />
</for-each>
<text>}</text>
</when>
<xsl:when test="$value">
<xsl:text>"</xsl:text>
<xsl:call-template name="util:json-escape">
<xsl:with-param name="string" select="$value" />
</xsl:call-template>
<xsl:text>"</xsl:text>
</xsl:when>
<when test="$value">
<text>"</text>
<call-template name="util:json-escape">
<with-param name="string" select="$value" />
</call-template>
<text>"</text>
</when>
<xsl:otherwise>
<xsl:message terminate="yes">[util] !!! invalid util:json</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<otherwise>
<message terminate="yes">[util] !!! invalid util:json</message>
</otherwise>
</choose>
</template>
<xsl:template name="util:json-escape">
<xsl:param name="string" />
<template name="util:json-escape">
<param name="string" />
<xsl:value-of select="$string" />
</xsl:template>
<value-of select="$string" />
</template>
</xsl:stylesheet>
</stylesheet>

View File

@ -20,12 +20,11 @@
along with this program. If not, see
<http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="include/dslc-base.xsl" />
<include href="include/dslc-base.xsl" />
<xsl:include href="compiler/linker.xsl" />
<include href="compiler/linker.xsl" />
</xsl:stylesheet>
</stylesheet>

View File

@ -21,82 +21,80 @@
<http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet version="2.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:lvp="http://www.lovullo.com"
xmlns:lvm="http://www.lovullo.com/rater/map"
xmlns:lvmc="http://www.lovullo.com/rater/map/compiler"
xmlns:c="http://www.lovullo.com/calc"
xmlns:l="http://www.lovullo.com/rater/linker"
xmlns:compiler="http://www.lovullo.com/rater/compiler"
xmlns:calc-compiler="http://www.lovullo.com/calc/compiler"
xmlns:util="http://www.lovullo.com/util"
xmlns:ext="http://www.lovullo.com/ext"
xmlns:preproc="http://www.lovullo.com/rater/preproc">
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:lv="http://www.lovullo.com/rater"
xmlns:lvp="http://www.lovullo.com"
xmlns:lvm="http://www.lovullo.com/rater/map"
xmlns:lvmc="http://www.lovullo.com/rater/map/compiler"
xmlns:c="http://www.lovullo.com/calc"
xmlns:l="http://www.lovullo.com/rater/linker"
xmlns:compiler="http://www.lovullo.com/rater/compiler"
xmlns:calc-compiler="http://www.lovullo.com/calc/compiler"
xmlns:util="http://www.lovullo.com/util"
xmlns:ext="http://www.lovullo.com/ext"
xmlns:preproc="http://www.lovullo.com/rater/preproc">
<xsl:output
<output
indent="yes"
omit-xml-declaration="yes"
/>
<xsl:include href="include/dslc-base.xsl" />
<include href="include/dslc-base.xsl" />
<!-- compiler -> JS -->
<xsl:include href="compiler/linker.xsl" />
<xsl:include href="compiler/map.xsl" />
<xsl:include href="include/depgen.xsl" />
<include href="compiler/linker.xsl" />
<include href="compiler/map.xsl" />
<include href="include/depgen.xsl" />
<!-- path to program XML -->
<xsl:param name="path-program-ui" />
<param name="path-program-ui" />
<xsl:template match="/" priority="5">
<template match="/" priority="5">
<!-- the rater itself -->
<xsl:text>var rater = </xsl:text>
<xsl:value-of disable-output-escaping="yes" select="/lv:package/l:exec/text()" />
<xsl:text>; </xsl:text>
<text>var rater = </text>
<value-of disable-output-escaping="yes" select="/lv:package/l:exec/text()" />
<text>; </text>
<!-- maps may or may not exist -->
<xsl:variable name="map" select="/lv:package/l:map-exec" />
<xsl:variable name="retmap" select="/lv:package/l:retmap-exec" />
<variable name="map" select="/lv:package/l:map-exec" />
<variable name="retmap" select="/lv:package/l:retmap-exec" />
<!-- store a reference to the mapper in rater.fromMap() -->
<xsl:text>rater.fromMap = </xsl:text>
<xsl:choose>
<xsl:when test="$map">
<xsl:value-of disable-output-escaping="yes" select="$map/text()" />
</xsl:when>
<text>rater.fromMap = </text>
<choose>
<when test="$map">
<value-of disable-output-escaping="yes" select="$map/text()" />
</when>
<!-- no map available -->
<xsl:otherwise>
<otherwise>
<!-- simply invoke the conintuation with the provided data -->
<xsl:text>function(d,c){c(d);}</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>; </xsl:text>
<text>function(d,c){c(d);}</text>
</otherwise>
</choose>
<text>; </text>
<!-- return map -->
<xsl:text>rater._retmap = </xsl:text>
<xsl:choose>
<xsl:when test="$retmap">
<xsl:value-of disable-output-escaping="yes" select="$retmap/text()" />
</xsl:when>
<text>rater._retmap = </text>
<choose>
<when test="$retmap">
<value-of disable-output-escaping="yes" select="$retmap/text()" />
</when>
<!-- no map available -->
<xsl:otherwise>
<otherwise>
<!-- simply invoke the conintuation with the provided data -->
<xsl:text>function(d,c){c(d);}</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>; </xsl:text>
<text>function(d,c){c(d);}</text>
</otherwise>
</choose>
<text>; </text>
<!-- we'll export a version that automatically performs the mapping -->
<xsl:text>module.exports = function( args_base ) { </xsl:text>
<xsl:text>var ret; rater.fromMap( args_base, function( args ) {</xsl:text>
<xsl:text>
<text>module.exports = function( args_base ) { </text>
<text>var ret; rater.fromMap( args_base, function( args ) {</text>
<text>
var rater_result = rater( args );
// perf counter
@ -137,13 +135,13 @@
total: time
}
};
</xsl:text>
<xsl:text>} );</xsl:text>
</text>
<text>} );</text>
<xsl:text>return ret;</xsl:text>
<xsl:text>}; </xsl:text>
<text>return ret;</text>
<text>}; </text>
<xsl:text>
<text>
function process_worksheet( worksheet, vars, consts, debug, premium )
{
var ret = {};
@ -234,10 +232,10 @@
return ret;
}
</xsl:text>
</text>
<!-- expose the raw, unmapped rater -->
<xsl:text>module.exports.rater = rater;</xsl:text>
</xsl:template>
<text>module.exports.rater = rater;</text>
</template>
</xsl:stylesheet>
</stylesheet>