Constructed text to text map
Submitted by admin on Mon, 2009-09-07 16:30
Constructed Text-to-Text Map
This Specification example demonstrates how to use the ACS Block System to build a texttotextmap.
The advantage of building a TextToText map this way (rather than using a TextToTextSource) is that it allows you to use properties delegated from the Superblock inside the TextToText map.
It is a fully functional application that can be tested with the Specification Tool. The application results in a System Tray Notification or at the end user's computer. The message comes out of the map, according to the value of the superblock's KeyIn property. You can try any of the following keys: fruit, dances, animals or reader.
This also provides an example for how to use the &touchatag.reader.hash; variable to get the hash id for the reader being used.
<?xml version="1.0" encoding="UTF-8"?>
<specification xmlns="http://www.touchatag.com/schema/configurator/specification-1.0">
<application>
<command id="default" name="Constructed Text-to-Text Map Test"/>
</application>
<blueprint>
<superblock id="urn:tdn:example:construct-t2tmapper">
<!--The KeyIn property gets mapped against text value. Try: fruit, dances, animals or reader.-->
<property name="KeyIn"><text>reader</text></property>
<breakdown>
<!--This TextSource feeds the value to be mapped to the GetTextToTextValue.-->
<block id="current" ref="urn:touchatag:block:text-source">
<property name="Value"><delegate as="KeyIn"/></property>
</block>
<!--This series of blocks builds a text-to-text map for testing-->
<block id="emptyMap" ref="urn:touchatag:block:empty-text2text"/>
<!--Add the fruit key/value pair-->
<block id="addFruit" ref="urn:touchatag:block:add-text2text"/>
<block id="fruitKey" ref="urn:touchatag:block:text-source">
<property name="Value"><text>fruit</text></property>
</block>
<block id="fruitValue" ref="urn:touchatag:block:text-source">
<property name="Value"><text>Apples, oranges and bananas.</text></property>
</block>
<block id="addDances" ref="urn:touchatag:block:add-text2text"/>
<block id="dancesKey" ref="urn:touchatag:block:text-source">
<property name="Value"><text>dances</text></property>
</block>
<block id="dancesValue" ref="urn:touchatag:block:text-source">
<property name="Value"><text>Polka, tarantella and pogo.</text></property>
</block>
<block id="addAnimals" ref="urn:touchatag:block:add-text2text"/>
<block id="animalsKey" ref="urn:touchatag:block:text-source">
<property name="Value"><text>animals</text></property>
</block>
<block id="animalsValue" ref="urn:touchatag:block:text-source">
<property name="Value"><text>Pangolin, poodle and periwinkle.</text></property>
</block>
<block id="addReaderId" ref="urn:touchatag:block:add-text2text"/>
<block id="readerKey" ref="urn:touchatag:block:text-source">
<property name="Value"><text>reader</text></property>
</block>
<block id="readerValue" ref="urn:touchatag:block:text-source">
<property name="Value"><text>&touchatag.reader.hash;</text></property>
</block>
<!--The next block swaps any identifiers (such as &touchatag.reader.hash;) in the map-->
<block id="idreplacer" ref="urn:touchatag:block:text2textmap-resource-identifier-replacer"/>
<!--This GetTextToTextValue extracts a mapped value output from the TextToTextMap.-->
<block id="gettext" ref="urn:touchatag:block:get-text2text"/>
<!--This Message receives the mapped value output from the TextToTextMapper.-->
<block id="message" ref="urn:touchatag:block:message"/>
</breakdown>
<wiringscheme>
<!--This part of the wiring assembles the text2text map.-->
<wire from="emptyMap:out" to="addFruit:map-in"/>
<wire from="fruitKey:out" to="addFruit:key-in"/>
<wire from="fruitValue:out" to="addFruit:value-in"/>
<wire from="addFruit:out" to="addDances:map-in"/>
<wire from="dancesKey:out" to="addDances:key-in"/>
<wire from="dancesValue:out" to="addDances:value-in"/>
<wire from="addDances:out" to="addAnimals:map-in"/>
<wire from="animalsKey:out" to="addAnimals:key-in"/>
<wire from="animalsValue:out" to="addAnimals:value-in"/>
<wire from="addAnimals:out" to="addReaderId:map-in"/>
<wire from="readerKey:out" to="addReaderId:key-in"/>
<wire from="readerValue:out" to="addReaderId:value-in"/>
<!--This part replaces any identifiers, such as &touchatag.reader.hash;, if used.-->
<wire from="addReaderId:out" to="idreplacer:in"/>
<!--This part replaces any identifiers, such as &touchatag.reader.hash;, if used.-->
<wire from="current:out" to="gettext:key-in"/>
<wire from="idreplacer:out" to="gettext:map-in"/>
<!--Finally, we send the message out.-->
<wire from="gettext:out" to="message:in"/>
<shunt from="message:out" to="action-out"/>
</wiringscheme>
</superblock>
</blueprint>
</specification>
