Writing XFA Scripts

Simply seeing all of the elements that make up the XFA vocabulary isn't quite sufficient to learn how to create useful XFA scripts. However, it does provide you with a basic understanding of the XFA scripting language's capabilities. This section will introduce you to some practical examples of scripts created in XFA that perform some interesting tasks.

Reading from a Text File

One interesting usage of XFA is to read data from text files and incorporate it into a Web page. Listing 28.3 contains code for the Fortune.xfa script, which reads a list of quotes (fortunes) from a text file and displays them on a Web page.

Listing 28.3. The Fortune.xfa XFA Script that Displays Fortunes Read from a Text File
 <xfa:function Fortune> ...

Get XML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.