xslt中的C#-找不到名为{urn:my-scripts} ConvertUTCtoLocal()

时间:2019-01-02 21:38:06

标签: c# xslt xslt-1.0 msxsl

我不使用撒克逊语;我使用的是XSLT 1.0。
我正在使用以下XSLT文档:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:a="http://schemas.datacontract.org/2004/07/Delek.Store"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:user="urn:my-scripts">

  <msxsl:script implements-prefix='user' language='CSharp'>
    <![CDATA[  
    
      public string ConvertUTCtoLocal(DateTime EndTime)
      {
        var Local = EndTime.ToLocalTime().ToString("MM/dd/yyyy") + " " + EndTime.ToLocalTime().ToString("HH:mm:ss");
        return Local;
      }
    
    ]]>
  </msxsl:script>

  <!-- .. since we have a source default namespace we have to declare a namespace here   exclude-result-prefixes="msxsl" -->
  <xsl:output method="xml" indent="yes"/>
  <xsl:param name="header" />
  <xsl:param name="footer"/>
  <xsl:param name="ReceiptLayoutCodeType"/>
  <xsl:variable name="spaces27" select="'                           '"/>
  <xsl:template match="/">
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Body>
        <epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
          <xsl:apply-templates select ="Sale"/>
          <feed unit="24"/>
          <cut/>
        </epos-print>
      </s:Body>
    </s:Envelope>
  </xsl:template>
  <xsl:template match="Sale">
    <text lang="en" smooth="true" align="left" >
      Date<xsl:value-of select="concat(substring($spaces27,9),user:ConvertUTCtoLocal(EndTime))"/>
    </text>

  </xsl:template>

</xsl:stylesheet>

当它尝试调用C#脚本时,出现错误

  

找不到名为{urn:my-scripts} ConvertUTCtoLocal()的匹配的1参数函数

我所做的每一次搜索都将返回撒克逊代码的错误。我没有使用Saxon代码,并且阅读的所有内容均表示格式与标准W3C XSLT中使用的格式不同。

有人对如何使此代码起作用有任何建议吗?

真正奇怪的是,我正在使用https://www.freeformatter.com/xsl-transformer.html进行检查,对于我在网络上使用的任何示例代码来说,这都是一样的。

那是我的代码吗?对XML 1.0的更新有什么问题吗?

我目前迷路了,可以借助一些帮助摆脱杂草。

人们可以用来测试的XML数据:

<Sale z:Id="i1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
  <AllItems>
   <!--Data Removed-->
  </AllItems>
  <CreditTendered>-8.17</CreditTendered>
  <EndTime>2018-10-22T15:25:35.0562305Z</EndTime>
  <GrossFuelSaleAmount>0</GrossFuelSaleAmount>
  <GrossNonFuelSaleAmount>7.48</GrossNonFuelSaleAmount>
  <IdPerson>1000</IdPerson>
  <IdRowStateCode>0</IdRowStateCode>
  <IdSale>8</IdSale>
  <IdSite>1</IdSite>
  <IdWorkflowStateCode>Completed</IdWorkflowStateCode>
  <IsTaxExempt>false</IsTaxExempt>
  <Loyalties />
  <NetNonFuelSaleAmount>7.48</NetNonFuelSaleAmount>
  <PaymentMethods>
    <!--Data Removed-->
  </PaymentMethods>
  <Receipts>
    <SaleReceipt z:Id="i15">
      <IdReceiptTypeCode>Store</IdReceiptTypeCode>
      <IdRowStateCode>0</IdRowStateCode>
      <IdSale>8</IdSale>
      <IdSaleReceipt>1</IdSaleReceipt>
      <ReceiptSegments>
        <SaleReceiptSegment z:Id="i16">
          <!--Data Removed-->
        </SaleReceiptSegment>
      </ReceiptSegments>
      <ReceiptTypeCode i:nil="true" />
      <RowCreated>2018-10-22T15:25:34.6771725</RowCreated>
      <RowGuid>1810a6b5-0ed6-e811-9766-90e2ba14d18e</RowGuid>
      <RowModifiedBy>1000</RowModifiedBy>
      <RowModifiedDate>2018-10-22T15:25:34.6771725</RowModifiedDate>
      <RowVersion>AAAAAAAAIII=</RowVersion>
    </SaleReceipt>
    <SaleReceipt z:Id="i17">
      <IdReceiptTypeCode>Customer</IdReceiptTypeCode>
      <IdRowStateCode>0</IdRowStateCode>
      <IdSale>8</IdSale>
      <IdSaleReceipt>2</IdSaleReceipt>
      <ReceiptSegments>
        <SaleReceiptSegment z:Id="i18">
          <!--Data Removed-->
        </SaleReceiptSegment>
      </ReceiptSegments>
      <ReceiptTypeCode i:nil="true" />
      <RowCreated>2018-10-22T15:25:34.6800439</RowCreated>
      <RowGuid>1a10a6b5-0ed6-e811-9766-90e2ba14d18e</RowGuid>
      <RowModifiedBy>1000</RowModifiedBy>
      <RowModifiedDate>2018-10-22T15:25:34.6800439</RowModifiedDate>
      <RowVersion>AAAAAAAAIIQ=</RowVersion>
    </SaleReceipt>
  </Receipts>
  <ReferencedBySales />
  <ReferencedSales />
  <RowCreated>2018-10-22T15:15:13.0180317</RowCreated>
  <RowGuid>bd931f45-0dd6-e811-9766-90e2ba14d18e</RowGuid>
  <RowModifiedBy>1000</RowModifiedBy>
  <RowModifiedDate>2018-10-22T15:25:35.0832346</RowModifiedDate>
  <RowStateCode i:nil="true" />
  <RowVersion>AAAAAAAAIJQ=</RowVersion>
  <SaleManagerSales />
  <Session z:Id="i19" xmlns:a="http://schemas.datacontract.org/2004/07/Delek.Store">
    <!--Data Removed-->
  </Session>
  <Signatures />
  <StartTime>2018-10-22T15:15:13.0180317</StartTime>
  <TotalTendered>-8.17</TotalTendered>
  <WorkflowStateCode i:nil="true" />
</Sale>

这是打印机返回的错误:

- <Result>


<Battery>0</Battery> 
  <Code>Error exists in the requested document syntax</Code> 
  <Status /> 
  <Success>Print Failed</Success> 
- <Res>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Body>
  <response success="false" code="SchemaError" status="0" battery="0" xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print" /> 
  </soapenv:Body>
  </soapenv:Envelope>
  </Res>
  </Result>

0 个答案:

没有答案