Radzmar has written a macro that makes Listing all fields in a form method I described in a previous blog a lot easier.
The macro contains the XSLT so you no longer need to copy it around and the macro also resolves the namespace so the XSLT will work for all Adobe Reader target versions.
Run the macro and you will be prompted to save the XML file that can be opened into Microsoft Excel as an XML table, without having to make temporary changes to your XDP file.
Download the macro in XFAObjectList.zip which contains the JavaScript of the macro and the macro.xml file Designer uses to create the Tools ... Macros menu items.
This is a copy of Adobe LiveCycle Designer Cookbooks I had on the Adobe Developer Connection before they stopped being available. There are also some code samples used in answering questions on the LiveCycle Designer forum.
Search This Blog
Showing posts with label macro. Show all posts
Showing posts with label macro. Show all posts
Sunday, 9 February 2014
Tuesday, 19 November 2013
XML Schema minOccurs="0" handling
If you define a data connection using an XML Schema you can specify a minOccur="0" attribute to allow an element to be omitted from the resulting XML. So an XML Schema element defined as;
<xs:element name="preferredContactMethod" type="preferredContactMethodType" minOccurs="0"/>
Will produce a data connection description of;
<preferredContactMethod dd:minOccur="0" dd:nullType="exclude"/>
And the resulting XML will not contain a preferredContactMethod element if the value is null.
It is the nullType="exclude" attribute that controls the handling of the empty element. However, Designer only sets this attribute on simple types. If the minOccurs="0" is on an element that contains child elements or an attribute (that is complex types) then the nullType="exclude" attribute is not added to the data connection description, which can cause the resulting XML to fail schema validation.
This macro will go though the form data description and add the missing nullType="exclude".
Here is a sample form that shows the differences, ComplexTypeNullTypeExclude.pdf. The same fields are duplicated with the first set having the default behaviour and the second set that has been updated by this macro.
And here is the macro, AddNullTypeExcludeToComplexTypes.zip. Extract the files to the macros directory of your Designer ES3 (or later) install and you will now get a "Add dd:nullType="exclude" to complex types" option in the Tools ... Macros menu. (In Designer ES2 you need to extract the files to the Scripts directory of your install and the menu option will be AddNullTypeExcludeToComplexTypes.
<xs:element name="preferredContactMethod" type="preferredContactMethodType" minOccurs="0"/>
Will produce a data connection description of;
<preferredContactMethod dd:minOccur="0" dd:nullType="exclude"/>
And the resulting XML will not contain a preferredContactMethod element if the value is null.
It is the nullType="exclude" attribute that controls the handling of the empty element. However, Designer only sets this attribute on simple types. If the minOccurs="0" is on an element that contains child elements or an attribute (that is complex types) then the nullType="exclude" attribute is not added to the data connection description, which can cause the resulting XML to fail schema validation.
This macro will go though the form data description and add the missing nullType="exclude".
Here is a sample form that shows the differences, ComplexTypeNullTypeExclude.pdf. The same fields are duplicated with the first set having the default behaviour and the second set that has been updated by this macro.
And here is the macro, AddNullTypeExcludeToComplexTypes.zip. Extract the files to the macros directory of your Designer ES3 (or later) install and you will now get a "Add dd:nullType="exclude" to complex types" option in the Tools ... Macros menu. (In Designer ES2 you need to extract the files to the Scripts directory of your install and the menu option will be AddNullTypeExcludeToComplexTypes.
Subscribe to:
Posts (Atom)