Looping on DocumentList

Hi all,

I am new to webMethods working on version 6. I have a with looping on a document list.

Here is the document structure that will be used as input

  1. Root(Document)
    1.1) Parent(DocumentList)
    1.1.1) Child1.1(String)
    1.1.2) Child1.2(Document)
    1.1.3) Child1.3(DocumentList)
    1.1.3.1) Child1.3.1(String)

I have an XML file as input and mapping to a fixed format flatfile. I created the document as

per the input XML file. I do have some more Childnodes repeating down the Child1.3

Following is the occurences of elements
1.1 Parent : 1 or more times
1.1.3 Child1.3 : 0 or more times

Given below are the steps I am using.

  1. getFile
  2. XMLStringToXMLNode
  3. XMLNodeToDocument.
  4. Loop on parent
    4.1) Sequence

it is Ok till Step 3. The processing and result after the 3rd step varies depending on the

occurrence of the Document List values in the above structure.

Case#1)
If Parent node occurs only once, the structure will be
1)Root
1.1) Parent
1.1.1) Child 1.1

Case#2)
If Parent node occurs more than once, the structure will be

  1. Root
    1.1)Parent
    1.1.1)Parent[0]
    1.1.1.1) Child1.1.1

Here is the problem. The Sequence step with #4.1 will be executed only in Case#2, but not in Case#1, because of the difference in strucutres. My complete logic will be in & after this sequence step. The same problem occurs for all the consecutive repeating Child elements.

How can I loop on the parent node without caring for the occurences?. Is there any wrong in my approach or is there any other way around?

Any help is appreciated.

-Sateesh

try invoking IO.idata.readAndWriteDocumentList in the WmSamples package.
Pass in your “Parent” to the service in.
What it’s supposed to do is if there is only one occurrence of Parent it will still force it to be a list. Therefore you only have to code for list situations.

HTH

Or you can create a document of structure for input XML, then set the parent as document list. In the parsing service, choose the document as your schema.

Thanks for the immediate response.

But did not solve my problem though. When I used “IO.idata.readAndWriteDocumentList” and sent Parent as the input, all the document $ DocumentLists that are within/under the Parent are converted to Strings. Hence I cannot go ahead with further mapping since I also have to map all the data that follows down under.

What I need to know is the reason for variance in result structures based on the occurence of the DocumentList fields as specified in Case#1 and Case#2 and how to proceed further with the mapping by looping on the DocumentList fields.

Help is really appreciated

Sateesh,

When the pub.xml:XMLDocumentToNode executes in the case where only one “parent” exists does the resulting record structure show the parent node as a document or document list?

If it is not a document, try one or both of the following:

  1. In the arrays input parameter type the name of the “parent” record to force this service to create the parent node as a document list. [*]In the documentTypeName input parameter specify the fully qualified (folder.subfolder:docTypeName) of the documentType structure that you want to impose on the resulting document.

These input parameters are explained in the IS Built-In Services Guide found in your <developerroot>\doc folder.

HTH,

Mark

Thanks Mark for your valueble suggestion.

To answer your question. If there is only one Parent the resulting Structure is Document, but if there are multiple parents the result is a DocumentList of Parents.

I used your 2nd condition, the result structure pops up as a DocumentList regardless of the occurences. This is what I actually need to loop further on DocumentList

I appreciate your help.

Hi,
I want to loop through a stringList(source) and map it to a documentList within a documentList.
How do i loop through it.
Please advice

Thanks,
Sana

Sana,

Look in the built-in services guide for documentation on how to use the pub.list:stringListToDocumentList service.

Search the forums here for many discussions on iterating over document lists.

Mark