XML Pickup for Multiple Values

Post Reply
matt.baile
Member
Posts: 43
Joined: Wed Nov 29, 2017 4:36 pm

XML Pickup for Multiple Values

Post 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"]
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: XML Pickup for Multiple Values

Post 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.
Malcolm Mackenzie
Member
Posts: 121
Joined: Wed Mar 22, 2017 5:05 pm
Location: London, UK
Contact:

Re: XML Pickup for Multiple Values

Post 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.
Malcolm Mackenzie
Member
Posts: 121
Joined: Wed Mar 22, 2017 5:05 pm
Location: London, UK
Contact:

Re: XML Pickup for Multiple Values

Post 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.
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: XML Pickup for Multiple Values

Post by jan_suhr »

You can also split the XML to single XML-files for each item with XSLT and Saxon configurator
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
r.zegwaard
Member
Posts: 93
Joined: Fri Jul 08, 2011 10:31 am
Location: The Netherlands

Re: XML Pickup for Multiple Values

Post 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"]
matt.baile
Member
Posts: 43
Joined: Wed Nov 29, 2017 4:36 pm

Re: XML Pickup for Multiple Values

Post 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.
r.zegwaard
Member
Posts: 93
Joined: Fri Jul 08, 2011 10:31 am
Location: The Netherlands

Re: XML Pickup for Multiple Values

Post 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.
Arthur
Member
Posts: 113
Joined: Sat Sep 09, 2017 11:58 pm
Location: Yateley, UK

Re: XML Pickup for Multiple Values

Post 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 :(
Post Reply