Skip to content
LambogeniusDocs

Compose using XSLT for Azure Logic Apps

Quick start

Install the package, add the connection and a map, and run a workflow locally.

Service provider/serviceProviders/lamboXsltComposeOperation ComposeXslt, shown in the designer as Compose using XSLT.

Transform an order in five steps

  1. 1
    Get the package

    from Downloads, save it in a folder such as packages/, and make that folder a package source:

    <configuration>
      <packageSources>
        <add key="xslt-compose" value="packages" />   <!-- the folder holding the downloaded .nupkg -->
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
      </packageSources>
    </configuration>
  2. 2
    Reference it

    in a NuGet-based Logic Apps Standard project:

    <ItemGroup>
      <PackageReference Include="Lambogenius.XsltCompose.LogicApps" Version="1.1.1" />
    </ItemGroup>

    The package's build targets copy the XSLT worker to xslt-worker/ in the build and publish output. The host.json the runtime reads must not have an extensionBundle section, or the runtime ignores the project's packages; the samples remove it from the build and publish copies.

  3. 3
    Add the connection and the settings.
    {
      "serviceProviderConnections": {
        "lamboXsltCompose": {
          "displayName": "Lambogenius XSLT",
          "serviceProvider": { "id": "/serviceProviders/lamboXsltCompose" },
          "parameterValues": { "mapFolder": "" }
        }
      }
    }
    {
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "APP_KIND": "workflowApp",
        "FUNCTIONS_INPROC_NET8_ENABLED": "1"
      }
    }
  4. 4
    Add a map

    as Artifacts/Maps/orders/order-to-sales-order.xslt:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
      <xsl:param name="currency" select="'CAD'"/>
      <xsl:template match="/Order">
        <SalesOrder>
          <OrderNumber><xsl:value-of select="normalize-space(Number)"/></OrderNumber>
          <Currency><xsl:value-of select="$currency"/></Currency>
          <Lines><xsl:value-of select="count(Lines/Line)"/></Lines>
        </SalesOrder>
      </xsl:template>
    </xsl:stylesheet>
  5. 5
    Create the workflow and run it.
    {
      "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "contentVersion": "1.0.0.0",
        "triggers": {
          "When_an_HTTP_request_is_received": { "type": "Request", "kind": "Http", "inputs": { "method": "POST" } }
        },
        "actions": {
          "Compose_using_XSLT": {
            "type": "ServiceProvider",
            "inputs": {
              "parameters": {
                "content": "@{triggerBody()}",
                "mapSource": "deployed",
                "mapName": "orders/order-to-sales-order.xslt",
                "parameters": { "currency": "CAD" }
              },
              "serviceProviderConfiguration": {
                "connectionName": "lamboXsltCompose",
                "operationId": "ComposeXslt",
                "serviceProviderId": "/serviceProviders/lamboXsltCompose"
              }
            },
            "runAfter": {}
          },
          "Response": {
            "type": "Response",
            "kind": "Http",
            "inputs": {
              "statusCode": 200,
              "headers": { "Content-Type": "@{body('Compose_using_XSLT')?['contentType']}" },
              "body": "@body('Compose_using_XSLT')?['result']"
            },
            "runAfter": { "Compose_using_XSLT": [ "Succeeded" ] }
          }
        },
        "outputs": {}
      },
      "kind": "Stateful"
    }

    Run dotnet build, then func start in bin/Debug/net8.0, and POST an order as application/xml to the trigger URL. No license is needed under func start; before you deploy, get one (see Licensing).

Faster: start from a sample

The samples repository has four ready-made Logic Apps. ./run.ps1 builds and starts one, and ./demo.ps1 calls every workflow and checks the answers.