change xpath expressions of xml Dymanically

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
dstage2006
Premium Member
Premium Member
Posts: 116
Joined: Fri Jan 20, 2006 2:30 pm

change xpath expressions of xml Dymanically

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not that I am aware of, there's nothing "dynamic" about those values as far as I know.
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post 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
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dstage2006
Premium Member
Premium Member
Posts: 116
Joined: Fri Jan 20, 2006 2:30 pm

Post 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.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post 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
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post 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.
Post Reply