0. Pre-work needed to configure this connector

1. Generate a Jinja template file

We use Jinja templates to map the data from the input table to your XML file. You can use conditionals, for loops and other features available on Jinja to make your template dynamic and flexible to fit your needs. You can also add attributes to tags, if needed.

Example

Imagine the following input table:

titledescriptionsale_pricetotal_areafeatures
Cozy CottageA cozy cottage in the countryside.$150,0001,200 sqft[“Fireplace”, “Garden”]
Modern ApartmentA sleek apartment in the city center.$300,000850 sqft[“Gym”, “Rooftop”]
Family HouseSpacious family home with a large backyard.$400,0002,500 sqft[“Backyard”, “Garage”]
Luxurious VillaA luxury villa with ocean views.$1,500,0004,500 sqft[“Pool”, “Home Theater”]
Studio ApartmentCompact studio with modern amenities.$200,000600 sqft[“Central Heating”, “Balcony”]

If you want to map these values to an XML file, here’s how your template would look like:

{% for listing in records %}
<Listing>
    <Title>{{ listing.title }}</Title>
    <Description>{{ listing.description }}</Description>
    <Details>
        <ListPrice>{{ listing.sale_price }}</ListPrice>
        <TotalArea>{{ listing.total_area }}</TotalArea>
        <Features>
            {% for feature in listing.features %}
            <Feature>{{ feature }}</Feature>
            {% endfor %}
        </Features>
    </Details>
</Listing>
{% endfor %}

Where:

  • records correspond to the rows of incoming data from a table in your Data Lake that you will select while configuring the destination
  • <Listing> is the name of the target tag

This template file combined with the input table from the section above would render the following list of target tags.

<Listing>
	<Title>Cozy Cottage</Title>
	<Description>A cozy cottage in the countryside.</Description>
	<Details>
		<ListPrice>$150,000</ListPrice>
		<TotalArea>1,200 sqft</TotalArea>
		<Features>
			<Feature>Fireplace</Feature>
			<Feature>Garden</Feature>
		</Features>
	</Details>
</Listing>
<Listing>
	<Title>Modern Apartment</Title>
	<Description>A sleek apartment in the city center.</Description>
	<Details>
		<ListPrice>$300,000</ListPrice>
		<TotalArea>850 sqft</TotalArea>
		<Features>
			<Feature>Gym</Feature>
			<Feature>Rooftop</Feature>
		</Features>
	</Details>
</Listing>
<Listing>
	<Title>Family House</Title>
	<Description>Spacious family home with a large backyard.</Description>
	<Details>
		<ListPrice>$400,000</ListPrice>
		<TotalArea>2,500 sqft</TotalArea>
		<Features>
			<Feature>Backyard</Feature>
			<Feature>Garage</Feature>
		</Features>
	</Details>
</Listing>
<Listing>
	<Title>Luxurious Villa</Title>
	<Description>A luxury villa with ocean views.</Description>
	<Details>
		<ListPrice>$1,500,000</ListPrice>
		<TotalArea>4,500 sqft</TotalArea>
		<Features>
			<Feature>Pool</Feature>
			<Feature>Home Theater</Feature>
		</Features>
	</Details>
</Listing>
<Listing>
	<Title>Studio Apartment</Title>
	<Description>Compact studio with modern amenities.</Description>
	<Details>
		<ListPrice>$200,000</ListPrice>
		<TotalArea>600 sqft</TotalArea>
		<Features>
			<Feature>Central Heating</Feature>
			<Feature>Balcony</Feature>
		</Features>
	</Details>
</Listing>

2. Add write permissions to your S3 bucket

The XML file generated by this destination will be uploaded to an S3 bucket specified when configuring the connector. For that, you have to grant write permissions to Nekt, so the connector can write files to this bucket.

Here’s the step-by-step:

  • Add the following policy to your S3 bucket:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": [
          "arn:aws:iam::720174903362:role/nekt-backend-production-execution-role", // If the bucket is in the same AWS account as your Nekt workspace, you don't need this line
          "arn:aws:iam::<YOUR_AWS_ACCOUNT_ID>:role/nekt-ecs-task-role"
        ]
      },
      "Action": ["s3:ListBucket", "s3:GetObject", "s3:PutObject"],
      "Resource": [
        "arn:aws:s3:::<BUCKET_NAME>",
        "arn:aws:s3:::<BUCKET_NAME>/*" // Here you can limit access to a specific folder
      ]
    }
  ]
}
  • Add the following permission block to nekt-ecs-task-role (be careful to not modify existing permissions):
{
  "Action": ["s3:GetObject", "s3:PutObject", "s3:ListBucket"],
  "Resource": ["arn:aws:s3:::<BUCKET_NAME>", "arn:aws:s3:::<BUCKET_NAME>/*"],
  "Effect": "Allow",
  "Sid": ""
}

Now you’re ready to jump to the next step and configure your XML destination.

1. Configure the XML connector

  1. In the Destinations tab, click on the “Add destination” button located on the top right of your screen. Then, select the XML option from the list of connectors.

  2. Click Next and you’ll be prompted to add your access:

  • XML format: The format of the XML file to use pre-defined names for the static part of the XML file, including root tags, header and footer.
  • Jinja template file: The jinja template file used to map the input table data to the target element structure. Don’t forget to validate your jinja template to ensure sure your destination will work as expected.
  • Bucket name: The name of the S3 bucket where the generated XML file will be stored.
  • S3 folder path: Optionally define the name of folder inside the S3 bucket where the generated XML file will be stored.
  • Output file name: The static name of the generated XML file that will be uploaded to S3.
  1. Click Next.

2. Select the data from Catalog to send

  1. The next step is letting us know which data you want to send to the XML. Select the layer and then the desired table.

    Tip: The table can be found more easily by typing its name.

  2. Click Next.

3. Configure your XML data destination

  1. Describe your destination for easy identification within your organization. You can inform things like what data it sends, to which team it belongs, etc.

  2. To define your Trigger, consider how often you want data to be sent to this destination. This decision usually depends on how frequently you need the data updated on your XML (every day, once a week, only at specific times, etc.).

  3. Click Done.

Check your new destination!

  1. Once completed, you’ll receive confirmation that your new destination is set up!

  2. You can view your new destination on the Destinations page. Now, for you to be able to see it on your XML, you have to wait for the pipeline to run. You can monitor it on the Destinations page to see its execution and completion. If needed, manually trigger the pipeline by clicking on the refresh icon.

Once executed, your data should be seen on the defined XML location.

If you encounter any issues, reach out to us via Slack, and we’ll gladly assist you!