Icon

Simple Customisable XML Generation with Components

Simple Customisable XML Generation from table with components
<?xml version=1.0 encoding=UTF-8?><people><person><PERSON_ID>101</PERSON_ID><PERSON_NAME>Andrew</PERSON_NAME><YEAR_OF_BIRTH>1972</YEAR_OF_BIRTH></person><person><PERSON_ID>108</PERSON_ID><PERSON_NAME>Brian</PERSON_NAME><YEAR_OF_BIRTH>1980</YEAR_OF_BIRTH></person><person><PERSON_ID>103</PERSON_ID><PERSON_NAME>Claire</PERSON_NAME><YEAR_OF_BIRTH>2000</YEAR_OF_BIRTH></person><person><PERSON_ID>110</PERSON_ID><PERSON_NAME>Deborah</PERSON_NAME><YEAR_OF_BIRTH>1995</YEAR_OF_BIRTH></person></people> person_name person_id year of birthAndrew 101 1972Brian 108 1980Claire 103 2000Deborah 110 1995 Generate customisable XMLAn introductory workflow to generate XML from a table. It is possible to domuch the same as this using Table to JSON and JSON to XML, but themechanism here provides greater flexibility when we then wish toprogress further by joining to other tables, and build up a more complexnested XML structure.This flow builds on the original "Simple" flow I created, but additionallyuses some components for changing column titles to an XML-compatibleformat, and generating the column XMLBrian Bates @takbb 31 March 2021 Here we have a couple of components that I'veadded. The first takes the individual columnnames and converts them to upper case, aswell as converting spaces in names tounderscores.so "year of birth" becomes "YEAR_OF_BIRTH" This extracting of context properties and use ofJava Edit Variable is included here onlybecause I couldn't find a way of using relativefile paths with XML Row Combine and Write.There may be another way to do this that Icouldn't find, and In future, this may not benecessary.When adding the File Reader I found that thepath variable required for the WRITE was notcompatible with the one required for READ, so Ihad to add a second flow variable into the JavaEdit Variable node A second component thenconverts every column to XML Finally the individual columnXML values are combinedinto a single row XML value Combine xml from person_id and person_name into a single xml columnArrange columnsinto theorder I wish for xml output.Put rows together to write as a single XML file"./data/simpleOutput.xml"Manual table containing person_nameand person_idCollect Define xml filename relative relative to workflowas XML Row Combine & Writedoesn't have relative pathsReader added for convenience of inspecting the generated xml XML CompatibleColumn Names XML Column Combiner Column Resorter XML Row Combineand Write Table Creator Extract ContextProperties Java Edit Variable File Reader All Columns to XML <?xml version=1.0 encoding=UTF-8?><people><person><PERSON_ID>101</PERSON_ID><PERSON_NAME>Andrew</PERSON_NAME><YEAR_OF_BIRTH>1972</YEAR_OF_BIRTH></person><person><PERSON_ID>108</PERSON_ID><PERSON_NAME>Brian</PERSON_NAME><YEAR_OF_BIRTH>1980</YEAR_OF_BIRTH></person><person><PERSON_ID>103</PERSON_ID><PERSON_NAME>Claire</PERSON_NAME><YEAR_OF_BIRTH>2000</YEAR_OF_BIRTH></person><person><PERSON_ID>110</PERSON_ID><PERSON_NAME>Deborah</PERSON_NAME><YEAR_OF_BIRTH>1995</YEAR_OF_BIRTH></person></people> person_name person_id year of birthAndrew 101 1972Brian 108 1980Claire 103 2000Deborah 110 1995 Generate customisable XMLAn introductory workflow to generate XML from a table. It is possible to domuch the same as this using Table to JSON and JSON to XML, but themechanism here provides greater flexibility when we then wish toprogress further by joining to other tables, and build up a more complexnested XML structure.This flow builds on the original "Simple" flow I created, but additionallyuses some components for changing column titles to an XML-compatibleformat, and generating the column XMLBrian Bates @takbb 31 March 2021 Here we have a couple of components that I'veadded. The first takes the individual columnnames and converts them to upper case, aswell as converting spaces in names tounderscores.so "year of birth" becomes "YEAR_OF_BIRTH" This extracting of context properties and use ofJava Edit Variable is included here onlybecause I couldn't find a way of using relativefile paths with XML Row Combine and Write.There may be another way to do this that Icouldn't find, and In future, this may not benecessary.When adding the File Reader I found that thepath variable required for the WRITE was notcompatible with the one required for READ, so Ihad to add a second flow variable into the JavaEdit Variable node A second component thenconverts every column to XML Finally the individual columnXML values are combinedinto a single row XML value Combine xml from person_id and person_name into a single xml columnArrange columnsinto theorder I wish for xml output.Put rows together to write as a single XML file"./data/simpleOutput.xml"Manual table containing person_nameand person_idCollect Define xml filename relative relative to workflowas XML Row Combine & Writedoesn't have relative pathsReader added for convenience of inspecting the generated xml XML CompatibleColumn Names XML Column Combiner Column Resorter XML Row Combineand Write Table Creator Extract ContextProperties Java Edit Variable File Reader All Columns to XML

Nodes

Extensions

Links