Dynamic List Values from a Macro Input Parameter
You can populate the list of valid values dynamically from another input parameter to the macro. For example, one input parameter is a document with results from an RSS web feed. A second parameter accepts one article title that users should select from the RSS results to use as a query to another mashable, such as this example:
Thus one field in the repeating items from the first input parameter provides the dynamic list of valid values for a second macro input parameter. The first input parameter must be a document type that has at least one repeating node.
To provide a dynamic list of values for an input parameter based on a repeating node from another parameter, you add the following macro metadata elements to <parameter>:
<type> with a datatype of
enum <list> as a child of <type>
<xpath> as a child of <list>
You specify the path within the source input parameter to the repeating node that contains the values for this list in the
limitTo attribute in <xpath>
In this example, the <item> node in the RSS feed for the newsSource input parameter is repeating. The list of values to show for the newsItem input parameter is the article titles for each <item> in newsSource:
<macros xmlns="http://www.open-mashup.org/schemas/v1.0/EMML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML/..
/schemas/EMMLPrestoSpec.xsd"
domain="myBlocks">
<macro name="MoreNews"
xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions"
xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro">
<input name="newsSource" type="document"/>
<input name="newsItem" type="string"/>
<presto:macro-meta>
<block usage="Wires">
...
</block>
<parameters>
<parameter name="newsSource">
<label>Choose an RSS web feed</label>
<required>true</required>
</parameter>
<parameter name="newsItem">
<label>Choose a news article</label>
<required>true</required>
<type datatype="enum">
<list>
<xpath limitTo="$newsSource/rss/channel/item/title"/>
</list>
</type>
</parameter>
</parameters>
</presto:macro-meta>
....
</macro>
...
</macros>