{
  "nodes": [
    {
      "id": "bca571ac-25dc-470d-b249-460861e99791",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        660,
        380
      ],
      "parameters": {
        "path": "81115579-ca32-496f-baa7-f14fb3baec6f",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 1
    },
    {
      "id": "e851d287-f739-462e-816b-605daf7b4897",
      "name": "Show 16 random products",
      "type": "n8n-nodes-base.mySql",
      "position": [
        840,
        380
      ],
      "parameters": {
        "query": "SELECT * from products\nORDER BY RAND()\nLIMIT 16;",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "895725ed-e250-408b-95f5-32223a58adfe",
      "name": "Define file structure",
      "type": "n8n-nodes-base.set",
      "position": [
        1020,
        380
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Product.Code",
              "value": "={{ $json.productCode }}"
            },
            {
              "name": "Product.Name",
              "value": "={{ $json.productName }}"
            },
            {
              "name": "Product.Line",
              "value": "={{ $json.productLine }}"
            },
            {
              "name": "Product.Scale",
              "value": "={{ $json.productScale }}"
            },
            {
              "name": "Product.Price",
              "value": "={{ $json.MSRP }}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 2
    },
    {
      "id": "4bf5deb3-56d8-45f3-8c26-01cd7e58968c",
      "name": "Concatenate Items",
      "type": "n8n-nodes-base.itemLists",
      "position": [
        1200,
        380
      ],
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "operation": "concatenateItems",
        "destinationFieldName": "Products"
      },
      "typeVersion": 3
    },
    {
      "id": "0d97118d-bf0c-4084-9d18-54fed1a9c8b6",
      "name": "Convert to XML",
      "type": "n8n-nodes-base.xml",
      "position": [
        1380,
        380
      ],
      "parameters": {
        "mode": "jsonToxml",
        "options": {
          "headless": true
        }
      },
      "typeVersion": 1
    },
    {
      "id": "670f23f3-2b18-4121-93c8-6b047f999054",
      "name": "Create HTML",
      "type": "n8n-nodes-base.html",
      "position": [
        1760,
        380
      ],
      "parameters": {
        "html": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<?xml-stylesheet type=\"text/xsl\" href=\"{{ $env.WEBHOOK_URL }}webhook/044ccd2d-d1a7-485b-bb22-218a6848fd1c/models.xsl\"?>\n\n{{ $json.data }}"
      },
      "typeVersion": 1
    },
    {
      "id": "43bb6052-4a4e-4951-836b-ee5afe478188",
      "name": "Move Binary Data",
      "type": "n8n-nodes-base.moveBinaryData",
      "position": [
        2240,
        380
      ],
      "parameters": {
        "mode": "jsonToBinary",
        "options": {
          "mimeType": "text/xml",
          "keepSource": false,
          "useRawData": true
        },
        "sourceKey": "html",
        "convertAllData": false
      },
      "typeVersion": 1
    },
    {
      "id": "3ca41f0f-e21a-450e-bfbe-8d94c3f65277",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2420,
        380
      ],
      "parameters": {
        "options": {
          "responseCode": 200,
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "text/xml"
              },
              {
                "name": "Control-Allow-Origin",
                "value": "*"
              }
            ]
          }
        },
        "respondWith": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "776db7a4-7e03-4bb1-a937-e15cb1f66a59",
      "name": "Get XSLT",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        840,
        740
      ],
      "parameters": {
        "url": "https://gist.githubusercontent.com/teds-tech-talks/02c4bb157627e5e9031df996ffa7d2d2/raw/9a058ba2866c9853c52cdd136c74276b883af04a/models.xsl",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "aedf30e5-d670-4f14-8ba1-f7afd613628d",
      "name": "Respond to Webhook1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1020,
        740
      ],
      "parameters": {
        "options": {
          "responseCode": 200,
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "text/xsl"
              }
            ]
          }
        },
        "respondWith": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "cb69cda9-3639-46cc-a16d-aaf101261fb2",
      "name": "Request xsl template",
      "type": "n8n-nodes-base.webhook",
      "position": [
        660,
        740
      ],
      "parameters": {
        "path": "044ccd2d-d1a7-485b-bb22-218a6848fd1c/models.xsl",
        "options": {
          "rawBody": false
        },
        "responseMode": "responseNode"
      },
      "typeVersion": 1
    },
    {
      "id": "306bc89e-d497-4344-9bb5-6f4ea607130a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        657.1779141104296
      ],
      "parameters": {
        "width": 644.1717791411014,
        "height": 249.44785276073617,
        "content": "### This webhook is needed to comply with the CORS policy of modern browsers.\n### It requests XSL template stored on GitHub gist and serves it using your n8n URL"
      },
      "typeVersion": 1
    },
    {
      "id": "5f57d577-577f-4dc9-a0b3-696fedeeab08",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        234.8490345891829
      ],
      "parameters": {
        "width": 728.0981595091996,
        "height": 315.4577138770747,
        "content": "## Get data from SQL and convert it to XML\n### Note that XML node has an activated Headless toggle"
      },
      "typeVersion": 1
    },
    {
      "id": "21ecc2b5-8ae1-421b-8a0e-8d75d94dd63e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1560,
        233.36956603560543
      ],
      "parameters": {
        "width": 511.65644171779115,
        "height": 315.43648613045264,
        "content": "## Set node can be used as well\n### XML declaration and a link to the XSL template are added here\n### Note that {{$env.WEBHOOK_URL}} variable is used, so that an URL of your n8n instance is automatically selected"
      },
      "typeVersion": 1
    },
    {
      "id": "84df91b1-767b-46fb-aa1f-847b549a3c0d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2100,
        237.0954119462532
      ],
      "parameters": {
        "width": 531.5337423312881,
        "height": 312.1448304414918,
        "content": "## Convert to binary data and send the webhook response"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Show 16 random products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get XSLT": {
      "main": [
        [
          {
            "node": "Respond to Webhook1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create HTML": {
      "main": [
        [
          {
            "node": "Move Binary Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to XML": {
      "main": [
        [
          {
            "node": "Create HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move Binary Data": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Concatenate Items": {
      "main": [
        [
          {
            "node": "Convert to XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request xsl template": {
      "main": [
        [
          {
            "node": "Get XSLT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Define file structure": {
      "main": [
        [
          {
            "node": "Concatenate Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show 16 random products": {
      "main": [
        [
          {
            "node": "Define file structure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}