I need to get a specific filename part value while mapping XML to the desired structure in the XMLMap connector. F. ex. I need to extract ‘1234’ part from a file name 1234_abcd.xml.
I have tried to write an expression in the Expression Editor: dgetfilename(substring(0, indexof(filename(), "_")))]
The result is always an error. "The attribute does not exist. This formatter cannot be called with nonexistent attributes."
Can i ask if you can share the exact code used to solve your problem?
@AndreaMassa The reason why you are seeing that exception is because the script nodes inside of XML Map do not support the FileName] attribute. Instead, you will want to target the actual FileName header itself, which is stored on the _message item, like this:
<_message.header:FileName]
This will evaluate to the name of the input file. However, I noticed you are using a script node for this and while this will work, it isn’t necessary. You can evaluate the name of the input file and apply any formatters to it within the expression editor for the desired node. This would be the recommended approach:
Many thanks, I really would never have gotten there. I spent hours trying to figure out how to do this. I was starting to suspect that I had to get the information some other way. Unfortunately I looked for documentation or other examples but I never came across an example like the one you wrote to me.
Many thanks again. I update my ticket so there is a trace!