XFA Specification
Chapter 9, Automation Objects
Document Variables
295
<image name="DocPicture"
href="…/PictureOfDog.jpg"/>
<image name="CatPicture"
href="…/PictureOfCat.jpg"/>
</variables>
<field name="PersonalizedPicture">
<imageEdit/>
<calculate>
<script>if (CatOrDogLover==1) then CatPicture
else DocPicture endif;</script>
</calculate>
</field>
<exclGroup name="CatOrDogLover" … >
<field … >
<ui> <checkButton shape="round">… </checkButton> </ui>
<caption … >
<value>
<text>Cat Lover</text>
</value>
</caption>
<items>
<integer>1</integer>
</items>
</field>
<field y="9.525mm" w="60.325mm" h="9.525mm">
<ui> <checkButton shape="round">… </checkButton> </ui>
<caption … >
<value>
<text>Dog Lover</text>
</value>
</caption>
<items>
<integer>2</integer>
</items>
</field>
</exclGroup>
</subform>
It is conventional to place a single
variables
element in the root subform to hold all document
variables, but this is only a convention. Any subform can hold a variable element.
Variables Used to Define Named Script Objects
XFA allows variables (
variables
objects may be referenced using the familiar class expression,
object.property
or
object.method()
.
Instantiation of Named Script Objects
Subforms are instantiated during data binding. At the same time, the variables contained in each subform
are instantiated. If multiple occurrences of the same subform are instantiated, then each instance has its
individual set of variables.