Question

Json to XML with namespaces

  • 18 October 2023
  • 0 replies
  • 25 views

hello,

I’m new to streamsets so it might be an obvious question!

I’m using “data generator” to accept the json input and transform to XML, however I want to add few namespaces in the generated XML output. Please can anyone suggest how to achieve that?

This is the output “data generator” is producing:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<id>file</id>
<value>File</value>
<popup>
<menuitem>
<value>New</value>
<onclick>CreateDoc()</onclick>
</menuitem>
<menuitem>
<value>Open</value>
<onclick>OpenDoc()</onclick>
</menuitem>
<menuitem>
<value>Save</value>
<onclick>SaveDoc()</onclick>
</menuitem>
</popup>
</root>

What changes do I need to make it something like this (the element id is under “b” namespace):

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<root xmlns:b="http://bookstore.com/books">
<b:id>file</id>
<b:value>File</value>
<popup>
<menuitem>
<value>New</value>
<onclick>CreateDoc()</onclick>
</menuitem>
<menuitem>
<value>Open</value>
<onclick>OpenDoc()</onclick>
</menuitem>
<menuitem>
<value>Save</value>
<onclick>SaveDoc()</onclick>
</menuitem>
</popup>
</root>

 


0 replies

Be the first to reply!

Reply