s.im.pl meta-metadata:
tutorial [semantic actions]
This tutorial will show you how to create useful semantic actions for the meta_metadata object urban_spoon_restaurant.

All semantic actions must be placed within the meta_metadata tag of the object they are intended for.

In general there are three types of semantic actions: variable declarations, control flow statements, and bridge function statements.

Variable Declarations: Control Flow Statements: Bridge Function Statements: The actions we want to take for an Urban Spoon restaurant information page might include: The semantic_actions for displaying the image of the restaurant (as stored in the meta_metadata_field pic) are:
<semantic_actions>

<get_field name="pic"/>

<create_and_visualize_img_surrogate>

<arg value="pic" name="image_purl"/>

</create_and_visualize_img_surrogate>

</semantic_actions>

Not all restaurant pages have a picture. In the case that it doesn't have a picture this action will do nothing. We can add a check to see if pic is null and if so then we can display the image map.
<semantic_actions>

<get_field name="pic">

<check condition="NOT_NULL" name="picFound"/>

</get_field>

<if>

<flag_check value="picFound"/>

<create_and_visualize_img_surrogate>

<arg value="pic" name="image_purl"/>

</create_and_visualize_img_surrogate>

</if>

<get_field name="map"/>

<create_and_visualize_img_surrogate>

<arg value="pic" name="image_purl"/>

</create_and_visualize_img_surrogate>

</semantic_actions>
Now we will add the semantic actions for adding each food genre page to the download queue. To do this we will have to use a for_each statement as well as parse_document.

This is the corresponding action set that will be added to the end of our existing semantic actions:
<get_field name="genres"/>

<for_each collection="genres" as="genre"/>

<get_field name="link" object="genre"/>

<get_field name="heading" object="genre"/>

<parse_document>

<arg value="link" name="container_link"/>

<arg value="heading" name="anchor_text"/>

</parse_document>

</for_each>



Tip: The default behavior of parse_document is to queue that URL for downloading and parsing in a waiting list. However, it has an attribute now that you can set to true if you want meta-metadata to immediately download and parse that document.

The next part of this tutorial talks about some advanced topics about the meta-language.