Legend Labels

For most elements, the label attribute defines the text that appears in the legend. For example, if <legend use="@shapes#borders"/> appears in the Model XML, the value of <borders label="…"> is the text that appears to the left of the generated example shapes.

For elements which can appear multiple times, <border>, <color>, <overlay> and <style> label is the text that appears inside the example component.

The labels in a Shapes XML can do some simple value substitution. Any value in curly braces in a label attribute is interpreted as an XPath expression. The expression is taken relative to the calling Model XML file’s root <model> element. The most common use of this is to include the version number in an example of a new component. For example:

<!-- Model XML -->
<!-- Computing a label value -->
<model revision="1.0" revision-type="issued" name="Symbian OS" ver="9.4" 
label="System Model" shapes="shapes.xml">
<!-- Shapes XML -->  
<!-- Computing a label value -->
<overlay rule="VERSION(@introduced) = VERSION()" use="#new" label="New in {@ver}"/> 

In the above example, the value of the ver attribute of the model in the Model XML is used when creating the label (in the legend) of the overlay element. This generates the text New in 9.4 in the generated example component.

Another example use of curly braces is to count the number of items which match the legend item. For example:

<style label="Plugin Compo&#xad;nent ({count(//component[@plugin='Y'])})"
rule="@plugin='Y'">stroke-width: 2</style>

This shows up as Plugin Component (162) in the generated example component.