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

XMLReader adds extra XML element to the schema if the input contains XML attribute

    XMLWordPrintableJSON

Details

    Description

      Let's use a ConvertRecord processor with an XMLReader to process XML documents. Let's set the reader's 'Schema Access Strategy' property to 'Infer Schema'. The processor can be configured with any writer, we just need to make sure the record schema is written in an attribute to the outgoing flowfile.

      XMLReader controller service settings:

      • Schema Access Strategy: Infer Schema
      • Expect Records as Array: false

      ConvertRecord processor settings:

      • Record Reader: XMLReader
      • Record Writer: any writer with Schema Write Strategy: Set 'avro.schema' Attribute and Schema Access Strategy: Inherit Record Schema

      Input data:

      <record>
        <num>123</num>
        <software favorite="true">Apache NiFi</software>
      </record>

      Output schema:

      {
          "type": "record",
          "name": "nifiRecord",
          "namespace": "org.apache.nifi",
          "fields": [
              {
                  "name": "num",
                  "type": [
                      "null",
                      "int"
                  ]
              },
              {
                  "name": "software",
                  "type": [
                      "null",
                      {
                          "type": "record",
                          "name": "softwareType",
                          "fields": [
                              {
                                  "name": "favorite",
                                  "type": [
                                      "null",
                                      "boolean"
                                  ]
                              },
                              {
                                  "name": "value",
                                  "type": [
                                      "null",
                                      "string"
                                  ]
                              }
                          ]
                      }
                  ]
              },
              {
                  "name": "favorite",
                  "type": [
                      "null",
                      "boolean"
                  ]
              }
          ]
      }

      In the output schema the record/favorite element is unexpected.

      Attachments

        Issue Links

          Activity

            People

              pgyori Peter Gyori
              pgyori Peter Gyori
              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 - 50m
                  50m