Adobe LiveCycle XML Data Binding

We are generating the XSD from an example instance XML, and then using JAXB to generate java classes based on the resulting schema. These generated classes are used to populate the XML that will eventually be bound to the Adobe XDP Form to produce a dynamically populated PDF.

XSD

  • XML schema snippets (defines some phone number info):
<xs:complexType name="templateType">
  <xs:sequence>
   <xs:element type="tem:phonesType" name="phones"
       xmlns:tem="http://foo.com/foo/xmlbeans/template"/>
   ...
  </xs:sequence>
 </xs:complexType>

 <xs:complexType name="phonesType">
  <xs:sequence>
    <xs:element type="tem:mobileType" name="mobile"
        xmlns:tem="http://foo.com/foo/xmlbeans/template"/>
    ...
  </xs:sequence>
 </xs:complexType>

 <xs:complexType name="mobileType">
  <xs:simpleContent>
   <xs:extension base="xs:string">
    <xs:attribute type="xs:string" name="number"/>
    <xs:attribute type="xs:string" name="area-code"/>
   </xs:extension>
  </xs:simpleContent>
 </xs:complexType>

Java

  • Java code snippet to populate the mobile phone XML for data binding:
MobileType mobileType = ObjectFactory.createMobileType();
 mobileType.setNumber(number);
 mobileType.setAreaCode(areaCode);

XML

  • Example populated XML snippet with mobile phone data:
<mobile number="555-5555" area-code="416"/>

XDP

  • XDP Adobe form snippet (displays the mobile phone area code):
<field h="0.160in" name="Area_Code1" w="0.481in" x="3.717in" y="4.413in">
 <ui>
    <textEdit>
    </textEdit>
 </ui>
 <para vAlign="middle"/>
 <font size="9.0pt" typeface="Arial"/>
 <border>
    <edge cap="butt" thickness="0.012in">
       <color value="255,255,204"/>
    </edge>
    <fill>
       <color value="255,255,203"/>
    </fill>
 </border>
 <bind match="dataRef" ref="$record.phones.mobile.area-code"/>
</field>
It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply