Expand my Community achievements bar.

Defining Drop Down List in an XSD

Avatar

Former Community Member
I want to define a drop down list that contains both text and value in an xsd. I found an interestnig article that demonstrates how to use the enumeration in an xsd to define a drop down list but I don't see anything regarding a binding value. http://www.devx.com/Adobe/Article/29157

For Example, I want my text in the drop down list to be Red, Blue, Green but the value it passes back to be R, B, G.

I took a look at the xdp and this is what it looks like

Red
Blue
Green


R
B
G


Any suggestions?
3 Replies

Avatar

Former Community Member
Since you're talking about an "XSD", I take it you're trying to define a node structure in an XML Schema Definition file which Designer's Data Connection palette will recognize as a drop down list so that loading XML Data (which adheres to the schema) will automatically populate a drop down list with text and value (bound) items. Is that correct?



If so, there's an easier way than this: Just use the "Dynamic Properties" feature in Designer 7.1. It's "off" by default so you have to turn it "on" using the
Show Dynamic Properties check box on the Data Binding panel of the "Tools | Options" dialog. Then, select a drop down list and go to the Object palette's Field tab: The
List Items property, amongst others, will be green and underlined. Assuming you have an existing data connection, click on the link and you'll get a dialog which will let you specify which schema node the "text" items should come from and which node the "value" (bound) items should come from.



When you load the form in Acrobat (stand-alone or previewed) and import data into it, your drop down list will automatically be populated with the data pertaining to the schema nodes you bound to the list items.



Stefan

Adobe Systems

Avatar

Former Community Member
Is there any way to embed the data for the list in the schema instead of having to import it? I'm not sure if this is a bug but if I perform an import it seems to blow away any data in the document. If I import once to get the data in there and then the end user does an import it would wipe out the initial data I imported. I have managed dynamically populate a drop down using enumeration but I can't bind the text/value of the drop down.

Avatar

Former Community Member
When data is imported into a form, all the current data is cleared if the source is an XML data file and data was previously imported into the form via another XML data file. It is possible, however, to have multiple data connections from which data is imported simultaneously however only one data connection to a schema (XSD) is permitted. You may have as many data connections to ODBC and WSDL data sources as you wish.



You say you've "managed dynamically populate a drop down using enumeration". I assume this means you've been able to enumerate the nodes in the imported data file and populate the drop down list with information from it?



If that's the case, then you should be adding items to the drop down list programmatically by using its
addItem method:



addItem(
text [,
value]);


where the second parameter is optional and specifies the value associated to the text for a given item.



The only thing you should be missing, then, in order to bind the value of the drop down list to a node in the form's output data is to ensure that the drop down list's Default Binding property (on the Object palette's Binding tab) is set to
Normal or to some explicit data node expression (SOM expression) into a data connection.



Another way to do it, if the drop down list's data is static (i.e. doesn't change depending on the data imported into the form), is to simply enter the items directly into the list by using the Object palette's Field and Binding tabs. You can specify an item's text on the Field tab and its associated value on the Binding tab.



Finally, there's a third option: You can use multiple data connections (the viability of this option will obviously depend on your requirements). For instance, you could load the drop down list's items from a data connection to an XML data file and load the rest of the form's data via an ODBC data connection.



Stefan

Adobe Systems