Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

Reading Multiple XMLs and Validating against XSD Schema

Hi,
I have a case in which I need to have a poll folder which would read available XML files, queue them, validate them using XSD schema then do other processing. I used the following components but couldn't get the results I want:
1. tWaitForFile: poll folder.
2. tXSDValidator: to validate XML files.
I found some shortcomings (either in my knowledge of Talend's components or in components themselves):
1. tWaitForFile: after discovering a file and processing it, I want to delete it from the poll folder or move it to another directory for archiving but I couldn't find component attribute to support these operations.
2. tXSDValidator: Takes a specific instance of and XML file. The path of the file is hardcoded which means I can't iterate over XML files which are queued by some other components. Also, there is no fine-grained error handling such as fatal error handling, handling error at a specific XML element etc...
How can I overcome the above mentioned shortcomings? Are there other components which support my requirements? Should I assemble components in a different way?
I appreciate your time answering my questions.
Labels (3)
4 Replies
Anonymous
Not applicable

Hello
1. tWaitForFile: after discovering a file and processing it, I want to delete it from the poll folder or move it to another directory for archiving but I couldn't find component attribute to support these operations.

You can use the tFileCopy component to copy the file and delete it.
2. tXSDValidator: Takes a specific instance of and XML file. The path of the file is hardcoded which means I can't iterate over XML files which are queued by some other components. Also, there is no fine-grained error handling such as fatal error handling, handling error at a specific XML element etc...

Don't hardcode the file path, there is a global var 0683p000009MPcz.png(String)globalMap.get("tWaitForFile_1_CREATED_FILE")), with which you can iterate all new created file on tXSDValidator.eg:
tWaitForFile--iterate-->tXSDValidator
on the xml file field of tXSDValidator, type in 0683p000009MPcz.png(String)globalMap.get("tWaitForFile_1_CREATED_FILE"))
tip: on any text field, press ctrl+bank space, you will see a list of global vars.
Best regards

shong
_AnonymousUser
Specialist III
Specialist III
Author

Thank you Shong. Your tips were of a great help to me especially the concept of global variables.
I still have some issues in this topic.
* I observed that whenever I have an exception, the job exits. This is an undesirable behavior since there are recoverable exceptions with which the job can continue peacefully. Isn't there a way to configure a job so that it doesn't exit on certain exceptions (e.g., FileNotFoundException)?
* tXSDValidator: I expected to have two handler branches in this component, one for happy scenario in which the XML file was valid and one for failure scenario in which the XML file was invalid. However, I didn't find any available action that I can use based on the outcome of this component (except printing messages to console). How can I implement those two handlers based on the outcome of tXSDValidator?
_AnonymousUser
Specialist III
Specialist III
Author

Reminder!
Anonymous
Not applicable

Hello
* I observed that whenever I have an exception, the job exits. This is an undesirable behavior since there are recoverable exceptions with which the job can continue peacefully. Isn't there a way to configure a job so that it doesn't exit on certain exceptions (e.g., FileNotFoundException)?

Put tXSDValidator to a child job, use a tRunJob to run the child job and uncheck 'die on child error' option in the father job. eg:
In father job: tWaitForFile--iterate-->tRunJob
In child job: tXSDValidator
How can I implement those two handlers based on the outcome of tXSDValidator?

Using the global var 0683p000009MPcz.png(String)globalMap.get("tXSDValidator_1_ERROR_MESSAGE"))
it returns 'file is invalid' if it is failed and returns 'file is valid' if it is ok.
Best regards

shong