XML Script logo
Using code to generate data
Usage

The _eval command can be used with the result attribute set to 'data' to generate text which will be added to the data tree, at the root of the current template, for later processing. As with all _eval commands, the text within the element is first parsed. Any text which is not a recognised command will be echoed; any recognised code will be run, and the output then echoed as appropriate. Setting the result attribute to 'data' will cause the output to be grafted onto the data tree instead of being echoed.

If a template is processed multiple times, elements added to the data root of that template will persist between processings. Subsequent processings of the same template will result in multiple copies of the 'generated' data being grafted into the same place on the template's data root. Although the attributes of a given element are unique, there can be multiple sub-elements with the same name, and even contents, under the same parent element. This makes array creation simpler than in conventional languages.

Setting the result attribute to 'temporary' or 'temp' will graft the output onto the data tree for the persistance of the current template only. This ensures that the grafted data is discarded each time the template finishes, to prevent arrays of similar elements being accumulated.

Examples

Using _eval with result='data'

Using _eval to create multiple values with result='data'

Using _eval to supress multiple values with result='temp'

Version

1.0

Ref

t.24

Date

16 March 1999

XML Script homepage | Documentation home | XML Script docs | Command list | Function list | X-Tract docs

X-Stream, X-Tract and XML Script are trade marks of DecisionSoft Limited
© Copyright 1998-2000 DecisionSoft Limited