pub.list:appendToDocumentList

How to use appendToDocumentList before the loop?

Hi,

can you describe your issue in detail please?

Regards,
Holger

This is the main xml structure:


letter C
letter D
letter D
letter F

I need to insert below xml after element above.

<G.G>letter G.G</G.G>
<G.H>letter G.H</G.H>


<G.G>letter G.G</G.G>
<G.H>letter G.H</G.H>


<G.G>letter G.G</G.G>
<G.H>letter G.H</G.H>

The final output should be like this:


letter C
letter D
letter D
letter F

<G.G>letter G.G</G.G>
<G.H>letter G.H</G.H>


<G.G>letter G.G</G.G>
<G.H>letter G.H</G.H>


<G.G>letter G.G</G.G>
<G.H>letter G.H</G.H>


Hi,

prepare a sub-document named G with fields G.G and G.H.

are the three entries in your sample the same or different each?

Initialize a (temporary) list of documents of type G → temp_G.
Loop over your source list (InputArray = source_List)

  • fill fields G.G and G.H to new instance of doc_G accordingly.
  • add doc_G to list temp_G (inList=outList = temp_G, inDoc = doc_G)
  • drop doc_G
    Add temp_G to list A/B (inList=outList= A/B, inDoc=temp_G)
    Here you can drop the temp_G list when no longer needed.
    Go ahead with your document A as needed.

Make sure that variable doc_G ist not used before the loop otherwise you might receive unpredictable behaviour in your service.
Use the loop when the different entries of G-list are different.
When the different entries of G-list are identical (wondering why they have to be present several times then) you can preprare one doc_G and add this to the temp_G list as many times as needed (i.e. by a REPEAT-step) and drop it (doc_G) afterwards.

Regards,
Holger

1 Like