Project: Suppliers

Export Templates

At the moment, Diggernaut supports templates for XML format only.

The unloading template allows you to configure the required data structure when exporting data in manual mode or via API. Switch the digger configuration editor to the Export by clicking on the corresponding tab and selecting the format XML:

If the digger has a data export template set for specific format, Diggernaut will use it automatically when you try download data from any session or via API in this particular format.

The template is an XML document with built-in control structures, similar to the language of the Django templates. All the control elements of this language are quite simple and do not require a long study. you can use official documentation to learn available commands.

  1. Template language
  2. Built-in template tags and filters
  3. Pongo2

Please note:
Diggernaut has slight differences from the Django template language. You can read more about these differences here

As a bonus, we give an example of an export data template from one of the real diggers :)

          <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="{{current_datetime_utc.strftime("%Y-%m-%dT%H:%M:%S")}}">
    <shop>
        <categories>
            <category id="1">Mattresses</category>
            <category id="2">Beds</category>
            <category id="3">Mattress covers</category>
            <category id="4">Bases</category>
            <category id="5">Pillows</category>
            <category id="6">Furniture</category>
            <category id="7" parentId="6">Decorative pillows</category>
            <category id="8" parentId="6">Mirrors and tables</category>
            <category id="9" parentId="6">Armchairs</category>
            <category id="10" parentId="6">Ottomans and banquets</category>
            <category id="11" parentId="6">Curbstones and chests of drawers</category>
            <category id="12" parentId="6">Cabinets and shelving</category>
        </categories>

        <offers date="{{current_datetime_utc.strftime("%Y-%m-%dT%H:%M:%S")}}">
        {% for dt in data %}
        {% if dt.offer.categoryId == "1" %}
          <offer id="{{dt.offer.checksum}}">
            <categoryId>{% if dt.offer.subcategoryId %}{{dt.offer.subcategoryId}}{% else %}{{dt.offer.categoryId}}{% endif %}</categoryId>
            <name>{{dt.offer.model}}</name>
            <description><![CDATA[
            {{dt.offer.description|safe}}
            ]]>
            </description>
            {% if dt.offer.original_url %}
            <param name="URL of webpage">{{dt.offer.original_url}}</param>{% endif %}
            {% if dt.offer.brand %}
            <param name="Brand">{{dt.offer.brand}}</param>{% endif %}
            {% if dt.offer.warranty %}{% if dt.offer.warranty != -1 %}
            <param name="Warranty">{{dt.offer.warranty}}</param>{% endif %}{% endif %}
            {% if dt.offer.ves %}
            <param name="Вес">{{dt.offer.ves}}</param>{% endif %}
            {% if dt.offer.lifetime %}{% if dt.offer.lifetime != -1 %}
            <param name="Lifetime">{{dt.offer.lifetime}}</param>{% endif %}{% endif %}
            {% if dt.offer.hardness %}
            <param name="Hardness">{{dt.offer.hardness}}</param>{% endif %}
            {% if dt.offer.hardness_side_1 %}
            <param name="1-st side hardness">{{dt.offer.hardness_side_1}}</param>{% endif %}
            {% if dt.offer.hardness_side_2 %}
            <param name="2-nd side hardness">{{dt.offer.hardness_side_2}}</param>{% endif %}
            {% if dt.offer.height%}{% if dt.offer.height !="0"%}
            <param name="Height">{{dt.offer.height}}</param>{% endif %}{% endif %}
            {% if dt.offer.width %}
            <param name="Width">{{dt.offer.width}}</param>{% endif %}
            {% if dt.offer.length %}
            <param name="Length">{{dt.offer.length}}</param>{% endif %}
            {% if dt.offer.weight_diff %}{% if dt.offer.weight_diff != -1 %}
            <param name="Allowed difference in weight">{{dt.offer.weight_diff}}</param>{% endif %}{% endif %}
            {% if dt.offer.load %}{% if dt.offer.load != -1 %}
            <param name="Allowed loading">{{dt.offer.load}}</param>{% endif %}{% endif %}
            {% if dt.offer.is_roll %}{% if dt.offer.is_roll == "1" %}
            <param name="Roll">Y</param>{% endif %}{% endif %}
            {% if dt.offer.is_round %}{% if dt.offer.is_round == "1" %}
            <param name="Round">Y</param>{% endif %}{% endif %}
            {% if dt.offer.is_child %}{% if dt.offer.is_child == "1" %}
            <param name="For kids">Y</param>{% endif %}{% endif %}
            {% if dt.offer.transform %}{% if dt.offer.transform != -1 %}
            <param name="Transform">{{dt.offer.transform}}</param>{% endif %}{% endif %}
            {% if dt.offer.basis %}
            <param name="Base">{{dt.offer.basis}}</param>{% endif %}
            {% if dt.offer.natur %}
            <param name="Natural components">{{dt.offer.natur}}</param>{% endif %}
            {% if dt.offer.deepening %}
            <param name="Deepening">{{dt.offer.deepening}}</param>{% endif %}
            {% if dt.offer.height_izn %}
            <param name="Frontal height">{{dt.offer.height_izn}}</param>{% endif %}
            {% if dt.offer.height_on_pol %}
            <param name="Clearance above the floor">{{dt.offer.height_on_pol}}</param>{% endif %}
            {% if dt.offer.height_bok %}
            <param name="Sidewall height">{{dt.offer.height_bok}}</param>{% endif %}
            {% if dt.offer.status %}
            <param name="Status">{{dt.offer.status}}</param>{% endif %}
            {% if dt.offer.height_nozhek %}
            <param name="Height of legs">{{dt.offer.height_nozhek}}</param>{% endif %}

            {% for doc in dt.offer.documents %}
            <param name="Documents" desc="{{doc.name}}">{{doc.url}}</param>
            {% endfor %}
            {% for pic in dt.offer.pictures %}{% if pic.picture|length >0 %}
            <param name="Image">{{pic.picture}}</param>{% endif %}
            {% endfor %}
            {% for pic in dt.offer.sizepicture %}
            <param name="Picture with size">{{pic}}</param>
            {% endfor %}
            {% for trait in dt.offer.traits %}
            <param name="Trait">{{trait.trait}}</param>
            {% endfor %}
            {% for youtube in dt.offer.youtube %}
            <param name="Youtube link">{{youtube.src}}</param>
            {% endfor %}
            {% for layer in dt.offer.layers %}
            <param name="Layer">{{layer.layer}}</param>
            {% endfor %}

            {% for review in dt.offer.reviews %}
            <comment>
                {% if review.author %}<author>{{review.author}}</author>{% endif %}
                {% if review.date %}<date>{{review.date}}</date>{% endif %}
                {% if review.likes %}<like>{{review.likes}}</like>{% endif %}
                {% if review.rating %}<rating>{{review.rating}}</rating>{% endif %}
                {% if review.message %}<message>{{review.message}}</message>{% endif %}
                <source>ormatek</source>
            </comment>
            {% endfor %}

            {% for sku in dt.offer.sku %}
            <sku>
                {% for pic in sku.pictures %}
                <param name="Image">{{pic.picture}}</param>
                {% endfor %}
                {% for pic in sku.detail_pictures %}
                <param name="Image">{{pic.picture}}</param>
                {% endfor %}
                {% if sku.sizepicture %}
                <param name="Picture with sizes">{{sku.sizepicture}}</param>
                {% endif %}
                {% if sku.discountper %}{% if sku.discountper !="0" %}
                <param name="Discount">{{sku.discountper}}</param>{% endif %}{% endif %}
                {% if sku.width %}
                <param name="Width" sku="Y">{{sku.width}}</param>{% endif %}
                {% if sku.length %}
                <param name="Length" sku="Y">{{sku.length}}</param>{% endif %}
                {% if sku.height %}
                <param name="Height" sku="Y">{{sku.height}}</param>{% endif %}
                {% if sku.box %}
                <param name="Case" sku="Y">{{sku.box}}</param>{% endif %}
                {% if sku.price %}{% if sku.old_price %}{% if sku.old_price != sku.price %}
                <param name="Old price">{{sku.old_price}}</param>{% endif %}{% endif %}
                {% endif %}
                {% if sku.width_g %}
                <param name="Width of dimensions">{{sku.width_g}}</param>{% endif %}
                {% if sku.length_g %}
                <param name="Length of dimensions">{{sku.length_g}}</param>{% endif %}
                {% if sku.color %}
                <param name="Color" sku="Y">{{sku.color}}</param>{% endif %}
                {% if sku.material %}
                <param name="Material" sku="Y">{{sku.material}}</param>{% endif %}
                <price>{{sku.price}}</price>
            </sku>
            {% endfor %}
          </offer>
          {% endif %}
        {% endfor %}
        </offers>
    </shop>
