Forum Discussion

darshthakkar's avatar
darshthakkar
Valued Contributor
3 years ago
Solved

Converting value of input schema to distinct columns

First time trying to format into XML with SnapLogic. I have CSV data that I am trying to convert into XML. There are repeating elements, possibly multiple, in the schema. 

I've pared down the schema and file to work with here. My actual schema contains over a hundred fields.

I am able to read in the file, and use a Mapper with either XML Formatter or XML Generator to create basic XML file based on adding the XSD to those snaps. 

However, it creates multiple files because the CSV Parser is outputting as multiple documents. 

Where I'm struggling is that if I add a Root Element into the XML Formatter to consolidate the documents, then it adds extra Document tags, which then fail the XSD validation. If I do something like a Gate to combine documents up front, then I can't use the Mapper the same way to map fields to the schema. And in neither of those cases am I able to successfully create the repeating elements, like multiple dependents under a specific employee.

Sample data file and pipeline are attached. Schema pasted below since I cannot attach

Any insight is appreciated. I can't tell if I'm very close or on a completely wrong path.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<xs:element name="Member">
		<xs:complexType>
			<xs:all>
				<xs:element ref="EmployeeRecordsList" />
			</xs:all>
		</xs:complexType>
	</xs:element>

	<!-- Dependent RecordsList -->
	<xs:element name="DependentRecordsList">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="DependentRecord" maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="DependentRecord">
		<xs:complexType>
			<xs:all>
				<!-- Dependent Personal Information -->
				<xs:element name="EENo" minOccurs="0" />
				<xs:element name="DepSSN" minOccurs="0" />
				<xs:element name="FirstName" minOccurs="1" />
				<xs:element name="LastName" minOccurs="1" />
				<xs:element name="RelationshipToEmployee" minOccurs="0" />
				<xs:element name="Gender" minOccurs="0" />
			</xs:all>
		</xs:complexType>
	</xs:element>
	<!-- Employee Record List -->
	<xs:element name="EmployeeRecordsList">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="EmployeeRecord" minOccurs="0" maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<!-- Employee Record -->
	<xs:element name="EmployeeRecord">
		<xs:complexType>
			<xs:all>
				<!-- Employee Personal Information -->
				<xs:element name="EENo" minOccurs="0" />
				<!-- Dependent Record List -->
				<xs:element ref="DependentRecordsList"  minOccurs="0" />								
			</xs:all>
		</xs:complexType>
	</xs:element>
</xs:schema>