我没有使用撒克逊语;我正在使用直接的 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 参数函数
我所做的每次搜索都会返回撒克逊代码的错误。我没有使用撒克逊代码,我读到的所有内容都说格式与标准 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>