Question

I've defined a xml-schema in Talend, using an xml file from one provider. I have multiple providers that I need to handle seperately, but they have the same format of xml.

I only want to define the xml schema once, but use it in multiple jobs each with a different file name. The xml schema seems to be tight to a filename however, and changing the filename makes it a build-in type. I don't want a build in type as I want changes to the xml schema to happen once.

Can somebody point me in the right direction? Should this be done using context?

Was it helpful?

Solution 2

This is very common, but unfortunately there's no an elegant solution.

Context vars are limited to just primitive types (almost), while the only way to do so is to define an xml schema metadata and then switch off to built-in to change just the filename. This is very ugly, but AFAIK is the only solution possible atm.

OTHER TIPS

It is possible to define a schema for a set file (using the wizards provided or building it yourself) and then use just that schema by simply choosing it from the repository.

So, as an example, you might wish to loop through a folder full of XML files and read them using the same schema for all of them and then load this into a database:

Example XML Job

To do this you would start with a tFileList which points to the folder full of XML files. Set this up as usual (you probably want a filemask on *.xml") and then link it via an Iterate flow to a tFileInputXML component specifying the file name as: ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")).

Now select Repository from the drop down box next to Schema (should be default as Built-In. From here simply select the XML schema previously defined for a single file. Now you can use just the schema defined but change everything else (you probably only want control over the file name and leave the rest as is).

Now you can simply connect it to a database component of your choice, such as a tMySQLOutput and have the database component insert rows as per usual.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top