XML pickup tool

Post Reply
sherczog
Newbie
Posts: 6
Joined: Wed Mar 23, 2011 3:43 pm

XML pickup tool

Post by sherczog »

Can someone help me with the tool xml-pickup?

I want to catch a file as defined in an xml.



The flow gives an error: Failed to find asset ''
An xml file (called: testXml.xml) containing:







pad

E:test.txt






And in Powerswtich an Single-line text with variables defined: [Metadata.Text:Path="//field[tag=pad]/value",Dataset="Xml",Model="XML"].


Where do I go wrong?


mattbeals
Member
Posts: 59
Joined: Fri Oct 29, 2010 2:49 am
Location: Edmonds, WA
Contact:

XML pickup tool

Post by mattbeals »

As far as I know this requires a script expression rather than a condition with variable. But I do not have a script that would do this.
I'm just a dude. Anything I say has nothing to do with any other person or company.
mattbeals
Member
Posts: 59
Joined: Fri Oct 29, 2010 2:49 am
Location: Edmonds, WA
Contact:

XML pickup tool

Post by mattbeals »

Here, try this:

http://www.mattbeals.com/misc/inject_job.zip

http://www.mattbeals.com/misc/inject_job2.zip



What I did was use the XML as the asset itself. Then I use the inject job to point to a fixed location where the job resides. All the metadata that comes inside the XML is preserved and can be used for routing/processing.



The second sample has a UNC path to the asset itself.
I'm just a dude. Anything I say has nothing to do with any other person or company.
sherczog
Newbie
Posts: 6
Joined: Wed Mar 23, 2011 3:43 pm

XML pickup tool

Post by sherczog »

It works!

Although I do not understand how. How does PowerSwitch know where the tag is for the path? In the manual it says : “the asset (the xml file) must contain data of the appropriate type..” What is the appropriate type?



The method in my original question (XMLpickup – Metadata refers to asset) suggests that the structure of the xml is flexible as long as your Xpath statement is correct... but that didn’t work, so I guess my logic is not sound.



Maybe Enfocus can provide with some more information...but for now I can use your solution.



thanx


bens
Advanced member
Posts: 252
Joined: Thu Mar 03, 2011 10:13 am

XML pickup tool

Post by bens »

sherczog wrote: And in Powerswtich an Single-line text with variables defined: [Metadata.Text:Path="//field[tag=pad]/value",Dataset="Xml",Model="XML"].
The xpath expression is not completely correct. Try this one:



[Metadata.Text:Path="//field[tag='pad']/value",Dataset="Xml",Model="XML"]
rgpepper
Member
Posts: 80
Joined: Wed Oct 14, 2015 2:09 am

Re: XML pickup tool

Post by rgpepper »

I can't seem to make the method mentioned here work for me.

I have this XML (just the top portion shown for brevity), dataset is named "FTP_XML", I want to use xpath so that I don't have to re-connect everything if I add a field in the middle of the XML.

<?xml version="1.0" encoding="UTF-8"?>
<field-list>
<field>
<tag>CustomerID</tag>
<type>string</type>
<required>true</required>
<value>1107</value>
</field>

[Metadata.Text:Path=''//field[tag='CustomerID']/value",Dataset="FTP_XML",Model="XML"]

Shouldn't the above method work if I choose "textindexed" then "build location path" then External, choose "XPath expression"?
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: XML pickup tool

Post by cstevens »

Using a double slash in an XPath means to start at the beginning of the document. If you're doing that then you need to include the field-list element (

Code: Select all

[Metadata.Text:Path="//field-list/field[tag='CustomerID']/value",Dataset="Xml",Model="XML"]
Also Switch's path builder tool is picky about XPaths that match multiple values, so if 'CustomerID' is not a unique value within the XML you could have issues.
rgpepper
Member
Posts: 80
Joined: Wed Oct 14, 2015 2:09 am

Re: XML pickup tool

Post by rgpepper »

Yeah nada:

[Metadata.Text:Path="//field-list/field[tag='PO#']/value",Dataset="FTP_XML",Model="XML"]

Doesn't work, I get the following error:
"There is no selected node. A location path is valid only when it indicates a single node"
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: XML pickup tool

Post by cstevens »

You sure that PO# is unique in the XML file? If it points to multiple nodes then you'll get that error.

What happens if you define the first node like this:

Code: Select all

//field-list/field[tag="PO#"][1]/value
rgpepper
Member
Posts: 80
Joined: Wed Oct 14, 2015 2:09 am

Re: XML pickup tool

Post by rgpepper »

That at least highlights the opening value tag <value> for the correct node and doesn't give an error in that dialog. For testing purposes I was playing with an existing SQL call (just some place I could define a variable) and it gives this error in response to the following in the "Text with variables" field:

[Metadata.TextIndexed:Path="//field-list/field[tag="PO#"][1]/value",Dataset="FTP_XML",Model="XML"]

Variable 'Metadata.TextIndexed' has incorrect syntax in 'SQL statement': unexpected 'P' characters after the argument value; expected characters are ',' or ']' - But if I change the double quotes around the tag name "PO#" to single quotes, all is well. Then it also works to take the [1] specifier out;

[Metadata.TextIndexed:Path="//field-list/field[tag='PO#']/value",Dataset="FTP_XML",Model="XML"]
So it was just "Metadata.TextIndexed" vs. "Metadata.TextPath" that was at issue.

Thanks for the assistance!
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: XML pickup tool

Post by jan_suhr »

Have you tried [Metadata.Text.... instead of TextIndexed ?

TextIndexed will give you an array of values instead of just the value from the node if you use Text.

The Tag must always be in single quotes otherwise you break the XPath.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
rgpepper
Member
Posts: 80
Joined: Wed Oct 14, 2015 2:09 am

Re: XML pickup tool

Post by rgpepper »

I will try that, thanks!
Post Reply