question

MarekDbrowski-5426 avatar image
0 Votes"
MarekDbrowski-5426 asked ·

Logic Apps - Transform XML (XSLT) using it to create a CSV (text) file.

Hello,

I try to do a simple transform XML to CSV (text output) using Logic App 'Transfrom XML' functionality.
So i created right maps that work in XML Transformation (in Notepad++) and also other converter like https://www.freeformatter.com/ etc.

SIMPLE XML that i try:

 <?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34; standalone=&#34;no&#34;?>
 <CATALOG>
 <PLANT>
 <COMMON>Bloodroot</COMMON>
 <BOTANICAL>Sanguinaria canadensis</BOTANICAL>
 <ZONE>4</ZONE>
 <LIGHT>Mostly Shady</LIGHT>
 <PRICE>$2.44</PRICE>
 <AVAILABILITY>031599</AVAILABILITY>
 </PLANT>
 <PLANT>
 <COMMON>Columbine</COMMON>
 <BOTANICAL>Aquilegia canadensis</BOTANICAL>
 <ZONE>3</ZONE>
 <LIGHT>Mostly Shady</LIGHT>
 <PRICE>$9.37</PRICE>
 <AVAILABILITY>030699</AVAILABILITY>
 </PLANT>
 </CATALOG>

One of the .XSLT idea that should work in Logic App:

 <?xml version=&#34;1.0&#34;?>
 <xsl:stylesheet version=&#34;1.0&#34; xmlns:xsl=&#34;http://www.w3.org/1999/XSL/Transform&#34;>
 <xsl:output method=&#34;text&#34;/>
 <xsl:variable name='newline'><xsl:text>
 </xsl:text></xsl:variable>
 <xsl:variable name='comaVar'><xsl:text>,</xsl:text></xsl:variable>
 <xsl:template match=&#34;/CATALOG&#34;>
 <xsl:value-of select=&#34;concat('COMMON,BOTANICAL,ZONE,LIGHT,PRICE,AVAILABILITY',$newline)&#34;/>
 <xsl:for-each select=&#34;./PLANT&#34;>
 <xsl:value-of select=&#34;concat('&quot;',./COMMON,'&quot;',$comaVar,'&quot;',./BOTANICAL,'&quot;',$comaVar,./ZONE,$comaVar,'&quot;',./LIGHT,'&quot;',$comaVar,./PRICE,$comaVar,./AVAILABILITY,$newline)&#34;/>
 </xsl:for-each>
 </xsl:template>
 </xsl:stylesheet>

What i should achieve:

 COMMON,BOTANICAL,ZONE,LIGHT,PRICE,AVAILABILITY
 "Bloodroot","Sanguinaria canadensis",4,"Mostly Shady",$2.44,031599
 "Columbine","Aquilegia canadensis",3,"Mostly Shady",$9.37,030699

Every time i try it on diffrent ideas in .xslt i have same &#39;BadRequest&#39; info in Logic App Designer:

