简体   繁体   中英

Logic App - Transform XML using XSLT - Date Format

I am using a Logic App connector "Transform XML" with an Integration account having a XSLT map version 3.0 file.

It is working to transform my required XML but when I am including C# code to convert a date tag throwing below exception:

Has anyone got similar issue yet, please let me know.

my XSLT file content


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:userCSharp="urn:my-scripts"
    exclude-result-prefixes="msxsl"![97882-error.png][1]
    >
  <msxsl:script language="C#" implements-prefix="userCSharp">
    <![CDATA[
    public string FormatDateFunction(string inputDate)
    {
    string formatdate;
    if(string.IsNullOrEmpty(inputDate))
    return "";
    formatdate = System.DateTime.Parse(inputDate).ToString("M/dd/yyyy");
    return formatdate;
    }
  ]]>
  </msxsl:script>

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

  <xsl:variable name="paramDate">
    <xsl:value-of select="/*/XPathBody/Data" />
  </xsl:variable> 

  <xsl:template match="/">
    <MyHeader_1.0>
      <MyTag>        
        <DueDate>
          <xsl:value-of select="userCSharp:FormatDateFunction($paramDate)"/>          
        </DueDate>        
        <MyDate>          
          <xsl:choose>
            <xsl:when test="$paramDate != ''">
                <xsl:value-of select="userCSharp:FormatDateFunction($paramDate)"/>
            </xsl:when>
            <xsl:otherwise>          
            </xsl:otherwise>
        </xsl:choose>         
        </MyDate>
      </MyTag>
    </MyHeader_1.0>
  </xsl:template>
</xsl:stylesheet>

Error in logic app

*

{
  "Code": "InvalidXsltContent",
  "Message": "An error occurred while transforming the given input with the provided map. Details: 'net.sf.saxon.trans.XPathException: Errors were reported during stylesheet compilation'.",
  "Details": [
    {
      "Code": "InvalidXsltContent",
      "Message": "{\"StatusCode\":400,\"ErrorCode\":7,\"Details\":null,\"Message\":\"An error occurred while transforming the given input with the provided map. Details: 'net.sf.saxon.trans.XPathException: Errors were reported during stylesheet compilation'.\",\"Data\":{},\"InnerException\":null,\"TargetSite\":{\"Name\":\"MoveNext\",\"AssemblyName\":\"Microsoft.Azure.Function.Common.Cloud, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\",\"ClassName\":\"Microsoft.Azure.Function.Xslt30Transform.BaseXslt30Transformer+<Transform>d__3\",\"Signature\":\"Void MoveNext()\",\"Signature2\":\"System.Void MoveNext()\",\"MemberType\":8,\"GenericArguments\":null},\"StackTrace\":\"   at Microsoft.Azure.Function.Xslt30Transform.BaseXslt30Transformer.<Transform>d__3.MoveNext() in X:\\\\bt\\\\1186352\\\\repo\\\\src\\\\functions\\\\Scripts\\\\Function.Common.Cloud\\\\Xml\\\\BaseXslt30Transformer.cs:line 75\\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.Xslt30Transform.Xslt30TransformRequestProcessor.<ProcessTransformRequest>d__2.MoveNext() in X:\\\\bt\\\\1186352\\\\repo\\\\src\\\\functions\\\\Scripts\\\\Function.Xslt30Transform\\\\Xslt30TransformRequestProcessor.cs:line 50\",\"HelpLink\":null,\"Source\":\"Microsoft.Azure.Function.Common.Cloud\",\"HResult\":-2146233088}",
      "Details": null,
      "InnerError": null
    }
  ],
  "InnerError": null
}

Attached error image enter image description here

Any help would be much appreciable.

Thanks in advance.

As per my understanding Logic App connector "Transform XML" does not support XSLT version 3.0. It is also mentioned in the docs.

Please visit https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-enterprise-integration-maps?tabs=consumption

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM