Problem creating mapping structure for XMLWriter

Hi,

I want to send delimited separated meta data record to xml file. I tried using XMLWriter but I am facing issues in creating mapping structure for XMLWriter. Actually my XML structure is not fixed, I need to generated XML dynamically based on certain decisions. So I need a generic mapping structure which would work for every scenario.

XMLWriter:
The record is in the form of field1,field2,field3 etc. and I need to generate XML structures from this record. One of my XML structure is:


<?xml version="1.0" encoding="UTF-8"?> 
<Rows> 
	<Row>
		<Item_Number>
			<ID>field4</ID>
		</Item_Number> 
		<GTIN_Number code="field2"/>
		<Mill_Code>field5</Mill_Code> 
		<Mill_Description>
			<ID>field1</ID>
		</Mill_Description>
		<Style_Number>
			<Style>
				<ManufactureName name="field3">
					<ID>field6</ID>
				</ManufactureName> 
			</Style>
		</Style_Number>
	</Row>
	<Row>
		<Item_Number>
			<ID>field4</ID>
		</Item_Number> 
		<GTIN_Number code="field2"/>
		<Mill_Code>field5</Mill_Code> 
		<Mill_Description>
			<ID>field1</ID>
		</Mill_Description>
		<Style_Number>
			<Style>
				<ManufactureName name="field3">
					<ID>field6</ID>
				</ManufactureName> 
			</Style>
		</Style_Number>
	</Row>
	...
	...
</Rows>

Please help me in creating an mapping structure for the same.

Thanks in advance

Pushpendra

Hello,
if you don’t need to join records from different input ports use StructureWriter instead of XMLWriter.

Hi Agata,

Thanks for your quick reply.
I have tried using StructureWriter as well and using this component I am not able to generate a valid XML file.
I have set mapping for the body mask for generating xml file in above format as:


<Row>
		<Item_Number>
			<ID>$field4</ID>
		</Item_Number> 
		<GTIN_Number code="$field2"/>
		<Mill_Code>$field5</Mill_Code> 
		<Mill_Description>
			<ID>$field1</ID>
		</Mill_Description>
		<Style_Number>
			<Style>
				<ManufactureName name="$field3">
					<ID>$field6</ID>
				</ManufactureName> 
			</Style>
		</Style_Number>
	</Row>

As in case of xml, header and footer won’t be required , so I didn’t set footer mask and header mask for the same.

The invalid generated XML file structure is:


<Row>
		<Item_Number>
			<ID>345</ID>
		</Item_Number> 
		<GTIN_Number code="1234"/>
		<Mill_Code>345</Mill_Code> 
		<Mill_Description>
			<ID>345</ID>
		</Mill_Description>
		<Style_Number>
			<Style>
				<ManufactureName name="234dfsd4">
					<ID>345</ID>
				</ManufactureName> 
			</Style>
		</Style_Number>
	</Row>
    <Row>
		<Item_Number>
			<ID>sdfd3443</ID>
		</Item_Number> 
		<GTIN_Number code="345"/>
		<Mill_Code>field5</Mill_Code> 
		<Mill_Description>
			<ID>3432</ID>
		</Mill_Description>
		<Style_Number>
			<Style>
				<ManufactureName name="wer3fd">
					<ID>fs2343</ID>
				</ManufactureName> 
			</Style>
		</Style_Number>
	</Row>

The Rows which is root node is not present in the XML generated file.

Also I would like to know how to set the namespaces by using StructureWriter for XML files.

Thanks
Pushpendra

Set static header:

<?xml version="1.0" encoding="UTF-8"?>
<Rows> 

and footer:

</Rows>

Namespaces can’t be used with StructureWriter.

Is it possible to map multiple inputs for the body part?