{
&#34;statusCode&#34;: 400,
&#34;headers&#34;: {
&#34;Pragma&#34;: &#34;no-cache&#34;,
&#34;Cache-Control&#34;: &#34;no-cache&#34;,
&#34;Date&#34;: &#34;Tue, 14 Apr 2020 22:24:16 GMT&#34;,
&#34;Server&#34;: &#34;Microsoft-IIS/10.0&#34;,
&#34;X-Powered-By&#34;: &#34;ASP.NET&#34;,
&#34;Content-Length&#34;: &#34;5628&#34;,
&#34;Content-Type&#34;: &#34;application/json&#34;,
&#34;Expires&#34;: &#34;-1&#34;
},
&#34;body&#34;: {
&#34;Code&#34;: &#34;InvalidXsltContent&#34;,
&#34;Message&#34;: &#34;An error occurred while processing map. 'Token Text in state Start would result in an invalid XML document. Make sure that the ConformanceLevel setting is set to ConformanceLevel.Fragment or ConformanceLevel.Auto if you want to write an XML fragment. '&#34;,
&#34;Details&#34;: [
{
&#34;Code&#34;: &#34;InvalidXsltContent&#34;,
&#34;Message&#34;: &#34;{\&#34;StatusCode\&#34;:400,\&#34;ErrorCode\&#34;:7,\&#34;Details\&#34;:null,\&#34;Message\&#34;:\&#34;An error occurred while processing map. 'Token Text in state Start would result in an invalid XML document. Make sure that the ConformanceLevel setting is set to ConformanceLevel.Fragment or ConformanceLevel.Auto if you want to write an XML fragment. '\&#34;,\&#34;Data\&#34;:{},\&#34;InnerException\&#34;:{\&#34;ClassName\&#34;:\&#34;System.InvalidOperationException\&#34;,\&#34;Message\&#34;:\&#34;Token Text in state Start would result in an invalid XML document. Make sure that the ConformanceLevel setting is set to ConformanceLevel.Fragment or ConformanceLevel.Auto if you want to write an XML fragment. \&#34;,\&#34;Data\&#34;:null,\&#34;InnerException\&#34;:null,\&#34;HelpURL\&#34;:null,\&#34;StackTraceString\&#34;:\&#34; at System.Xml.XmlWellFormedWriter.ThrowInvalidStateTransition(Token token, State currentState)\\r\\n at System.Xml.XmlWellFormedWriter.AdvanceState(Token token)\\r\\n at System.Xml.XmlWellFormedWriter.WriteString(String text)\\r\\n at System.Xml.Xsl.Runtime.XmlRawWriterWrapper.WriteString(String text)\\r\\n at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteString(String text, Boolean disableOutputEscaping)\\r\\n at plantcatalog_tocsv.<xsl:template match=\\\&#34;/\\\&#34;>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)\\r\\n at plantcatalog_tocsv.Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)\\r\\n at plantcatalog_tocsv.Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)\\r\\n at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)\\r\\n at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)\\r\\n at System.Xml.Xsl.XslCompiledTransform.Transform(XmlReader input, XsltArgumentList arguments, XmlWriter results)\\r\\n at Microsoft.Azure.Function.Transform.XsltTransformer.TransformToXmlInternal(ProcessedXslt`1 processedXslt, XmlReader inputXmlReader, XsltArgumentList xsltArguments, Nullable`1 transformOptions) in X:\\\\bt\\\\1075184\\\\repo\\\\src\\\\functions\\\\Scripts\\\\Function.Transform\\\\XsltTransformer.cs:line 235\\r\\n at Microsoft.Azure.Function.Transform.XsltTransformer.TransformInternal(ProcessedXslt`1 processedXslt, XmlReader inputXmlReader, XsltArgumentList xsltArguments, Nullable`1 transformOptions) in X:\\\\bt\\\\1075184\\\\repo\\\\src\\\\functions\\\\Scripts\\\\Function.Transform\\\\XsltTransformer.cs:line 174\&#34;,\&#34;RemoteStackTraceString\&#34;:null,\&#34;RemoteStackIndex\&#34;:0,\&#34;ExceptionMethod\&#34;:\&#34;8\\nThrowInvalidStateTransition\\nSystem.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\nSystem.Xml.XmlWellFormedWriter\\nVoid ThrowInvalidStateTransition(Token, State)\&#34;,\&#34;HResult\&#34;:-2146233079,\&#34;Source\&#34;:\&#34;System.Xml\&#34;,\&#34;WatsonBuckets\&#34;:null},\&#34;TargetSite\&#34;:{\&#34;Name\&#34;:\&#34;TransformInternal\&#34;,\&#34;AssemblyName\&#34;:\&#34;Microsoft.Azure.Function.Transform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\&#34;,\&#34;ClassName\&#34;:\&#34;Microsoft.Azure.Function.Transform.XsltTransformer\&#34;,\&#34;Signature\&#34;:\&#34;Microsoft.Azure.Function.Transform.XsltTransformOutput TransformInternal(Microsoft.Azure.Function.Common.Xml.ProcessedXslt`1[System.Xml.Xsl.XslCompiledTransform], System.Xml.XmlReader, System.Xml.Xsl.XsltArgumentList, System.Nullable`1[Microsoft.Azure.Function.Common.Xml.XsltTransformOptions])\&#34;,\&#34;Signature2\&#34;:\&#34;Microsoft.Azure.Function.Transform.XsltTransformOutput TransformInternal(Microsoft.Azure.Function.Common.Xml.ProcessedXslt`1[[System.Xml.Xsl.XslCompiledTransform, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Xml.XmlReader, System.Xml.Xsl.XsltArgumentList, System.Nullable`1[[Microsoft.Azure.Function.Common.Xml.XsltTransformOptions, Microsoft.Azure.Function.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]])\&#34;,\&#34;MemberType\&#34;:8,\&#34;GenericArguments\&#34;:null},\&#34;StackTrace\&#34;:\&#34; at Microsoft.Azure.Function.Transform.XsltTransformer.TransformInternal(ProcessedXslt`1 processedXslt, XmlReader inputXmlReader, XsltArgumentList xsltArguments, Nullable`1 transformOptions) in X:\\\\bt\\\\1075184\\\\repo\\\\src\\\\functions\\\\Scripts\\\\Function.Transform\\\\XsltTransformer.cs:line 214\\r\\n at Microsoft.Azure.Function.Transform.XsltTransformer.<Transform>d_9.MoveNext() in X:\\\\bt\\\\1075184\\\\repo\\\\src\\\\functions\\\\Scripts\\\\Function.Transform\\\\XsltTransformer.cs:line 92\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\\r\\n at Microsoft.Azure.Function.Transform.TransformRequestProcessor.<ProcessTransformRequest>d_2.MoveNext() in X:\\\\bt\\\\1075184\\\\repo\\\\src\\\\functions\\\\Scripts\\\\Function.Transform\\\\TransformRequestProcessor.cs:line 49\&#34;,\&#34;HelpLink\&#34;:null,\&#34;Source\&#34;:\&#34;Microsoft.Azure.Function.Transform\&#34;,\&#34;HResult\&#34;:-2146233088}&#34;,
&#34;Details&#34;: null,
&#34;InnerError&#34;: null
}
],
&#34;InnerError&#34;: null
}
}









azure-logic-apps
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

bhargaviannadevara-msft avatar image
0 Votes"
bhargaviannadevara-msft answered ·

Hello @MarekDbrowski-5426,

Thanks for the question. Azure Logic Apps has not yet migrated to the Q&A platform, but is active on MSDN:

https://social.msdn.microsoft.com/Forums/en-US/home?forum=azurelogicapps

Please post your question there so you can get assistance from the community.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.