Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-7493

XML Schema Inference can infer a type of String when it should be Record

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.12.0
    • Extensions
    • None

    Description

      From the mailing list:

      I have configured a XMLReader to use the Infer Schema. The other issue is that I have problems converting sub records. My records looks something like this:<RootLabel>    <Part1>        <name>John Doe</name>        <adress>some there</adress>    </Part1>    <Part2>        <Job>workingman</Job>    </Part2>    <Part3>        <Details>            <additionalInfo name="Location">New York</additionalInfo>
                  <additionalInfo name="Company">A Company</additionalInfo>
              </Details>
          </Part3>
      </RootLabel>
       
      The issues are with the subrecords in part 3. I have configured the XMLReader property "Field Name for Content" = value
       
      When the data is being converted via a XMLWriter the output for the additionalInfo fields looks like this:
      <Part3>    <Details>        <additionalInfo>MapRecord[\{name=Location, value=New York}]</additionalInfo>
              <additionalInfo>MapRecord[\{name=Company, value=A Company}]</additionalInfo>    </Details>
      </Part3>
       
       
      If I use a JSONWriter I gets this:
      "Part3": {    "Details":

      Unknown macro: {         "additionalInfo"}

      ]", "MapRecord[\{name=Company, value=A Company}]" ]
          }
      }

      The issue appears to be that "additionalInfo" is being inferred as a String, but the XML Reader is returning a Record.
       
      This is probably because the "additionalInfo" element contains String content and no child nodes. However, it does have attributes. As a result, the XML Reader will return a Record. I'm guessing that attributes are not taken into account in the schema inference, though, and since "additionalInfo" has no child nodes but has textual content, it must be a String.

      Attachments

        Issue Links

          Activity

            People

              markap14 Mark Payne
              markap14 Mark Payne
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h