109 lines
3.0 KiB
XML
109 lines
3.0 KiB
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
<!--
|
|
Brings c:case statements to life
|
|
|
|
The problem with cases is that they are so verbose for simple cases. This
|
|
makes simple cases simple.
|
|
-->
|
|
<package xmlns="http://www.lovullo.com/rater"
|
|
xmlns:c="http://www.lovullo.com/calc"
|
|
xmlns:t="http://www.lovullo.com/rater/apply-template"
|
|
core="true"
|
|
desc="Mapping templates/functions">
|
|
|
|
|
|
<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">
|
|
<!-- default empty -->
|
|
<text></text>
|
|
</param>
|
|
|
|
<param name="@default@" desc="Default value" />
|
|
|
|
<c:cases label="@label@">
|
|
<param-copy name="@values@">
|
|
<param-meta name="map_param" value="@name@" />
|
|
<param-meta name="map_index" value="@index@" />
|
|
</param-copy>
|
|
|
|
<!-- TODO: allow setting default via @default or t:default or something
|
|
(or both) -->
|
|
<if name="@default@">
|
|
<c:otherwise>
|
|
<c:const value="@default@" type="integer" desc="No mapping" />
|
|
</c:otherwise>
|
|
</if>
|
|
</c:cases>
|
|
</template>
|
|
|
|
|
|
<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@)" />
|
|
|
|
<param name="@type@" desc="Constant value type">
|
|
<text>float</text>
|
|
</param>
|
|
|
|
<param name="@desc@" desc="Map description">
|
|
<text>Destination mapping</text>
|
|
</param>
|
|
|
|
<!-- set by parent map-set -->
|
|
<param name="@name@" desc="Param name">
|
|
<param-inherit meta="map_param" />
|
|
</param>
|
|
<param name="@index@" desc="Index">
|
|
<param-inherit meta="map_index" />
|
|
</param>
|
|
|
|
<c:case>
|
|
<!-- index provided -->
|
|
<if name="@index@">
|
|
<c:when name="@name@" index="@index@">
|
|
<c:eq>
|
|
<c:value-of name="@from@" />
|
|
</c:eq>
|
|
</c:when>
|
|
</if>
|
|
<!-- no index provided -->
|
|
<unless name="@index@">
|
|
<c:when name="@name@">
|
|
<c:eq>
|
|
<c:value-of name="@from@" />
|
|
</c:eq>
|
|
</c:when>
|
|
</unless>
|
|
|
|
<if name="@value@">
|
|
<c:const value="@value@" type="@type@" desc="@desc@" />
|
|
</if>
|
|
<unless name="@value@">
|
|
<!-- TODO: index support -->
|
|
<c:value-of name="@to@" />
|
|
</unless>
|
|
</c:case>
|
|
</template>
|
|
|
|
|
|
<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@)" />
|
|
|
|
<c:otherwise>
|
|
<if name="@value@">
|
|
<c:const value="@value@" type="float" desc="@desc@" />
|
|
</if>
|
|
<unless name="@value@">
|
|
<!-- TODO: index support -->
|
|
<c:value-of name="@to@" />
|
|
</unless>
|
|
</c:otherwise>
|
|
</template>
|
|
</package>
|
|
|