[
https://issues.apache.org/jira/browse/NIFI-14780?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gábor Gyimesi updated NIFI-14780:
---------------------------------
Description:
In the XMLReader controller service if the 'Parse XML Attributes' is set to
true then XML node attributes are written as record fields. In this case the
content and the attributes are defined together as a record. In such a case,
the name of the tag will be used as the name for the record and the value of
this property will be used as the name for the field holding the original
content. The 'Field Name for Content' property is used in this case to define
the field name for the content in the record. For example if this attribute is
set to 'tagValue' this will be the result using the XMLReader and the
JsonRecordSetWriter:
Input:
{code:java}
<note>
<to alias="TK">Kyle</to>
<from>Stan</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>{code}
Output:
{code:java}
[{"to":{"alias":"TK","tagValue":"Kyle"},"from":"Stan","heading":"Reminder","body":"Don't
forget me this weekend!"}]
{code}
However when the 'Field Name for Content' is not set the content is meant to be
ignored and not written, resulting in the following debug message:
"Found content for a field that was supposed to be named with the value of the
"Field Name for Content" property but the property was not set. The content was
not added to the record."
This seems to be inconsistent with the result seen in the flow file, because
when the 'Field Name for Content' is empty a default "value" field is created
without any value:
{code:java}
[{"to":{"alias":"TK","value":null},"from":"Stan","heading":"Reminder","body":"Don't
forget me this weekend!"}]
{code}
I think this is inconsistent, we should either create a default "value" record
field with the XML tag content if the "Field Name for Content" property is
empty or we should not create any default "value" record fields at all.
was:
In the XMLReader controller service if the 'Parse XML Attributes' is set to
true then XML node attributes are written as record fields. In this case the
content and the attributes are defined together as a record. In such a case,
the name of the tag will be used as the name for the record and the value of
this property will be used as the name for the field holding the original
content. The 'Field Name for Content' property is used in this case to define
the field name for the content in the record. For example if this attribute is
set to 'tagValue' this will be the result using the XMLReader and the
JsonRecordSetWriter:
Input:
<note>
<to alias="TK">Kyle</to>
<from>Stan</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Output:
[\{"to":{"alias":"TK","tagValue":"Kyle"},"from":"Stan","heading":"Reminder","body":"Don't
forget me this weekend!"}]
However when the 'Field Name for Content' is not set the content is meant to be
ignored and not written, resulting in the following debug message:
"Found content for a field that was supposed to be named with the value of the
"Field Name for Content" property but the property was not set. The content was
not added to the record."
This seems to be inconsistent with the result seen in the flow file, because
when the 'Field Name for Content' is empty a default "value" field is created
without any value:
[\{"to":{"alias":"TK","value":null},"from":"Stan","heading":"Reminder","body":"Don't
forget me this weekend!"}]
I think this is inconsistent, we should either create a default "value" record
field with the XML tag content if the "Field Name for Content" property is
empty or we should not create any default "value" record fields at all.
> XMLReader writes null value if "Field Name for Content" is not set
> ------------------------------------------------------------------
>
> Key: NIFI-14780
> URL: https://issues.apache.org/jira/browse/NIFI-14780
> Project: Apache NiFi
> Issue Type: Bug
> Reporter: Gábor Gyimesi
> Assignee: Samkit Jain Ksolves Nifi Expertise
> Priority: Major
>
> In the XMLReader controller service if the 'Parse XML Attributes' is set to
> true then XML node attributes are written as record fields. In this case the
> content and the attributes are defined together as a record. In such a case,
> the name of the tag will be used as the name for the record and the value of
> this property will be used as the name for the field holding the original
> content. The 'Field Name for Content' property is used in this case to define
> the field name for the content in the record. For example if this attribute
> is set to 'tagValue' this will be the result using the XMLReader and the
> JsonRecordSetWriter:
> Input:
> {code:java}
> <note>
> <to alias="TK">Kyle</to>
> <from>Stan</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>{code}
> Output:
>
> {code:java}
> [{"to":{"alias":"TK","tagValue":"Kyle"},"from":"Stan","heading":"Reminder","body":"Don't
> forget me this weekend!"}]
> {code}
>
> However when the 'Field Name for Content' is not set the content is meant to
> be ignored and not written, resulting in the following debug message:
> "Found content for a field that was supposed to be named with the value of
> the "Field Name for Content" property but the property was not set. The
> content was not added to the record."
> This seems to be inconsistent with the result seen in the flow file, because
> when the 'Field Name for Content' is empty a default "value" field is created
> without any value:
>
> {code:java}
> [{"to":{"alias":"TK","value":null},"from":"Stan","heading":"Reminder","body":"Don't
> forget me this weekend!"}]
> {code}
>
> I think this is inconsistent, we should either create a default "value"
> record field with the XML tag content if the "Field Name for Content"
> property is empty or we should not create any default "value" record fields
> at all.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)