Page 1 of 1

XML Pickup for Multiple Values

Posted: Tue Feb 19, 2019 3:34 pm
by matt.baile
Hello. I'm doing an XML pickup and hoping to use the values from the pickup to route orders a certain way. What I have is a structure that looks like this:

Code: Select all

<ORDER_ITEMS>
     <ORDER_ITEM>
          <ORDER_QUANTITY></ORDER_QUANTITY>
     </ORDER_ITEM>
</ORDER_ITEMS>
I could have multiple <ORDER_ITEM> entries or just one, each file will be different. What I need to do is look at each of the quantity fields and find out of there are any that are over 200 copies or possibly say are there any >=200 AND <=25, or something like that. I've only been able to get something like this, where my <ORDER_QUANTITY> is whatever number I highlight. Is there a way to get all of the entries, like an array or nested values?

[Metadata.Text:Path="/TOP/ORDERS/ORDER/ORDER_ITEMS/ORDER_ITEM[1]/ORDER_QUANTITY",Dataset="Xml",Model="XML"]

Re: XML Pickup for Multiple Values

Posted: Tue Feb 19, 2019 6:32 pm
by cstevens
I think this is a limitation with the XML Pickup module. Expressions like this can only resolve to a single value, so when an XPath resolves to multiple values it either errors or returns the first value in the list.

I think you'll need to use a script expression that evaluates to a node list and then parse through the result set.

I think there's a thread on here about using variables in expressions like this. If you could use a variable in place of the 1 you might be able to "loop" a file through the XML Pickup module incrementing that value each time, but that seems like it could cause other issues.

Re: XML Pickup for Multiple Values

Posted: Tue Feb 19, 2019 6:39 pm
by Malcolm Mackenzie
https://www.enfocus.com/en/appstore/pro ... l-repeater
can split the xml to for each entry for sorting, not sure if it will deliver what you want.

Re: XML Pickup for Multiple Values

Posted: Tue Feb 19, 2019 6:39 pm
by Malcolm Mackenzie
https://www.enfocus.com/en/appstore/pro ... l-repeater
can split the xml to for each entry for sorting, not sure if it will deliver what you want.

Re: XML Pickup for Multiple Values

Posted: Tue Feb 19, 2019 7:14 pm
by jan_suhr
You can also split the XML to single XML-files for each item with XSLT and Saxon configurator

Re: XML Pickup for Multiple Values

Posted: Wed Feb 20, 2019 7:49 am
by r.zegwaard
You can quite easy sort the files based on the number of nodes with a quantity >= 250 or <=25

I've created a flow like this:
Image

The condition for routing to folder 3 or 4 is:
Image

Code: Select all

[Metadata.Integer:Path="count(//ORDER_ITEM[ORDER_QUANTITY >= 250 or ORDER_QUANTITY <=25])",Dataset="Xml",Model="XML"]

Re: XML Pickup for Multiple Values

Posted: Thu Mar 21, 2019 3:45 pm
by matt.baile
I think the XML repeater may be an option, but I'm not able to purchase anything from the app store at this point.

@r.zegwaard - Your idea seems to be correct, but is that looking at the total number of nodes, or looking at the value in the ORDER_QUANTITY itself? I'm not so much concerned with how many nodes appear, just the values that are in those nodes.

Re: XML Pickup for Multiple Values

Posted: Mon Mar 25, 2019 7:56 am
by r.zegwaard
It counts the the number of order_items for which the quantity is >= 200 or quantity is <= 25
If the this counted value is > 0 the job goes that direction.

Re: XML Pickup for Multiple Values

Posted: Thu Mar 28, 2019 6:42 pm
by Arthur
Could I add a question here regarding this method, which I am trying to utilise for something similar ??
XML structure is as per the following:

<?xml version="1.0" encoding="UTF-8"?>
-<csv>
-<row>
<col name="FileName">Some Filename</col>
<col name="FileSize in KB">12345</col>
</row>
</csv>

Looking to get the number of nodes for the 'FileSize in KB' equal to 0.
For this I am thinking of using the following XPath expression:

count(//col[@name='FileSize in KB'=0])

But it returns total number of nodes @name='FileSize in KB' rather than actually count those which value is 0.

If there is a different way of stating this equation of 'equal 0' - could someone point me in the right direction pls.
Losing patience now :)


--- EDIT ----

OK, I've got it. ... But .... I do not understand it. Could someone wise explain why in order to get the total number of /col nodes with a @name='FileSize in KB' it requires that node name identifier to be present, but to count those that have 0 value it works with the following:

count(//col[.='0']) and does not require the name of the /col to be present???
I see no logic here :(