Skip to main content
Question

How to create an XML Wrapper for an xml Templater?

  • August 25, 2017
  • 1 reply
  • 69 views

r7
Contributor
Forum|alt.badge.img+4
  • Contributor

I am using the XML Templater to transform data from a shapefile into an xml document. The Transformer creates one complete xml child node for each dataset perfectly. But this is not a complete xml file because I still need to add additional header information into the final XML Document before it is ready to be used in another application. In other words, I need to insert my XML Nodes  into a Wrapper document. AM I able to do this with the XML-Templater or do I need to use an additional transformer?

Think of it like this.

My Templater creates this:

<parent>
	<child>
		<value>
	</child>
	<child>
		<value>
	</child>
</parent>

But I need:

<?xml version="1.0" encoding="utf-8"?>
<CABS_BPLAN_Records xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ikxBase="http://schemas.webs.idu.de/cardo3/Ikx/IkxBase" xsi:schemaLocation="http://www.cardogis.com/ikx/schema/HEIDEKREIS/Exchange puzzle.xsd" xmlns="http://www.cardogis.com/ikx/schema/HEIDEKREIS/Exchange">

<parent>
	<child>
		<value>
	</child>
	<child>
		<value>
	</child>
</parent>

</CABS_BPLAN_Records>

1 reply

takashi
Influencer
  • August 25, 2017

Hi @r7, you can just surround the <parent> fragment by the root tag <CABS_BPLAN_Records xmlns:xsi= ...>...</CABS_BPLAN_Records> in the template expression.

If the root tag should contain multiple <parent> fragments, consider using the SUB template to create <parent> fragments and surround them by the root tag in the ROOT template, like this.

<CABS_BPLAN_Records xmlns:xsi= ...>
{fme:process-features("SUB")}
</CABS_BPLAN_Records>

The XML header <?xml ...?> will be added by the XMLTemplater automatically by default. Alternatively, you can also modify the header (encoding) with the XMLFormatter if necessary.

See also this article: XML Writing with XMLTemplater 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings