Page 1 of 1
Placing a Variable in a Variable
Posted: Fri Jan 27, 2017 3:51 pm
by mireille
Hello everyone,
I'm trying to read some data from my XML dataset attached to my job-file.
This is the path I need to use to fetch the data:
[Metadata.Text:Path="/dn:Workbook/dn:Worksheet[1]/dn:Table[1]/dn:Row[2]/dn:Cell[1]/dn:Data",Dataset="Xml",Model="XML",Before="_"]
The position of the 2 (.....Row[
2]....) needs to be dynamic and needs to be replaced by the number in the JobState variable.
So what I actually want is this:
[Metadata.Text:Path="/dn:Workbook/dn:Worksheet[1]/dn:Table[1]/dn:Row[[Job.JobState]]/dn:Cell[1]/dn:Data",Dataset="Xml",Model="XML",Before="_"]
But Switch doesn't like breaking up the pathcode with an other variable.
Does anaybody has a suggestion to get my variable in there?
An important detail is that we can't use the scriptingmodule, so I have to script it in the normal metadata menu's etc..
Thanks in advance!
Greetings from Holland

Mireille
Re: Placing a Variable in a Variable
Posted: Fri Jan 27, 2017 4:57 pm
by jan_suhr
You can construct the X-Path to go by the tag and attribute value.
Then you are not dependent on the order of the tags, it will go by the attribute.

- Screenshot 2017-01-27 16.53.58.jpg (37.28 KiB) Viewed 3829 times

- Screenshot 2017-01-27 16.54.18.jpg (16.65 KiB) Viewed 3829 times
In your example it would be //dn:Row[@your_attribute='attribute_value']
Jan
Re: Placing a Variable in a Variable
Posted: Mon Jan 30, 2017 9:47 am
by freddyp
You can only use a variable within a variable by scripting, but there could potentially be other ways of getting to dn:Row[x]. What Jan writes, for example, is worth investigating but if 'attribute_value' in
Code: Select all
//dn:Row[@your_attribute='attribute_value']
has to come from [Job.JobState] you have the same problem.
XPath has lots of functions and perhaps you can find a solution there. If for example the row you are looking for is the last one, then
would give you the correct one.
And another possibility to avoid having to use Switch scripting could be to use an XSL transformation. 'Could be' because whether this will work depends on what the problem is, and you are shifting the scripting from one environment to another one: you still need to script and if you think Switch scripting is difficult, try XSL

Re: Placing a Variable in a Variable
Posted: Mon Jan 30, 2017 6:40 pm
by cstevens
It looks like you're using a spreadsheet or csv file that was converted to XML. Getting specific row/column data in this format can be problematic. It might be easier if you can just pull data directly from the original data source.
There are multiple forum threads on pulling data from csv files on these forums that may help, but they typically involve some scripting.
Re: Placing a Variable in a Variable
Posted: Mon Jan 30, 2017 7:00 pm
by jan_suhr
Re: Placing a Variable in a Variable
Posted: Thu Feb 02, 2017 12:13 pm
by mireille
Hello,
Thanks for all the replies!
It's correct, we are starting from an Excel spreadsheet with all the article details in it for the new order. This document is provided by our customer.
We "clean" it up, so all the important data for the workflow remains in the new file and the redundant stuff is removed. Then we export it to XML and submit it to the flow.
My challenge for reading the variable in a variable is bit stranded, because we have no scripting module
But I still found a creative workaround to get the data in the place where we need it. (With a bit of manual preparation of the templates)
I used an XSL transform with a link to the rows and cells. I don't know for sure if all the syntax is correct, but it creates a workable output
And Freddy:
if you think Switch scripting is difficult, try XSL

I totally agree on this !!! writing XSL is serious complex matter. But thank you for that suggestion. We have now the output we need to let the documents start running through our special workflow.
Many greetings,
Mireille