287
edits
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
Templates will | Templates will allow generating content from XML sources as well as RDF. To use an XML source set the querytype attribute on the root element to 'xml', as in the following example: | ||
<vbox id="list" datasources="xml-url" ref="." querytype="xml"> | <vbox id="list" datasources="xml-url" ref="." querytype="xml"> | ||
| Line 66: | Line 66: | ||
</action> | </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. | 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. Note that the context for the expression in an assign element is each result, whereas the context for the expr expression on the query is the root of the XML source document. | ||
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. | 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. | ||
XML templates also support recursion in the same way as RDF templates. The result of each iteration will be used as the context for the next iteration. | |||
edits