Load context from XML file

One Star

Load context from XML file

Hello,
I'd like to manage my context variables thanks to an XML file. In this file, I would like to manage all the needed variables PLUS different value for these variable according to the execution environment (production or development).
So I wrote an XML file like this:
<setup_information>
<setup context="DEV">
<hostname>servename_DEV</hostname>
<port>1234_DEV</port>
<username>user_DEV</username>
<password>pass_DEV</password>
</setup>
<setup context="PROD">
<hostname>servename_PROD</hostname>
<port>1234_PROD</port>
<username>user_PROD</username>
<password>pass_PROD</password>
</setup>
</setup_information>

Then, I setup my tFileInputXML like you can see on the screen shot, where context.context_type = "DEV" or "PROD" according to the context...
I can retrieve the expected value, according to the context, taht fine.
BUT, how can I transform this into context, the tContextLoad component having a shema key/value ???
Community Manager

Re: Load context from XML file

Hello
BUT, how can I transform this into context,

After you extract the value from xml file, you can use a tJavaRow to set the values to context variables, see the screenshots.
the tContextLoad component having a shema key/value ???

Yes, tContextLoad component have a schema with key/value column. You can store your context variable and their values in a file like this:
hostname:hostnameDEV
portSmiley TongueortDEV
username:usernameDEV
passwordSmiley TongueasswordDEV
then, use a tContextLoad component to load the values to context variables in a job. About the basic usage of tContextload, please read the user documentation.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Load context from XML file

Damned... My yesterday job does not work anymore...
Tahnks shong for your help !!!
Arnaud
One Star

Re: Load context from XML file

hi guys,

i am using this approach to set global context in a project...
tmysqlinput(1)------>tjavarow(here multifull if conditions for assiging vales to different context's)
|
|
tmysqlinput(2)---------tmysqloutput
Note: Created context variables.

by using those components i am able to assign values to context and i am using those context in tmysqlinput(2), and finaly loaded data into target...
??????PROBLEM IS : i am facing one of the issue..like this..
i dont want to use " tmysqlinput(1)------>tjavarow(here multifull if conditions for assiging vales to different context's)" this part every time.
based on context variables i need to assign context values to other jobs..
when i retrive context by using context tab and trying to use.............but unable to retrive and dispaly those values.....
How we can use those context's in other jobs..?????

Pls let me know any one.....on this issue.???????

Regards
One Star

Re: Load context from XML file

Hi Buzzy,
How we can use those context's in other jobs..?????

Please see screeshots below. I am not good in explaining things that's why I just provided screenshots for you. But still, not sure if this is what you are looking for. Smiley Happy
Six Stars

Re: Load context from XML file

Hey,
nice tutorial Shong. It works well. But because it is already some time ago, I want to ask if there is another more intuitive way how to read configuration from XML file directly into context variables?
Best regards,
Ladislav Jech
One Star

Re: Load context from XML file

Sorry, but, where are the screenshots?