[Migrated from the Syclo Resource Center]
gmccobb 12/08/2011 17:45,
I am trying to map from a sequence of XML elements in a response such as the following:
<response>
<job-list>
<job>
<jobID>1</jobID>
<customerID>1</customerID>
<jobStatus>suspended</jobStatus>
</job>
<job>
<jobID>2</jobID>
<customerID>1</customerID>
...
</job-list>
</response>
to the object collection of the primary object in the MainObject.
Q: I figured out how to map from the response to a single job object in the collection. Is is possible to map from all the job elements in the response to create an entire collection of jobs at one time? If it is possible, how is it done?
Here is the log for attempting to map between job and all the job nodes in the response. Why doesn't it treat each of the 29 nodes as a separate object, as when the back-end is SQL each row in the result set is a separate object?
2011/12/08 15:39:39.121: Processing Object XML results for the 'GetJobs' request in the 'GetJobs' step
2011/12/08 15:39:39.121: The module is 'Account'
2011/12/08 15:39:39.121: The root object is 'Job'
2011/12/08 15:39:39.121: The Unique ID property for the 'Job' object is 'JobID'
2011/12/08 15:39:39.121: Found 6 properties in the 'Job' object
2011/12/08 15:39:39.121: Found 6 property mappings in the 'GetJobs' HTTP request
2011/12/08 15:39:39.121: The XML nodes in the 'GetJobs' HTTP request map to properties in the 'Job' object as follows:
2011/12/08 15:39:39.121: >XML node 'ns8:job-list/ns8:job/ns8:job-ID' <-> 'JobID' property (1 - the Unique ID for the 'Job' object)
2011/12/08 15:39:39.121: >XML node 'ns8:job-list/ns8:job/ns8:customer-ID' <-> 'CustomerID' property (5)
2011/12/08 15:39:39.121: >XML node 'ns8:job-list/ns8:job/ns8:workflow-ID' <-> 'WorkflowID' property (6)
2011/12/08 15:39:39.121: >XML node 'ns8:job-list/ns8:job/ns8:tenant-ID' <-> 'tenantID' property (9)
2011/12/08 15:39:39.121: >XML node 'ns8:job-list/ns8:job/ns8:start-time' <-> 'starttime' property (10)
2011/12/08 15:39:39.121: >XML node 'ns8:job-list/ns8:job/ns8:job-status' <-> 'JobStatus' property (2)
2011/12/08 15:39:39.121: Processing the XML property mappings for the 'Job' object - row 1
2011/12/08 15:39:39.121: Incoming: NULL context node
2011/12/08 15:39:39.121: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:39:39.121: Compiling XPath: /ns8:get-open-jobs-response
2011/12/08 15:39:39.121: Base xpath returned 1 node
2011/12/08 15:39:39.121: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:39:39.121: + Context Node=get-open-jobs-response
2011/12/08 15:39:39.121: + XPath=ns8:job-list/ns8:job/ns8:job-ID
2011/12/08 15:39:39.121: Compiling XPath: ns8:job-list/ns8:job/ns8:job-ID
2011/12/08 15:39:39.121: 29 nodes found, expecting 1
2011/12/08 15:39:39.121: *** XML node for the unique ID not found: Can't determine object to store current object info in - Skipping row 0
2011/12/08 15:39:39.121: 1 result row was processed
** Here is the log for when I attempted to map putting [<<sum <<size Jobs>> 1>>] in the axis of each property. The mapping is performed only for the first job in the collection:
Processing Object XML results for the 'GetJobs' request in the 'GetJobs' step
2011/12/08 15:57:10.498: The module is 'Account'
2011/12/08 15:57:10.498: The root object is 'Job'
2011/12/08 15:57:10.498: The Unique ID property for the 'Job' object is 'JobID'
2011/12/08 15:57:10.498: Found 6 properties in the 'Job' object
2011/12/08 15:57:10.498: Found 6 property mappings in the 'GetJobs' HTTP request
2011/12/08 15:57:10.498: The XML nodes in the 'GetJobs' HTTP request map to properties in the 'Job' object as follows:
2011/12/08 15:57:10.498: >XML node 'ns8:job-list/ns8:job[1.000000e+000]/ns8:job-ID' <-> 'JobID' property (1 - the Unique ID for the 'Job' object)
2011/12/08 15:57:10.498: >XML node 'ns8:job-list/ns8:job[1.000000e+000]/ns8:customer-ID' <-> 'CustomerID' property (5)
2011/12/08 15:57:10.498: >XML node 'ns8:job-list/ns8:job[1.000000e+000]/ns8:workflow-ID' <-> 'WorkflowID' property (6)
2011/12/08 15:57:10.498: >XML node 'ns8:job-list/ns8:job[1.000000e+000]/ns8:tenant-ID' <-> 'tenantID' property (9)
2011/12/08 15:57:10.498: >XML node 'ns8:job-list/ns8:job[1.000000e+000]/ns8:start-time' <-> 'starttime' property (10)
2011/12/08 15:57:10.498: >XML node 'ns8:job-list/ns8:job[1.000000e+000]/ns8:job-status' <-> 'JobStatus' property (2)
2011/12/08 15:57:10.498: Processing the XML property mappings for the 'Job' object - row 1
2011/12/08 15:57:10.498: Incoming: NULL context node
2011/12/08 15:57:10.498: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:57:10.498: Compiling XPath: /ns8:get-open-jobs-response
2011/12/08 15:57:10.498: Base xpath returned 1 node
2011/12/08 15:57:10.498: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:57:10.498: + Context Node=get-open-jobs-response
2011/12/08 15:57:10.498: + XPath=ns8:job-list/ns8:job[1.000000e+000]/ns8:job-ID
2011/12/08 15:57:10.498: Compiling XPath: ns8:job-list/ns8:job[1.000000e+000]/ns8:job-ID
2011/12/08 15:57:10.498: Text "395" from XML text node
2011/12/08 15:57:10.498: Setting Unique ID String property 'JobID' to "395"
2011/12/08 15:57:10.498: Making new Job 395
2011/12/08 15:57:10.498: Setting other object properties...
2011/12/08 15:57:10.498: Incoming: context node is get-open-jobs-response (Element)
2011/12/08 15:57:10.498: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:57:10.498: + Context Node=get-open-jobs-response
2011/12/08 15:57:10.498: + XPath=ns8:job-list/ns8:job[1.000000e+000]/ns8:job-ID
2011/12/08 15:57:10.498: Text "395" from XML text node
2011/12/08 15:57:10.498: Incoming: context node is get-open-jobs-response (Element)
2011/12/08 15:57:10.498: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:57:10.498: + Context Node=get-open-jobs-response
2011/12/08 15:57:10.498: + XPath=ns8:job-list/ns8:job[1.000000e+000]/ns8:customer-ID
2011/12/08 15:57:10.498: Compiling XPath: ns8:job-list/ns8:job[1.000000e+000]/ns8:customer-ID
2011/12/08 15:57:10.498: Text "1" from XML text node
2011/12/08 15:57:10.498: Setting String property 'CustomerID' to "1"
2011/12/08 15:57:10.498: Incoming: context node is get-open-jobs-response (Element)
2011/12/08 15:57:10.498: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:57:10.498: + Context Node=get-open-jobs-response
2011/12/08 15:57:10.498: + XPath=ns8:job-list/ns8:job[1.000000e+000]/ns8:workflow-ID
2011/12/08 15:57:10.498: Compiling XPath: ns8:job-list/ns8:job[1.000000e+000]/ns8:workflow-ID
2011/12/08 15:57:10.498: Text "1" from XML text node
2011/12/08 15:57:10.498: Setting String property 'WorkflowID' to "1"
2011/12/08 15:57:10.498: Incoming: context node is get-open-jobs-response (Element)
2011/12/08 15:57:10.498: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:57:10.498: + Context Node=get-open-jobs-response
2011/12/08 15:57:10.498: + XPath=ns8:job-list/ns8:job[1.000000e+000]/ns8:tenant-ID
2011/12/08 15:57:10.498: Compiling XPath: ns8:job-list/ns8:job[1.000000e+000]/ns8:tenant-ID
2011/12/08 15:57:10.498: Text "1" from XML text node
2011/12/08 15:57:10.498: Setting String property 'tenantID' to "1"
2011/12/08 15:57:10.498: Incoming: context node is get-open-jobs-response (Element)
2011/12/08 15:57:10.498: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:57:10.498: + Context Node=get-open-jobs-response
2011/12/08 15:57:10.498: + XPath=ns8:job-list/ns8:job[1.000000e+000]/ns8:start-time
2011/12/08 15:57:10.498: Compiling XPath: ns8:job-list/ns8:job[1.000000e+000]/ns8:start-time
2011/12/08 15:57:10.498: Text "2011-11-30T14:01:10-05:00" from XML text node
2011/12/08 15:57:10.498: Setting TimeAndDate property 'starttime' to "2:01:10 PM 11/30/2011" from "2011-11-30T14:01:10-05:00"
2011/12/08 15:57:10.498: Incoming: context node is get-open-jobs-response (Element)
2011/12/08 15:57:10.498: + Base XPath=ns8:get-open-jobs-response
2011/12/08 15:57:10.498: + Context Node=get-open-jobs-response
2011/12/08 15:57:10.498: + XPath=ns8:job-list/ns8:job[1.000000e+000]/ns8:job-status
2011/12/08 15:57:10.498: Compiling XPath: ns8:job-list/ns8:job[1.000000e+000]/ns8:job-status
2011/12/08 15:57:10.498: Text "Processing" from XML text node
2011/12/08 15:57:10.498: Setting String property 'JobStatus' to "Processing"
Thanks in advance,
Gerald McCobb
Bill Froelich 12/08/2011 18:25
Gerald,To map multiple object you set the base XPath to the repeating element. In your example that would be /response/job-list/job Then you can map the individual elements by referencing them as individual elements (jobid, customerid, jobstatus) and point them to the correct object properties in your application. Let me see if I can find a sample app I did awhile ago that I can hopefully share as an example.
Bill Froelich - Director, Consulting at Syclo
gmccobb 12/09/2011 10:25
Hi Bill,Yes that worked!
Thanks again.Regards,Gerald McCobb