【问题标题】:Cannot find a matching 1-argument function named找不到匹配的 1 参数函数,名为
【发布时间】:2015-05-27 20:50:57
【问题描述】:

我有以下 XSLT 并使用 Stylus。无论我做什么,我都会收到第 50 行的以下错误消息。 找不到名为 {http://schemas.microsoft.com/BizTalk/2003/userCSharp}ReplaceYYYMMDDtoXsdDate()

的匹配 1 参数函数
  • encoding="UTF-8" 没有帮助。
  • 添加 msxsl:assembly 和 msxsl:using 没有帮助 感谢提示和帮助。 问候,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>
  • 附上代码

【问题讨论】:

    标签: xslt xslt-2.0


    【解决方案1】:

    msxsl:script 是 Microsoft 在某些 XSLT 1.0 处理器中实现的专有 Microsoft 功能,例如各种 MSXML 版本(但不支持调用 .NET 语言,如 C#,您只能调用 VBScript 或 JScript 扩展功能)或类似XslCompiledTransform。我不知道您可以在 Stylus Studio 中使用哪些 XSLT 处理器,但我认为默认情况下它使用 Saxon,并且不支持调用 C# 的 Microsoft 特定扩展。因此,您需要检查 Stylus Studio 是否允许您切换到 Microsoft 的 XslCompiledTransform 作为 XSLT 处理器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-02
      • 2010-10-01
      • 2019-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多