title: IIB output XML with multiple root nodes
body: <h1>The Problem</h1>
  <p>Given an MQ input that receives multiple XML messages, I want to output the same messages, but batched into groups of (say) 3.</p>
  <p>e.g. Input (where each line is a new message on the input queue):</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;In1/&gt;
  &lt;In2&gt;&lt;In2a/&gt;&lt;/In2&gt;
  &lt;In3/&gt;
  &lt;In4/&gt;
  &lt;In5 test=&quot;test&quot;/&gt;
  &lt;In6/&gt;
  </code></pre>
  <p>e.g. Output (where each line is a new message on the output queue):</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;In1/&gt;&lt;In2&gt;&lt;In2a/&gt;&lt;/In2&gt;&lt;In3/&gt;
  &lt;In4/&gt;&lt;In5 test=&quot;test&quot;/&gt;&lt;In6/&gt;
  </code></pre>
  <p>The reason for doing this, is in order to batch the messages for transmission, in order to reduce the overhead of sending multiple small messages.</p>
  <h1>What I've tried</h1>
  <p>I've looked at <a href="https://www.ibm.com/developerworks/websphere/library/techarticles/1304_marie/1304_marie.html" rel="nofollow noreferrer">this article</a>, which suggests that using Built-in collection nodes might be an option for such a simple scenario.</p>
  <p>I've tried creating MQInput -&gt; Collector -&gt; MQOutput, but the <a href="https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ac37820_.htm" rel="nofollow noreferrer">Collector node</a> creates a special <a href="https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ac37690_.htm" rel="nofollow noreferrer">MessageCollection</a> object, which isn't quite what I want.</p>
  <p>So I then thought, OK, the Collector brings the messages together - now I just need to create a new message using ESQL - but I can't seem to figure out the ESQL to do it.</p>
  <p>My current attempt:</p>
  <pre><code>DECLARE collection REFERENCE TO InputRoot.Collection;
  MOVE collection FIRSTCHILD NAME 'MessagesIn';
  
  DECLARE I INTEGER 1;
  CREATE LASTCHILD OF OutputRoot.XMLNSC TYPE Name NAME 'Test';
  WHILE LASTMOVE(collection) DO
      SET OutputRoot.XMLNSC.Test.*[I] = collection.XMLNSC.*[&gt;];           
      MOVE collection NEXTSIBLING;
      SET I = I + 1;
  END WHILE;
      
  RETURN TRUE;
  
  </code></pre>
  <p>While this works, it only does so because it creates the single root &quot;Test&quot;, whereas I want my output to effectively have multiple roots.</p>
  <p>But if I remove the Test folder, this then throws errors about the output format, which is as follows:</p>
  <pre><code>( ['GENERICROOT' : 0x3a6d0bc8]
    (0x01000000:Name  ):Properties = ( ['MQPROPERTYPARSER' : 0x422a14d8]
      (0x03000000:NameValue):MessageSet             = NULL
      (0x03000000:NameValue):MessageType            = NULL
      (0x03000000:NameValue):MessageFormat          = NULL
      (0x03000000:NameValue):Encoding               = NULL
      (0x03000000:NameValue):CodedCharSetId         = NULL
      (0x03000000:NameValue):Transactional          = NULL
      (0x03000000:NameValue):Persistence            = NULL
      (0x03000000:NameValue):CreationTime           = NULL
      (0x03000000:NameValue):ExpirationTime         = NULL
      (0x03000000:NameValue):Priority               = NULL
      (0x03000000:NameValue):ReplyIdentifier        = NULL
      (0x03000000:NameValue):ReplyProtocol          = 'UNKNOWN' (CHARACTER)
      (0x03000000:NameValue):Topic                  = NULL
      (0x03000000:NameValue):ContentType            = NULL
      (0x03000000:NameValue):IdentitySourceType     = NULL
      (0x03000000:NameValue):IdentitySourceToken    = NULL
      (0x03000000:NameValue):IdentitySourcePassword = NULL
      (0x03000000:NameValue):IdentitySourceIssuedBy = NULL
      (0x03000000:NameValue):IdentityMappedType     = NULL
      (0x03000000:NameValue):IdentityMappedToken    = NULL
      (0x03000000:NameValue):IdentityMappedPassword = NULL
      (0x03000000:NameValue):IdentityMappedIssuedBy = NULL
    )
    (0x01000000:Folder):XMLNSC     = ( ['xmlnsc' : 0x31d412c8]
      (0x01000000:Folder):In1  = 
      (0x01000000:Folder):In2  = (
        (0x01000000:Folder):In2a = 
      )
      (0x01000000:Folder):In3  = 
    )
  )
  </code></pre>
  <p>The error message reads:</p>
  <pre><code>        (0x03000000:NameValue):Text            = 'XML Writing Errors have occurred' (CHARACTER)
          (0x01000000:Name     ):ParserException = (
            (0x03000000:NameValue):File     = 'F:\build\slot1\S900_P\src\MTI\MTIforBroker\GenXmlParser4\ImbXMLNSCWriter.cpp' (CHARACTER)
            (0x03000000:NameValue):Line     = 976 (INTEGER)
            (0x03000000:NameValue):Function = 'ImbXMLNSCWriter::writeMisc' (CHARACTER)
            (0x03000000:NameValue):Type     = '' (CHARACTER)
            (0x03000000:NameValue):Name     = '' (CHARACTER)
            (0x03000000:NameValue):Label    = '' (CHARACTER)
            (0x03000000:NameValue):Catalog  = 'BIPmsgs' (CHARACTER)
            (0x03000000:NameValue):Severity = 3 (INTEGER)
            (0x03000000:NameValue):Number   = 5016 (INTEGER)
            (0x03000000:NameValue):Text     = 'Unexpected XML type at this point in document.' (CHARACTER)
            (0x01000000:Name     ):Insert   = (
              (0x03000000:NameValue):Type = 5 (INTEGER)
              (0x03000000:NameValue):Text = 'In2' (CHARACTER)
            )
            (0x01000000:Name     ):Insert   = (
              (0x03000000:NameValue):Type = 5 (INTEGER)
              (0x03000000:NameValue):Text = 'folderType' (CHARACTER)
            )
  </code></pre>
  <h1>The Question</h1>
  <p>The parts to the question are:</p>
  <ol>
  <li>Is there a better way of aggregating these messages?</li>
  <li>If having multiple root elements is invalid according to the XMLNSC writer, is there another way around it? Treat it as a BLOB rather than XML, maybe?</li>
  </ol>