</yml_catalog>
          
          <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="2017-10-05T22:12:34">
    <shop>
        <categories>
          <category id="1">Mattresses</category>
          <category id="2">Beds</category>
          <category id="3">Mattress covers</category>
          <category id="4">Bases</category>
          <category id="5">Pillows</category>
          <category id="6">Furniture</category>
          <category id="7" parentId="6">Decorative pillows</category>
          <category id="8" parentId="6">Mirrors and tables</category>
          <category id="9" parentId="6">Armchairs</category>
          <category id="10" parentId="6">Ottomans and banquets</category>
          <category id="11" parentId="6">Curbstones and chests of drawers</category>
          <category id="12" parentId="6">Cabinets and shelving</category>
        </categories>
        <offers date="2017-10-05T22:12:34">
          <offer id="5df67cf15aab714e013ba00c19a62ec7">
            <categoryId>5</categoryId>
            <name>Pillow Light</name>
            <description><![CDATA[
            <div>
<p>Pillow with ergonomic shape, made of environmentally friendly material.
Due to its elasticity and special shape, the pillow ensures the correct position of the head,
It helps to minimize muscle tension, and also promotes complete relaxation and
rest.</p>
</div>
            ]]>
            </description>
            <param name="URL of webpage">https://domain.com/catalog/pillows/product/pillow-light/123123123/</param>
            <param name="Brand">Best</param>
            <param name="Warranty">1.5</param>
            <param name="Lifetime">3</param>
            <param name="1-st side hardness">Average</param>
            <param name="2-nd side hardness">Average</param>
            <param name="Height">10.5</param>
            <param name="Spring block">0</param>
            <param name="Image">https://domain.com/upload/products/123.jpg</param>
            <param name="Image">https://domain.com/upload/products/456.jpg</param>
            <param name="Trait">Pillow with ergonomic shape, made of environmentally friendly material.</param>
          </offer>
        </offers>
    </shop>
</yml_catalog>
          

If you make a mistake in writing a template, Diggernaut will display an error message when you try to download data, indicate the location of the problem in the template and the type of error.