0
votes

I have the following XSLT and using Stylus. No matter what I do I get the following error message for Line number 50. Cannot find a matching 1-argument function named {http://schemas.microsoft.com/BizTalk/2003/userCSharp}ReplaceYYYMMDDtoXsdDate()

  • encoding="UTF-8" at the does not help.
  • Adding msxsl:assembly and msxsl:using do not help Appreciate hints and help. Regards, Toraj

<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0 userCSharp ScriptNS0" version="1.0" xmlns:ns0="http://schemas.microsoft.com/dynamics/2008/01/documents/AdecPOItemArrival"
xmlns:st="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes" xmlns:s0="http://schemas.microsoft.com/BizTalk/EDI/X12/2006" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp" xmlns:ScriptNS0="http://schemas.microsoft.com/BizTalk/2003/ScriptNS0">
  <xsl:output indent="yes" omit-xml-declaration="yes" method="xml" version="1.0" />
  <xsl:strip-space elements="*" />

  <xsl:template match="/">
    <xsl:apply-templates select="s0:X12_00401_856" />
  </xsl:template>

  <!-- Use the following inside BizTalk Scripting Fuctoid - Start -->
  <xsl:template name="CopyOrderTemplate" match="s0:X12_00401_856" xmlns:s0="http://schemas.microsoft.com/BizTalk/EDI/X12/2006">
    <xsl:copy>
      <xsl:apply-templates select="s0:HLLoop1[.//HL03/text()='O']" />
    </xsl:copy>
  </xsl:template>

  <xsl:template name="WMSJournalTableTemplate" match="s0:HLLoop1[.//HL03/text()='O']">
    <ns0:WMSJournalTable class="entity" Number="{.//PRF01}">
      <xsl:apply-templates select="following-sibling::s0:HLLoop1[.//HL03/text()='I'][generate-id(preceding-sibling::s0:HLLoop1[.//HL03/text()='O'][1])=generate-id(current())]" />
    </ns0:WMSJournalTable>
  </xsl:template>

  <xsl:template name="WMSJournalTransTemplate" match="s0:HLLoop1[.//HL03/text()='I']">
    <ns0:WMSJournalTrans class="entity" Number="{.//LIN01}">
      <xsl:variable name="Qty" select="s0:SN1/SN102/text()" />
      <ns0:Qty>
        <xsl:value-of select="$Qty" />
      </ns0:Qty>

      <xsl:variable name="TestData" select="../s0:DTM/DTM02/text()" />
      <ns0:TestDataTst>
        <xsl:value-of select="$TestData" />
      </ns0:TestDataTst>

      <!-- From BizTalk Validate XSLT
        <xsl:variable name="var:v29" select="userCSharp:ReplaceYYYMMDDtoXsdDate(string(../../../s0:DTM/DTM02/text()))" /> -->
      <!-- <xsl:variable name="var:v29" select="userCSharp:ReplaceYYYMMDDtoXsdDate(string(../s0:DTM/DTM02/text()))"/> -->
      <xsl:variable name="var:v29" select="userCSharp:ReplaceYYYMMDDtoXsdDate($TestData)" />
      <ns0:TransDate>
        <xsl:value-of select="$var:v29" />
      </ns0:TransDate>

      <xsl:variable name="VendAccount" select="'13458'" />
      <ns0:VendAccount>
        <xsl:value-of select="$VendAccount" />
      </ns0:VendAccount>
    </ns0:WMSJournalTrans>
  </xsl:template>

  <msxsl:script language="C#" implements-prefix="userCSharp">
    <!-- <msxsl:script implements-prefix='userCSharp' language='C#'>
    <msxsl:assembly href="C:\Users\toraj.khavari\Documents\StylusProjects\856\Adec.Common.Modification.dll"/>
    <msxsl:using namespace="Adec.Common.Modification" /> 
    <msxsl:using namespace="System" />-->
    <![CDATA[ 
        /// <summary>
        /// Replaces the yyyymmddd date to XSD date.
        /// </summary>
        /// <param name="stringInput">The string input.</param>
        /// <returns></returns>
        public string ReplaceYYYMMDDtoXsdDate(string stringInput)
        {
            System.String resultStr = "NotFound";
            string year = null;
            string month = null;
            string day = null;

            try
            {
                if (!System.String.IsNullOrEmpty(stringInput) && (stringInput.Length > 7))
                {
                    // IsDigitsOnly
                    foreach (char c in stringInput)
                    {
                        if (c < '0' || c > '9')
                            return resultStr = "Invalid Input string values";
                    }
                    year = stringInput.Substring(0, 4);
                    month = stringInput.Substring(4, 2);
                    day = stringInput.Substring(6, 2);
                    resultStr = String.Format("{0}-{1}-{2}", year, month, day);
                }
                else
                {
                    resultStr = "Invalid Input string values";
                }
            }
            catch
            {
                resultStr = "ExceptionError in ReplaceYYYMMDDtoXsdDateTime";
            }

            return resultStr;
        }

  ]]>
  </msxsl:script>
  <!-- Use the bove inside BizTalk Scripting Fuctoid - END -->

</xsl:stylesheet>
  • Code attached
1

1 Answers

0
votes

Well msxsl:script is a proprietary Microsoft feature implemented in some XSLT 1.0 processor by Microsoft like the various MSXML version (which however don't support calling into .NET languages like C#, you can only call VBScript or JScript extension functions) or like XslCompiledTransform. I don't know which XSLT processors you can use with Stylus Studio but I think by default it uses Saxon and that does not support the Microsoft specific extension to call into C#. So you will need to check whether Stylus Studio allows you to switch to Microsoft's XslCompiledTransform as the XSLT processor.