Highlighted

Concatenate fixed text with datafields under certain conditions

Avatar

11-08-2008

Hi,<br /><br />I need to concatenate fixed text with different (occurrences of) datafields into one fluent text. <br />All the data can be found in one XML but under several paths. There are also fields of 1..n datasets from which I want to concatenate fields under certain conditions. <br />In order to build this text, I also need to know before the loop, how many records I have in de 1..n dataset.<br /><br />The datastructure is as follows (L = Level T = Table):<br /><br /><L1-T1> - 1..1<L2-T1> - 0..1<L3-T1> - 1..n<L4-T1><br /> - 1..n<L3-T2> - 0..1<L4-T2> - 1..n<L5-T1><br /><br />I need data from <L3-T1>, selection of <L4-T1>, each <L4-T2> and a selection of <L5-T1>.<br /><br />Can anybody help me sort this problem?<br /><br />Many thanks in advance,<br /><br />Gert

Replies

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

11-08-2008

Are you intending to do this at load time or is this an interactive exercise? Does each one of the nodes in the XML have a corresponding field on the form?
Highlighted

Avatar

11-08-2008

This is intended to use at load time and the fields are nowhere else on the form. I want to compose letters for different clients.
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

11-08-2008

So your data file would have multiple letters (of the same format) for different clients and you want to produce multiple letters with the same data merge operation ....right?



If so is the data structure for each letter the same ....for example the salutation is the same but the name changes (Dear Paul, or Dear Jean W. Smith .....).
Highlighted

Avatar

11-08-2008

Yes,



Data structure, the fixed text and conditions are the same for all clients, only the data in the DB is different.
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

12-08-2008

Then I suggest creatinng a template that represents the letter. Where varaiable data is supposed to go you can use a floating field. The floating can exist within a clock of text and you can bind an inbound data value to that field. Once the data is merged the field becomes text and the block is flowed again so that any additional spacings around the field are removed.



To add a floating field put the cursor in the text block location where you want the field to be. Under the Insert Menu choose Floating Field. The field is represented in the text block with a {TextField1}. A new entry is made in the hierarchy view. To set properties for the field highlight the object in the hierarchy view and the object palette (which also has the binding) will become active. Simply bind the field to the node in your XML and when you merge the template and data together it will take care of substituting the data into the field for you.
Highlighted

Avatar

12-08-2008

I'm already using it that way, but it doesn't work if you want to create fluent text with more than one occurence of the same field.

For example if you want to list it like this:

<<L5-T1>Var[0]>, <<L5-T1>Var[1]>, <<L5-T1>Var[2]> and <<L5-T1>Var[3]>...

without knowing how many occurrences there will be.

I can list up more occurrences of one variable but it is always listed one after another as in a table, instead of next to eachother as in a fluent text. In addition, I also need to be able to add text between the different variables.
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

12-08-2008

That makes it a lot more complicated ..... maybe it makes more sense to simply load the data into the data dom and write script to bind the information yourself. You could add multiple fields together and concatinate nodes as much as you want before setting the value of the fields.



Or you coudl manipulate the data using XSLT before you bind the data to the foem. In either case there is code to write.
Highlighted
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

13-08-2008

To get access to the data dom yopu would use the notation xfa.datasets.data. To get a feel for manipulating the Dom I suggest putting a large (lemgth and width) field on the form (this is temporary and only for debugging - once you figure out what to do you can delete the field). Make sure that it is visible and multi-line is set on. Now add a button - on the button click event do this command:



FieldName.rawValue = xfa.datasets.data.saveXML("pretty");



This will dump the data dom into the field so you can see the structure of it (the pretty flag is used to format the result into a nicer format for reading). Now that you see the structure you can access individual nodes in the xml by navigating to it. So you expressions look something like this:



xfa.datasets.data.form1.addressInfo.streetName.value



Note that to get the actual contents of the node the value property is used ....not the rawValue like in a field (this trips everyone up).



You can use methods like nodes to return back all nodes below a certain node. Once I have the nodes in an object I can get a length and loop through the different nodes to perform the operations that I want.



That should be enough to get you started.



Let me know how it turns out.