Limit Dynamic Choices and Forbid Literal Entries
You can limit the choices available within the Path Selection list to the results for one specific block in the mashup, and optionally to nodes within a specific path (a specific node or any of its descendants) in those results. This prevents users from entering literal values for the block property.
Note: The results for the block that user choices should be limited to must be passed to the macro as an input parameter with a document type.
Use the macro metadata statement <type> within <parameter>. Add <xpath> within <type> and specify the input parameter that choices should be limited to in the limitTo attribute.
The basic metadata to limit choices to results for one block would look something like this:
<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="helloWorld"
xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions"
xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro">
<input name="srcDoc" type="document"/>
<input name="aString" type="string"/>
<presto:macro-meta>
<block usage="Wires">
...
</block>
<parameters>
<parameter name="aString">
<label>Select a leaf node</label>
<type datatype="string">
<xpath limitTo="$srcDoc"/>
</type>
</parameter>
</parameters>
</presto:macro-meta>
....
</macro>
...
</macros>
With this configuration, the Path Selection list for this example would look like this:
In this example, the property with this configuration is a simple type, so users would be automatically be limited to selecting leaf nodes with simple data. For a document-type property, users could select any node within this single result.
To limit choices to one path within a specific block result, add path information to the input parameter name in limitTo attribute. For example:
<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="helloWorld"
xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions"
xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro">
<input name="srcDoc" type="document"/>
<input name="aString" type="string"/>
<presto:macro-meta>
<block usage="Wires">
...
</block>
<parameters>
<parameter name="aString">
<label>Group items by</label>
<type datatype="string">
<xpath limitTo="$srcDoc/root/complexRepeats"/>
</type>
</parameter>
</parameters>
</presto:macro-meta>
....
</macro>
...
</macros>
With this configuration, the Path Selection list for this example would look something like this: