How to create an avro schema containing list of records for apache nifi?

22 Views Asked by At

i'm trying to write an avro schema that will give me all attributes for the following xml:

<Criterion name="crit1" critName="crit1" ordering="6010" validFrom="2017-10-19" validTo="2222-02-22">false</Criterion>
<Criterion name="crit2" critName="crit2" ordering="6020" validFrom="2017-10-30" validTo="2222-02-22">aktiv</Criterion>
<Criterion name="crit3" critName="crit3" ordering="7000" validFrom="2018-04-26" validTo="2222-02-22">
Fristigkeit
<ValueParameter longName="Aufbewahrungsfrist" ordering="0"/>
</Criterion>

i'm using the following avro schema to transform the xml:

{"name": "Criterion", "type": {
      "type":"array",
      "items":{
        "name":"Criterion",
        "type":"record",
        "fields":[
          {"name":"value", "type":"string"},
          {"name":"action", "type":"string"},
          {"name":"name", "type":"string"},
          {"name":"critName", "type":"string"},
          {"name":"ordering", "type":"int"},
          {"name":"validFrom", "type":"string"},
          {"name":"validTo", "type":"string"},
          {"name":"ValueParameter", "type": {
            "type":"record",
            "name":"ValueParameter",
            "fields":[
              {"name": "longName", "type": ["null", "string"]},
              {"name": "ordering", "type": ["null", "int"]}
            ]}
          }
        ]
      }
    }}

i get the following Json:

"Criterion" : [ {
    "value" : null,
    "action" : null,
    "name" : "crit1",
    "critName" : "crit1",
    "ordering" : 6010,
    "validFrom" : "2017-10-19",
    "validTo" : "2222-02-22",
    "ValueParameter" : null
  }, {
    "value" : null,
    "action" : null,
    "name" : "crit2",
    "critName" : "crit2",
    "ordering" : 6020,
    "validFrom" : "2017-10-30",
    "validTo" : "2222-02-22",
    "ValueParameter" : null
  }, {
    "value" : null,
    "action" : null,
    "name" : "crit3",
    "critName" : "crit3",
    "ordering" : 7000,
    "validFrom" : "2018-04-26",
    "validTo" : "2222-02-22",
    "ValueParameter" : {
      "longName" : "Aufbewahrungsfrist",
      "ordering" : 0
    }
  }
]

Now i'm missing the value 'false' for crit1, 'aktiv' for crit2 and 'Fristigkeit' for crit3. How can i get these values?

0

There are 0 best solutions below