Expand my Community achievements bar.

Reading Complex Data Type items into my Process

Avatar

Former Community Member
Hello,



My process reads in a form that contains a list of items that have been defined as in the schema as complexType. The process needs to look at each item line and make routing decisions based on the content of the data. How do I get the process to iterate thru the list of items in order to view the contents of the data?



Thanks in advance.
14 Replies

Avatar

Level 9
Hi Hope

There are two ways that I know of doing this:

1. Create a looping construct in your process. Create a variable, and refer to your data something like:

/process_data/myform/..etc../complexitem[1]/subitem

/process_data/myform/..etc../complexitem[2]/subitem

etc.

If you want to use a variable you'll need something like this:

/process_data/myform/..etc../complexitem[number(/process_data/@counter)]/subitem



2. Use our XMLIterator component. This will automatically iterate over the repeating data in your form, and invoke a subprocess for each repeating element it finds.

We haven't released this component yet, if you want a preview, email: info@avoka.com

This will be released in the next couple of weeks, watch www.avoka.com



Good luck

Howard

Avatar

Former Community Member
Hello Howard,



Thanks for your suggestion. I tried both:



/process_data/myform/..etc../complexitem[1]/subitem

/process_data/myform/..etc../complexitem[2]/subitem

etc.

If you want to use a variable you'll need something like this:

/process_data/myform/..etc../complexitem[number(/process_data/@counter)]/subitem



but I still only get the 1st item on the list. All others come in to the process as null. I'm using a Static form, could this be the issue?

Avatar

Level 10
What Howard proposed should work. I've used it many times.



Can you try the following xPath:

get-collection-size(/process_data/myform/..etc../complexitem) to make sure you get more than one element and store that in an int variable.



Also remember xPath is 1 based, so your loop should start from 1 to the size of your collection.



Jasmin

Avatar

Former Community Member
Hi Jasmin,



Thank you for your suggestion. I added the get-collection-size XPath and the variable returns 1, although I entered three lines in the form.



I know this is a simple task, what could be so different about my form?



Hope

Avatar

Level 10
Are you sure your querying the right node? I could be different depending of the binding.



The best thing would be to use the Variable Logger (under Foundation) to log the content of the variable in a file and inspect the content to make sure the data file is what you expect.



If you don't see all the data in there, then we'll focus around the form design.



At least we know you xPath statement is fine :).



Jasmin

Avatar

Former Community Member
Jasmin, Thanks for your response. Below is the schema definition, my variavle mappings, and the Logger information returned. I entered three Asset Type lines in the form. I need the data entered in the element name="Type". You'll notice in the log only first one has data. <br /><br />Schema item:<br /><br /><xsd:element name="Assets" type="ctAsset"/><br /><br /><xsd:complexType name="ctAsset"><br /> <xsd:sequence><br /> <xsd:element maxOccurs="unbounded" minOccurs="1" name="Asset"><br /> <xsd:complexType><br /> <xsd:sequence><br /> <xsd:element name="Desc" type="xsd:string"/><br /> <xsd:element name="IsNew" type="xsd:boolean"/><br /> <xsd:element name="Count" type="xsd:integer"/><br /> <xsd:element name="Location" type="xsd:string"/><br /> <xsd:element name="IsTaxable" type="xsd:boolean"/><br /> <xsd:element name="Type" type="xsd:string"/><br /> <xsd:element name="MinorCategory" type="xsd:string"/><br /> <xsd:element name="Cost" type="xsd:float"/><br /> </xsd:sequence><br /> </xsd:complexType><br /> </xsd:element><br /><br />Heres my variable mappings and Log returns:<br /><br />Location:<br />/process_data/@formCollectionSize<br />Expression:<br />get-collection-size(/process_data/carForm/object/data/xdp/datasets/data/C0457/Assets/Asset)<br />Variable Logger:<br />@formCollectionSize - java.lang.Integer: 1<br /><br />Location:<br />/process_data/@assetType1<br />Expression:<br />/process_data/carForm/object/data/xdp/datasets/data/C0457/Assets/Asset[1]/Type<br />Variable Logger:<br />/process_data/@assetType1 - String: AIRCRAFT<br /><br />Location:<br />/process_data/@assetType2<br />Expression:<br />/process_data/carForm/object/data/xdp/datasets/data/C0457/Assets/Asset[2]/Type<br />Variable Logger:<br />/process_data/assetType2: null<br /><br />Location:<br />/process_data/@assetType3<br />Expression:<br />/process_data/carForm/object/data/xdp/datasets/data/C0457/Assets/Asset[3]/Type<br />Variable Logger:<br />/process_data/assetType3: null

Avatar

Level 10
Can you write the carForm variable to the file system using the File Utils service.I'm curious to see if the data is in the xdp at all.



Jasmin

Avatar

Level 9
The easiest way to check whether your form has the data correctly is to assign it to another user in the process. Does that user see all three rows?

Another trick is to assign the data part of your form variable to an xml variable, and then use variable logger to log that:

ie.

/process_data/myxml = /process_data/carForm/object/data/xdp/datasets/data/C0457



One of the common problems is that you need to set Asset in your XML schema to an unbound (0..infity) cardinality.



Hope this helps...



Howard

http://www.avoka.com

Avatar

Former Community Member
Jasmin, Howard thanks for your reply. I assigned the form to another user, only first row shows in form even though I entered three lines.

I assigned the data part of the form to a xml variable, entered three lines, first one was AIRCRAFT (I didn't fill out data in the other Asset fields), and this is what the logger returned for Assets:

-
-





AIRCRAFT



$0

Other data that I entered in the form showed up in the xml variable like:
1234567899
and 2
which is a boolean type field.

Howard, not sure what you mean by "you need to set Asset in your XML schema to an unbound (0..infity) cardinality."

Thanks, Hope

Avatar

Level 9
Hi Hope

Please send your form and XML schema (if any) to info@avoka.com

Howard

Avatar

Former Community Member
Can you please provide an update? I am experiencing this problem as well. I've followed every piece of advice as well as every example availalbe yet still only one row of data is present even though the XML clearly has multiple "records" in it.



Please help!

Avatar

Level 9
How do you know that the "XML clearly has multiple "records" in it."?



My comment about "unbounded" means this:

maxOccurs="unbounded" in your xsd.

I checked above, and it's okay.



Howard

Avatar

Former Community Member
The multiples are there because I created the XML for testing. They are really elements - sorry for the incorrect terms. It turns out that I did the following and it works for me so I hope this is useful for another. I followed the help and it didn't work - messing around I arrived at this working recipe:



Subform Binding : Normal

Table Binding : Normal

Header (Table) Binding : Normal

Subform Binding : Normal

Lines (Table) Binding : $record.expenseDetail

Row Binding : elements[*]

Attribute1 date

Attribute2 perDiem

Attribute3 lodging

Attribute4 autoRental

Attribute5 taxi

Attribute6 businessPhone



This help instructions ask for the binding on the Subform and Table to be the same as what I have for the Lines - but it doesn't work for me - only one element is displayed.



Thank you! My worry is fixed today!

Ronni

Avatar

Level 9
Well done.

I would actually make all the bindings till the Table "None", but I'm glad you've gotten it going.

Hope, does this help you?

Howard