The previous example generated only a set of buttons, but the action body may contain additional content. For instance, you might want to add a label to each item.
<action> <hbox uri="?relateditem"> <label value="Related Item:"/> <button label="?relateditem"/> </hbox> </action>
In this example, the <hbox> will be generated for each result, assigned an id of the value of the ?relateditem, and the label and button will be added inside it. The button's label will be the value of the ?relateditem variable. You would only use the uri attribute on a single element since only one of the generated elements should be given a particular id.
Although the uri attribute should only be on one element, it does not have to be the outermost element in the action body. You can place other elements outside this to serve as containers for all the results. One difference is that this content is only generated once, not for every result. Only the content at the element with the uri attribute and below is copied for each result. For example, if the example was modified to the following:
<action> <toolbar> <button uri="?relateditem" label="?relateditem"/> </toolbar> </action>
Here, only the button would be repeated for each result; the toolbar will only be generated once. The toolbar is created just before the content for the first result is generated. The effect will be a toolbar with a set of three buttons inside it. Of course, in this simple example you would really just make the toolbar the outer element with the datasources attribute rather than placing inside the action.
So far we have only be using the ?relateditem variable since that is really the only useful variable that is available. We could also use the ?start variable. Recall the results:
(?start = http://www.xulplanet.com/rdf/A, ?relateditem = http://www.xulplanet.com/rdf/B) (?start = http://www.xulplanet.com/rdf/A, ?relateditem = http://www.xulplanet.com/rdf/C) (?start = http://www.xulplanet.com/rdf/A, ?relateditem = http://www.xulplanet.com/rdf/D)
We could display the value of the ?start variable in the results if desired:
<action> <hbox uri="?relateditem"> <button label="?start"/> <button label="?relateditem"/> </hbox> </action>
For the first button, the value of the variable ?start will be looked up in the result data while the second button will use the ?relateditem variable. Since all three results have the same value for the ?start variable, the result will be that the first buttons in each row will all have the same label. Here is an image of this example
You'll notice that the second row has an extra two buttons. We'll see why next.