2015-03-18 11:31:47 -04:00
|
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2013-02-13 09:27:33 -05:00
|
|
|
<!--
|
|
|
|
Brings c:case statements to life
|
|
|
|
|
|
|
|
The problem with cases is that they are so verbose for simple cases. This
|
|
|
|
makes simple cases simple.
|
|
|
|
-->
|
2015-03-18 11:31:47 -04:00
|
|
|
<package xmlns="http://www.lovullo.com/rater"
|
2013-02-13 09:27:33 -05:00
|
|
|
xmlns:c="http://www.lovullo.com/calc"
|
|
|
|
xmlns:t="http://www.lovullo.com/rater/apply-template"
|
|
|
|
core="true"
|
|
|
|
desc="Mapping templates/functions">
|
|
|
|
|
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<template name="_map-set_" desc="Map a set of values">
|
|
|
|
<param name="@name@" desc="Param name" />
|
|
|
|
<param name="@index@" desc="Index" />
|
|
|
|
<param name="@values@" desc="Criteria (map nodes)" />
|
|
|
|
<param name="@label@" desc="Case statement label">
|
2013-02-13 09:27:33 -05:00
|
|
|
<!-- default empty -->
|
2015-03-18 11:31:47 -04:00
|
|
|
<text></text>
|
|
|
|
</param>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<param name="@default@" desc="Default value" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<c:cases label="@label@">
|
2015-03-18 11:31:47 -04:00
|
|
|
<param-copy name="@values@">
|
|
|
|
<param-meta name="map_param" value="@name@" />
|
|
|
|
<param-meta name="map_index" value="@index@" />
|
|
|
|
</param-copy>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<!-- TODO: allow setting default via @default or t:default or something
|
|
|
|
(or both) -->
|
2015-03-18 11:31:47 -04:00
|
|
|
<if name="@default@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:otherwise>
|
|
|
|
<c:const value="@default@" type="integer" desc="No mapping" />
|
|
|
|
</c:otherwise>
|
2015-03-18 11:31:47 -04:00
|
|
|
</if>
|
2013-02-13 09:27:33 -05:00
|
|
|
</c:cases>
|
2015-03-18 11:31:47 -04:00
|
|
|
</template>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<template name="_map_" desc="Map criteria">
|
|
|
|
<param name="@from@" desc="Value to map from" />
|
|
|
|
<param name="@value@" desc="Constant to map to" />
|
|
|
|
<param name="@to@" desc="Named value (use instead of @value@)" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<param name="@type@" desc="Constant value type">
|
|
|
|
<text>float</text>
|
|
|
|
</param>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<param name="@desc@" desc="Map description">
|
|
|
|
<text>Destination mapping</text>
|
|
|
|
</param>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<!-- set by parent map-set -->
|
2015-03-18 11:31:47 -04:00
|
|
|
<param name="@name@" desc="Param name">
|
|
|
|
<param-inherit meta="map_param" />
|
|
|
|
</param>
|
|
|
|
<param name="@index@" desc="Index">
|
|
|
|
<param-inherit meta="map_index" />
|
|
|
|
</param>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<c:case>
|
|
|
|
<!-- index provided -->
|
2015-03-18 11:31:47 -04:00
|
|
|
<if name="@index@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:when name="@name@" index="@index@">
|
|
|
|
<c:eq>
|
|
|
|
<c:value-of name="@from@" />
|
|
|
|
</c:eq>
|
|
|
|
</c:when>
|
2015-03-18 11:31:47 -04:00
|
|
|
</if>
|
2013-02-13 09:27:33 -05:00
|
|
|
<!-- no index provided -->
|
2015-03-18 11:31:47 -04:00
|
|
|
<unless name="@index@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:when name="@name@">
|
|
|
|
<c:eq>
|
|
|
|
<c:value-of name="@from@" />
|
|
|
|
</c:eq>
|
|
|
|
</c:when>
|
2015-03-18 11:31:47 -04:00
|
|
|
</unless>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<if name="@value@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:const value="@value@" type="@type@" desc="@desc@" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</if>
|
|
|
|
<unless name="@value@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<!-- TODO: index support -->
|
|
|
|
<c:value-of name="@to@" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</unless>
|
2013-02-13 09:27:33 -05:00
|
|
|
</c:case>
|
2015-03-18 11:31:47 -04:00
|
|
|
</template>
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
|
2015-03-18 11:31:47 -04:00
|
|
|
<template name="_map-else_" desc="Non-matching map criteria">
|
|
|
|
<param name="@value@" desc="Constant to map to" />
|
|
|
|
<param name="@to@" desc="Named value (use instead of @value@)" />
|
2013-02-13 09:27:33 -05:00
|
|
|
|
|
|
|
<c:otherwise>
|
2015-03-18 11:31:47 -04:00
|
|
|
<if name="@value@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<c:const value="@value@" type="float" desc="@desc@" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</if>
|
|
|
|
<unless name="@value@">
|
2013-02-13 09:27:33 -05:00
|
|
|
<!-- TODO: index support -->
|
|
|
|
<c:value-of name="@to@" />
|
2015-03-18 11:31:47 -04:00
|
|
|
</unless>
|
2013-02-13 09:27:33 -05:00
|
|
|
</c:otherwise>
|
2015-03-18 11:31:47 -04:00
|
|
|
</template>
|
|
|
|
</package>
|
|
|
|
|