Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

NiFi updaterecord with xmlreader and xmlwriter not properly writing final xml output

NiFi updaterecord with xmlreader and xmlwriter not properly writing final xml output

New Contributor

I am trying to convert an xml to avro and then back to xml. My original xml looks like the one below.

<?xml version="1.0" encoding="UTF-8"?>
<nifiRecord xmlns="http://test.org">
  <Id></cId>
  <Type></Type>
  <Order></Order>
  <Data></Data>
  <Reset></Reset>
  <Filename></Filename>
  <Modified></Modified>
  <Summary>
    <Ingest>
      <Type></type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
    <Ingest>
      <Type></Type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
    <Ingest>
      <Type></Type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
  </Summary>
  <Sets>
    <Set>
      <Id></Id>
      <testid></testId>
      <input><input>
      <Modified><Modified>
    </Set>
  </Sets>
</nifiRecord>

When converting from xml to avro the xmlns=http://test.org namespace is left out. After I have converted the avro back to it's original xml the xmlns namespace has been left out. 

<?xml version="1.0" encoding="UTF-8"?>
<nifiRecord>
  <Id></cId>
  <Type></Type>
  <Order></Order>
  <Data></Data>
  <Reset></Reset>
  <Filename></Filename>
  <Modified></Modified>
  <Summary>
    <Ingest>
      <Type></type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
    <Ingest>
      <Type></Type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
    <Ingest>
      <Type></Type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
  </Summary>
  <Sets>
    <Set>
      <Id></Id>
      <testid></testId>
      <input><input>
      <Modified><Modified>
    </Set>
  </Sets>
</nifiRecord>

I am trying to use a convertrecord with xmlreader and xmlwriter to add the xmlns namespace back into the xml. Doing something like below, but it's not adding it correctly. How can I put the namespace in its proper format? 

avro.PNG

But my final output is this. 

<?xml version="1.0" encoding="UTF-8"?>
<nifiRecord>
  <Id></Id>
  <Type></Type>
  <Order></Order>
  <Data></Data>
  <Reset></Reset>
  <Filename></Filename>
  <Modified></Modified>
  <Summary>
    <Ingest>
      <Type></type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
    <Ingest>
      <Type></Type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
    <Ingest>
      <Type></Type>
      <insert></insert>
      <update></update>
      <delete></delete>
    </Ingest>
  </Summary>
  <Sets>
    <Set>
      <Id></Id>
      <testid></testId>
      <input><input>
      <Modified><Modified>
    </Set>
  </Sets>
  <nifiRecord>xmlns=http://test.org</nifiRecord>
</nifiRecord>
Don't have an account?
Coming from Hortonworks? Activate your account here