[ 
https://issues.apache.org/jira/browse/NIFI-13335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stephen Jeffrey Hindmarch updated NIFI-13335:
---------------------------------------------
    Description: 
This is similar to NIFI-13334, but does not require an array of records to 
demonstrate.

If you create an XMLReader service and set the following:
 * Parse XML Attributes = true
 * Expect Records as Arrays = false
 * Field Name for Content = Value

Then use the reader in a ConvertRecord processor with a JSONRecordSetWriter

When parsing a flow file such as
{noformat}
<Event Type="foo">
  <System>
    <EventID>0x0001</EventID>
  </System>
  <UserData>
    <Data Name="Param1">String1</Data>
    <Data Name="Param2">String2</Data>
    <Data Name="Param3">String3</Data>
  </UserData>
</Event>{noformat}
then the data tags all get parsed with the correct values.
{noformat}
[ {
  "Type" : "foo",
  "System" : {
    "EventID" : "0x0001"
  },
  "UserData" : {
    "Data" : [ {
        "Name" : "Param1",
        "Value" : "String1"
    }, {
        "Name" : "Param2",
        "Value" : "String2"
    }, {
        "Name" : "Param3",
        "Value" : "String3"
    } ]
  }
} ]{noformat}
But if one of those data tags has a numeric value then all of the values are 
dropped and are replaced with null. For example
{noformat}
<Event Type="foo">
  <System>
    <EventID>0x0001</EventID>
  </System>
  <UserData>
    <Data Name="Param1">String1</Data>
    <Data Name="Param2">2</Data>
    <Data Name="Param3">String3</Data>
  </UserData>
</Event>
{noformat}
parses to
{noformat}
[ {
  "Type" : "foo",
  "System" : {
    "EventID" : "0x0001"
  },
  "UserData" : {
    "Data" : [ {
        "Name" : "Param1",
        "Value" : null
    }, {
        "Name" : "Param2",
        "Value" : null
    }, {
        "Name" : "Param3",
        "Value" : null
    } ]
  }
} ]{noformat}
and all of the tag data is lost.

  was:
This is similar to NIFI-13334, but does not require an array of records to 
demonstrate.

If you create an XMLReader service and set the following:
 * Parse XML Attributes = false
 * Expect Records as Arrays = true
 * Field Name for Content = Value

Then use the reader in a ConvertRecord processor with a JSONRecordSetWriter

When parsing a flow file such as
{noformat}
<Event Type="foo">
  <System>
    <EventID>0x0001</EventID>
  </System>
  <UserData>
    <Data Name="Param1">String1</Data>
    <Data Name="Param2">String2</Data>
    <Data Name="Param3">String3</Data>
  </UserData>
</Event>{noformat}
then the data tags all get parsed with the correct values.
{noformat}
[ {
  "Type" : "foo",
  "System" : {
    "EventID" : "0x0001"
  },
  "UserData" : {
    "Data" : [ {
        "Name" : "Param1",
        "Value" : "String1"
    }, {
        "Name" : "Param2",
        "Value" : "String2"
    }, {
        "Name" : "Param3",
        "Value" : "String3"
    } ]
  }
} ]{noformat}
But if one of those data tags has a numeric value then all of the values are 
dropped and are replaced with null. For example
{noformat}
<Event Type="foo">
  <System>
    <EventID>0x0001</EventID>
  </System>
  <UserData>
    <Data Name="Param1">String1</Data>
    <Data Name="Param2">2</Data>
    <Data Name="Param3">String3</Data>
  </UserData>
</Event>
{noformat}
parses to
{noformat}
[ {
  "Type" : "foo",
  "System" : {
    "EventID" : "0x0001"
  },
  "UserData" : {
    "Data" : [ {
        "Name" : "Param1",
        "Value" : null
    }, {
        "Name" : "Param2",
        "Value" : null
    }, {
        "Name" : "Param3",
        "Value" : null
    } ]
  }
} ]{noformat}
and all of the tag data is lost.


> XMLReader drops values from name-value content if values are mixture of 
> strings and numbers
> -------------------------------------------------------------------------------------------
>
>                 Key: NIFI-13335
>                 URL: https://issues.apache.org/jira/browse/NIFI-13335
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.24.0
>         Environment: Docker
>            Reporter: Stephen Jeffrey Hindmarch
>            Priority: Major
>
> This is similar to NIFI-13334, but does not require an array of records to 
> demonstrate.
> If you create an XMLReader service and set the following:
>  * Parse XML Attributes = true
>  * Expect Records as Arrays = false
>  * Field Name for Content = Value
> Then use the reader in a ConvertRecord processor with a JSONRecordSetWriter
> When parsing a flow file such as
> {noformat}
> <Event Type="foo">
>   <System>
>     <EventID>0x0001</EventID>
>   </System>
>   <UserData>
>     <Data Name="Param1">String1</Data>
>     <Data Name="Param2">String2</Data>
>     <Data Name="Param3">String3</Data>
>   </UserData>
> </Event>{noformat}
> then the data tags all get parsed with the correct values.
> {noformat}
> [ {
>   "Type" : "foo",
>   "System" : {
>     "EventID" : "0x0001"
>   },
>   "UserData" : {
>     "Data" : [ {
>         "Name" : "Param1",
>         "Value" : "String1"
>     }, {
>         "Name" : "Param2",
>         "Value" : "String2"
>     }, {
>         "Name" : "Param3",
>         "Value" : "String3"
>     } ]
>   }
> } ]{noformat}
> But if one of those data tags has a numeric value then all of the values are 
> dropped and are replaced with null. For example
> {noformat}
> <Event Type="foo">
>   <System>
>     <EventID>0x0001</EventID>
>   </System>
>   <UserData>
>     <Data Name="Param1">String1</Data>
>     <Data Name="Param2">2</Data>
>     <Data Name="Param3">String3</Data>
>   </UserData>
> </Event>
> {noformat}
> parses to
> {noformat}
> [ {
>   "Type" : "foo",
>   "System" : {
>     "EventID" : "0x0001"
>   },
>   "UserData" : {
>     "Data" : [ {
>         "Name" : "Param1",
>         "Value" : null
>     }, {
>         "Name" : "Param2",
>         "Value" : null
>     }, {
>         "Name" : "Param3",
>         "Value" : null
>     } ]
>   }
> } ]{noformat}
> and all of the tag data is lost.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to