Expand my Community achievements bar.

Dynamic data, dynamic templates

Avatar

Level 1

Hello--

I've been using LiveCycle Designer for a while but am relatively new to engaging with the scripting interface. Im trying to create a dynamic PDF template that will be processed by LiveCycle Server to create a PDF document containing "read only" form fields. This document would be generated by combining contents from a complex/nested XML file with a dynamic template containing a number of subforms that are rendered based upon which node is encountered in the XML document.

Im trying to wrap my head around how to accomplish this. Questions I have so far:

* Since LC Server will be processing the form template do I need to create a data connection in my template?

* How do I load the XML data source into the document DOM so I can parse that data for nodes and values I want to display? (this would be the same data that LC Server uses as a source for the merge with the template)....or would LC Server do all the XML parsing and hand off "content" to the template subforms to display?

* Upon finding the XML node or value I want to render in the PDF document, how do I bind this to a subform or subform set?

* Since the XML data contains multiple levels of nested data how would I recursively nest subforms?

Can anyone provide a basic outline of how to approach this, perhaps with relevant sample functions I need to call? I've done quite a bit of PHP development and think I could run with this project with a little bit of guidence from LiveCycle forms/templates experts. Im basically completely new to LC scripting and the form object model and various DOMs.

thanks again--any advice, direction, sample code appreciated

Paul

5 Replies

Avatar

Former Community Member

1. Yes you will need a dataconnection in your template. Ideally you woudl have a schema that will define the structure of the data but if you do no sample data will do the job.

2. By creating a dataconnection you can bind the fields that you want to hold the data to the corresponding nodes in the dat structure. This means that you shoudl not have to do any coding to get the data into your fields. When you render the form you can pass in a data file and it will merge the template and data file together putting the right xml values into the associated bound fields.

3. If there are multiple subforms present and you only want one to appear based on the presence of a data value in the data then you woudl wrap all subforms into a subform set and create a rule that woudl tell the form, which subform you want based on the value of a node in the XML data.

4. In the binding expressions multiple occurring data is denoted by adding a [*] ...indicating that this data is repeating. You shoudl not have to deal with this it will just happen.

Paul

Avatar

Level 1

Thank you for your reply Paul.

Regarding setting up subform sets: the XML data that will be deposited into the watch folder will likely contain many levels of nodes. Here's a webpage that shows the complexity of the XML data (XML parsed into multidimensional array):


http://construction.paulperreault.com/corexml/raw.php

Will creating a subform set with subforms set to appear conditionally (by matching node names) work for complex/nested data like this?

thanks again,

Paul

Avatar

Former Community Member

It shoudl work but the level of complexity will be very high.

Paul

Avatar

Level 1

Hello Paul--

I have a template working and recursing through two levels of data. The part Im not able to find any information on is how to deal with n levels of data. As you can see in the files I've uploaded the XML file has at least 4 levels of component data. In the attached template you can see that I've tried to "force" a 3rd level but the binding xpath doesnt resolve to anything in the data binding/schema.

It seems like you should be able to map fields according to your data binding but then substitute wildcards in the binding paths to allow for recursion. Like you mentioned above you would use [*] wildcards to denote multiple rows under a node--is there some syntax for the field binding path that allows for arbitrary depth in the data source?

Thanks again for replying to my questions--

PP

Avatar

Level 1

I thought I'd post an update on this topic:

I now have a template that can display data from my XML file up to 10 levels deep--but doing this required creating 10 subforms that are basically hardwired to each level of the XML data. While this solution should suffice for limited datasets and demonstrations of this concept, Im still searching for a method of creating 1 subform that can be called at any level of data present in the XML file.

Regarding the binding of fields within the subform:

As I mentioned above each subform is bound to a unique level of data within the XML hierarchy like so:

$.hierarchy1.entity.value

$.hierarchy1.entity.hierarchy2.entity.value

$.hierarchy1.entity.hierarchy2.entity.hierarchy3.entity.value

Can anyone recommend a sample dynamic template or tutorial that demonstrates how to create field bindings that dont require a fixed path to each level of the XML hierarchy?

thx again

PP