- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Why is Convert Record leaving two fields null, and ignoring attributes
- Labels:
-
Apache NiFi
Created on ‎04-24-2019 06:01 PM - edited ‎08-17-2019 03:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My simple flow:
The input XML:
The output JSON:
ConvertRecord Configuration:
XMLReader Configuration:
Several questions arise:
- Why are position and ncsmTrackData null?
- Why are all the attributes on fltdMessage being ignored?
- How can I see the inferred schema?
- What is a proper schema to correctly transform those two null fields, (along with the rest of the transformation as it currently looks ok)?
Created ‎04-24-2019 06:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've added a simple template that someone can use to replicate this. Test_Convert_Record_2.xml
Created on ‎04-25-2019 12:42 PM - edited ‎08-17-2019 03:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@David Sargrad , I faced the same issue and I believe that the nested structure of your XML is causing inferredSchema to fill null in those attributes. I came across this post, it suggested using a XSLT file to transform the XML directly to JSON. The inferred Schema works great for flat XML files.
You might want to give it a try or you can manually define a schema for the file you want to convert.
Here is how you can use the XSLT to transform the XML.
Configuration of TransformXML processor
Save the XSLT file and add the path to the file at XSLT file name
Created ‎04-25-2019 02:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Sumit Das
Thanks for your response. I came to the same conclusion. I have indeed used XSLT before along with TransformXML. I was hoping that the new capability with XMLReader would give me an alternative option.
Given the current state of the inference capability, I think that you are right.
Thanks again for taking the time to respond.
I did write an issue on the NIFI issue board: https://issues.apache.org/jira/browse/NIFI-6241. Hopefully this will get some attention.
Created ‎04-25-2019 02:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@David Sargrad , Would you mind sharing the source of your XML? I want to see if I missed something. Also, I could not find a way to have a look at the schema. Write Schema to attribute is disabled on inferSchema. Even InferavroSchema processor supports CSV and JSON only at the moment. Please share if you find a way to look at the inferred schema in future.
If it is a bug, lets hope it gets fixed soon.
Created on ‎04-25-2019 03:01 PM - edited ‎08-17-2019 03:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please see the template i added in my comment above.. it has the source generator that you need (Test_Convert_Record_2.xml)
Created on ‎04-26-2019 04:35 AM - edited ‎08-17-2019 03:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I fiddled with the XML and I found that the issue is having data in form of XML attributes. For example if the longitude and latitude data is in this format, you get the desired output.
Seems like there is some issue in the XMLReader. I upvoted your JIRA issue. Lets wait and see. Thanks for your response.
