287
edits
No edit summary |
No edit summary |
||
| Line 32: | Line 32: | ||
</template> | </template> | ||
</vbox> | </vbox> | ||
Multiple rules and conditions may also be used as with RDF templates. | |||
<vbox datasources="xml-url" ref="." querytype="xml" flex="1"> | |||
<template> | |||
<query expr="person[position()>1]"> | |||
<rule> | |||
<where subject="?name" rel="equals" value="Samantha"/> | |||
<action> | |||
<button uri="?" label="?name is a female."/> | |||
</action> | |||
</rule> | |||
<rule> | |||
<action> | |||
<button uri="?" label="?name is a male."/> | |||
</action> | |||
</rule> | |||
</template> | |||
</vbox> | |||
This example shows the full syntax for XML templates, where the expr attribute is used on the <query> element. | |||
The assign element allows the assignment of additional values to variables, in case you want the values to be calculated. If a variable is referred to that does not have an assignment, it is assumed to refer to the name of an attribute. This latter case is used in the earlier examples. | |||
<query expr="person"> | |||
<assign var="?number" expr="position()"/> | |||
</query> | |||
<action> | |||
<hbox uri="?"> | |||
<label value="?number"/> | |||
<button value="?name"/> | |||
</hbox> | |||
</action> | |||
In this example, the ?number variable is bound to the result of the 'position()' XPath expression. However, the ?name variable is not bound to a value, so it is used to retrieve the name attribute instead. | |||
This technique works similar to how the <binding> element is used, however the <assign> element requires a value to be set in order to generate a result. In the above example, the expression 'position()' will always return a value, but if it didn't, no output would be generated for that result. As with RDF templates, the <binding> element may be used for optional value. | |||
edits