In this case we will produce a list of all the field objects that we can view in Microsoft Excel, so we will also use Excel to run the XSLT.
First download the XSLT file, XSPFieldList.xslt , and place it in the same directory as the XDP file of your form.
Edit your form XDP file using Notepad or similar and add the following line after the XML declaration;
<?xml-stylesheet type="text/xsl" href="XDPFieldList.xslt"?>
So it should look something like;
There is a line in the XSPFieldList.xslt that looks like;
xmlns:xfa="http://www.xfa.org/schema/xfa-template/2.8/"
This might need to change to match the namespace in your XDP file (see the last line in the screen shot above) depending on which version of Reader your form is targeting. The namespace ending in xfa-template/2.8 means my form is targeting Reader 9.0 and above. For Reader 9.1 and above it would be xfa-template/3.0.
Now in Microsoft Excel open the XDP file (Excel doesn't know about XDP files so your will have to select "All Files (*.*)" in the Open dialog). The first thing Excel will do is popup an Import XML... dialog;
This means it has found our xml-stylesheet line and wants to confirm we want to run the XSLT, so select "Open the file with the following stylesheet applied (select one):"
You will then get a "different format" message, which is fair enough as the XSLT will have changed the format so select Yes;
Then you get an Open XML dialog, which defaults to "As an XML table" which is what we want to do, so select OK.
The final dialog is the no schema message. We haven't provided a schema so Excel will create one for us. This dialog you can turn off.
The final result will look something like;
There is a lot you can add to the XSLT so think of this as a starting point, and remember to remove the xml-stylesheet line from the XDP as Designer will think the form is created in a new version and not allow you to do much except look at the XML Source.
Response Files
This approach can also be helpful in working with a response file from the collection of returned forms. If you export the responses as XML then they can be processed by an XSLT and loaded into Excel in the same way.If your XSLT produces an HTML document containing a HTML table then Excel will still load it into a spreadsheet, but you now can specify business names for the columns not just the field names from the form, so you can now have spaces in the column names.
The XSLT will also allow you to do some decoding, such as turning 1 and 0 into 'Yes' and 'No' or whatever formatting you want.