Created on 10-23-2024 05:45 AM - edited 10-23-2024 05:46 AM
Hello!
The general task is to transform xml to csv
For this aim I created following pipeline:
Source xml content is:
<Email E-mail="AR-BIK@GMAIL.COM"> <Data GRN="3214600023849" Date="2024-07-28"></Data></Email>
Parameters of EvaluateXPath are:
ReplaceText parameters:
Attribute grn successfully produced with expected value:
But value "3214600023849" is not translated to csv. Only ; delimiter.
Encoding is UTF-8
What am I doing wrong?
Created 10-23-2024 06:33 AM
@AndreyDE
Post your EvaluateXPath processor you have a FlowFile that now has a FlowFile Attribute "/grn" with a value of "3214600023849".
In ReplaceText, it appears you intent is to replace the entire content of the FlowFile with the value returned by the NiFi Expression Language (NEL) statement:
${grn:escapeCsv()};
Your expression language statement grabs the value from FlowFile Attribute "grn", passes it the escapeCsv NEL function and then appends a ";" to the returned result.
Problem 1 is your FlowFile has no attribute "grn", it has an attribute "/grn"
Since "/grn" contains special character "/", it will need to be quoted in the NEL statement as follows:
${"/grn":escapeCsv()};
reference: Structure of a NiFi Expression
Above would output content with:
3214600023849;
This content would not require being surrounded by quotes under RFC 4180
reference: escapeCSV function
Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created 10-23-2024 06:33 AM
@AndreyDE
Post your EvaluateXPath processor you have a FlowFile that now has a FlowFile Attribute "/grn" with a value of "3214600023849".
In ReplaceText, it appears you intent is to replace the entire content of the FlowFile with the value returned by the NiFi Expression Language (NEL) statement:
${grn:escapeCsv()};
Your expression language statement grabs the value from FlowFile Attribute "grn", passes it the escapeCsv NEL function and then appends a ";" to the returned result.
Problem 1 is your FlowFile has no attribute "grn", it has an attribute "/grn"
Since "/grn" contains special character "/", it will need to be quoted in the NEL statement as follows:
${"/grn":escapeCsv()};
reference: Structure of a NiFi Expression
Above would output content with:
3214600023849;
This content would not require being surrounded by quotes under RFC 4180
reference: escapeCSV function
Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created 10-23-2024 09:55 AM
Thank you, the matter was in "/", indeed ))