Question

I'm using Adobe Livecycle Designer and XML files to create some PDF forms for a project. I created an XSD, which among others contains an unbounded sequence of choices, for example something like the following:

<xs:sequence maxOccurs="unbounded">
  <xs:choice>
    <xs:element name="Item1" type="xs:string" />
    <xs:element name="Item2" type="xs:string"/>
  </xs:choice>
</xs:sequence>

To represent this in Adobe Livecycle Designer, I'm having something like the following:

MyForm (Subform)
  ItemsSubForm (Subform, repeated for many items)
    Item1Wrapper (Subform)
      Item1 (TextField)
    Item2Wrapper (Subform)
      Item2 (TextField)
  AddItemsButtonsSubForm
    AddItem1Button (Button)
    AddItem2Button (Button)

When someone presses AddItem1Button, I create a new ItemsSubForm instance using the following:

this.parent.parent._ItemsSubForm.addInstance();
xfa.resolveNode("this.parent.parent.ItemsSubForm[" +(this.parent.parent.ItemsSubForm.instanceManager.count - 1) + "]").Item2Wrapper.presence = "hidden";

And the opposite thing for AddItem2Button.

The problem is that apart from inserting items manually, I also want to be able to use an XML file, and for that reason I created the XSD above. I also use bindings to associate Item1 and Item2 elements from the XSD with Item1Wrapper and Item2Wrapper respectively. The problem is that once I have an Item1 element in the XML, both Item1Wrapper and Item2Wrapper are created (and the same with Item2). Is there any way to control the loading in order to hide the respective wrapper?

I would like to inform you that unfortunately I cannot change either the PDFForm or the XSD.

Was it helpful?

Solution

If I understand you correctly, the solution has to be limited to changing the XML file.

I don't think you'll be able to solve this without changing the PDF form, as you set it up to ALWAYS insert BOTH children of ItemsSubForm.

You should've used either a choice subform or repeat settings associated with each Item?Wrapper (repeat for each data item, Min Count = 0).

OTHER TIPS

If the choices really are fairly simple you could use an xsd:enumeration. Otherwise your complex type should look like this:

<xs:complexType name="ItemList">
    <xs:sequence>
       <xs:element name="item" type="xs:string" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>
<xs:element name="myItems" type="ItemList"/>

and your bindings in the 'List Items' dynamic properties dialog should be

Items:   $record.myItems.item[*]
Item Text:   $
Item Value:  $

assuming that you put the myItems element just under the root element in you schema.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top