Author |
Message
|
akil |
Posted: Thu Jul 23, 2015 6:55 am Post subject: IIB9: Mapping Node fn:count/fn:foreach |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
I am using a mapping node, to create an output that looks like the following
Code: |
<output>
<numResults/>
<resultSet>
<item/>
<item/>
....
</resultSet>
</output>
|
The number of items in the resultSet are to be limited to what the client wants.
I can achieve this by putting a 'condition' on the 'for-each' transform that is creating the 'item' elements.
I am unable to figure out how do I set the numResults correctly.. as I've to set this as the minimum of the input value and the count of 'items' in the result set.
Any ideas? _________________ Regards |
|
Back to top |
|
 |
nelson |
Posted: Thu Jul 23, 2015 8:00 am Post subject: |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
What about wiring your output element as an input element of numResults, using count function? I have not tried this, but.. I guess it could work...  |
|
Back to top |
|
 |
martinb |
Posted: Wed Jul 29, 2015 12:45 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
Yep
Wire a Custom XPath from the source ResultSet to the "numResults" and use, assuming you "max items" limit is 10
if (fn:count($ResultSet) < 10) then fn:count($ResultSet) else 10 |
|
Back to top |
|
 |
akil |
Posted: Wed Jul 29, 2015 11:53 pm Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Thanks martinb, this worked.
One small quirk though, the toolkit gives a 'warning' as follows :
Code: |
The else element in XPath if (fn:count($Benef) < $numBeneficiaries3) then fn:count($Benef) else $numBeneficiaries3 was not found in the XML Schema. |
It does still work on the runtime, so going ahead for now.. _________________ Regards |
|
Back to top |
|
 |
martinb |
Posted: Thu Jul 30, 2015 12:03 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
Hi akil
Glad to hear you got this working.
"small quirk, the toolkit gives a 'warning' ..."
That will be a bug in the XPath validation.. the thread does not state what version you have, I'd hope it might already be fixed in latest. |
|
Back to top |
|
 |
akil |
Posted: Thu Jul 30, 2015 1:31 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
I've 9.0.0.2 ..Will try 9.0.0.3 and check
Regards
Akhilesh _________________ Regards |
|
Back to top |
|
 |
|