Page 1 of 1

change xpath expressions of xml Dymanically

Posted: Tue Sep 21, 2010 1:00 pm
by dstage2006
Hi All,

I am trying to capture couple of column data that are same in the 3 different xmls by dynamically changing the xpath expressions.

for ex:
col1,col2,col3---------xml1,xml2,xml3

is there any way to pass xpath expressions dynamically when i run my job atleast first part like (/xml1/col1/text() when i run second xml i want to replace xml1 to xml2 like (/xml2/col1/text()).

Thanks in advance.

Posted: Tue Sep 21, 2010 1:12 pm
by chulett
Not that I am aware of, there's nothing "dynamic" about those values as far as I know.

Posted: Tue Sep 21, 2010 2:17 pm
by eostic
You can't change the xpath...but you could code for it in advance.....each link could have its own xpath, and then do something else downstream, bring the links back together, etc.

...or, if the xml content is not "too" big, just change the xml itself in an upsteam transformer...easy if the pattern is as basic as you have described.

Ernie

Posted: Thu Sep 23, 2010 2:39 pm
by throbinson
I don't have access to DataStage so this is from memory and might be a little vague. It has been over a year since I talked DataStage so my accent might be rather thick.
You can change it dynamically (per job run that is) using parameters. Parameters will work within the description field. Parameters will also work in the XML Stage itself if you wanted to change the schema dynamically as well.

Posted: Thu Sep 23, 2010 3:40 pm
by chulett
throbinson wrote:Parameters will work within the description field.
Interesting... makes sense that something like that *could* work but I never had a need to try any such thing. Curious how that works out.

Posted: Tue Sep 28, 2010 2:19 pm
by dstage2006
Thanks throbinson,

Acutually it is working. I have added only parameter like

/#Jpass1#/Col1/text()

and passed differnt xmls as parameter values to get same column information from different xmls.

Thanks.

Posted: Tue Sep 28, 2010 3:25 pm
by eostic
Very nice! That's great! I haven't seen a use case that demanded it (usually the variety is very low, or else dramatic and impacting downstream stages making a separate path of stages a requirement).

Can you describe how #JPass1# changes? Does it ever include multiple nodes (slashes embedded in its value)?

Hmm. I have to think about the implications for 8.5........

Thanks.

Ernie

Posted: Tue Sep 28, 2010 7:09 pm
by throbinson
I'm happy that worked for you. The application I used it for was multiple xml schemas going to an Oracle db. The schemas described different hedged options like commodities (rice, hops, barley, the essentials for beer), as well as hedging international currency fluctuations, transportation costs, stuff like that as the input. The thing is those different XML schemas can all be parsed into loading the same Oracle table model. Consequently all these different XPaths all parsed into the same Update/Insert into Oracle AND were relatively the same except for element naming. Therefore the parameterized job could take different schemas but the exact same Oracle stages post parse. That my friend was re-usability.