2010-12-02 26 views
0

我正在使用Adobe Livecycle Designer和XML文件爲項目創建一些PDF表單。我創建了一個XSD,這在其他包含的選擇的無限序列,例如像下面這樣:將XSD選擇元素表示爲LiveCycle Designer PDF表單

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

在Adobe LiveCycle Designer中表示這一點,我有類似以下內容:

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

當有人按下AddItem1Button,我用下面創建一個新的ItemsSubForm實例:

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

而對於AddItem2Button相反的事。

問題是,除了手動插入項目,我也希望能夠使用XML文件,因此我創建了上面的XSD。我還使用綁定將XSD中的Item1和Item2元素分別與Item1Wrapper和Item2Wrapper相關聯。問題是,一旦我在XML中有一個Item1元素,就會創建Item1Wrapper和Item2Wrapper(並且與Item2相同)。有什麼辦法來控制加載,以隱藏相應的包裝?

我想告訴你,不幸的是我不能改變PDFForm或XSD。

回答

1

如果我理解正確,解決方案必須僅限於更改XML文件。

我不認爲你可以在不改變PDF格式的情況下解決這個問題,因爲你將它設置爲始終插入ItemsSubForm的兩個子項。

您應該已經使用了選擇子窗體或重複與每個項目相關的設置包裝器(對每個數據項重複最小計數= 0)。

1

如果選擇確實很簡單,可以使用xsd:枚舉。否則,你的複雜類型應該是這樣的:

<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"/> 

和你的綁定在「列表項」動態屬性對話框應該是

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

假設你把myItems元素只是在根元素你架構。