Home > Net >  Azure Logic App ignores indent="yes" when transforming XML
Azure Logic App ignores indent="yes" when transforming XML

Time:09-21

I'm using Azure Logic App to transform a CSV file to XML, everything was initially set up in BizTalk first to generate the relevant XSDs and XSL which worked perfectly fine. But when I use Azure Logic App the output XML file is all in one line even though I made sure it has indent="yes" in the XSL file.

enter image description here

I know I can use notepad to pretty print the result and save the file, but surely there's a way to automatically do that in Logic App?

CodePudding user response:

I manage to get indentation when using XSLT 3.0 with e.g. the stylesheet/map doing

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="3.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="#all"
  expand-text="yes">

  <xsl:output method="xml" indent="yes"/>

  <xsl:mode on-no-match="shallow-copy"/>

  <xsl:template match="/" name="xsl:initial-template">
    <xsl:next-match/>
    <xsl:comment xmlns:saxon="http://saxon.sf.net/">Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}</xsl:comment>
  </xsl:template>

</xsl:stylesheet>

then a request of e.g.

<root><item>a</item><item>b</item></root>

is transformed to the output

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <item>a</item>
   <item>b</item>
</root>
<!--Run with SAXON HE 9.8.0.8 -->

I don't know how they run the XSLT 1.0 processor to ignore the xsl:output settings, seems a flaw or quirk in the pipeline.

  • Related