【问题标题】:Format-number from ###.0 to ###.00格式编号从 ###.0 到 ###.00
【发布时间】:2013-07-05 11:42:31
【问题描述】:

我在 BizTalk 中使用 xslt 将 edifact 文件转换为 UBL 文件的项目。 edifact 文件包含 ###.0 的价格值,并且不起作用。我想使用格式号将其更改为###.00。但我不能让它工作。

这是我到目前为止所做的:

<cbc:Value>
    <xsl:variable name="SumOfNodes" select="edi:PRI/edi:C509/C50902"/>
    <xsl:value-of select="format-number($SumOfNodes, '0.00')"/>
</cbc:Value>

我正在使用这个样式表:

<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:edi="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006/MEDIAMARKT"
                xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Order-2"
                xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
                xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
                exclude-result-prefixes="msxsl edi">

关于如何解决这个问题的任何想法?

【问题讨论】:

  • 这给了你什么?
  • 错误:2(字段级错误) SegmentID:PRI TS 中的位置:87 数据元素 ID:C50902 段中的位置:2 字段中的位置:2 数据值:86.0 37:无效字符在数据元素中找到
  • 那么该段中有哪些数据?
  • 您的错误消息表明实际值为86.0 37。你检查过源文件吗?
  • 您能否提供一个示例输入文件,这将很有帮助。

标签: xslt biztalk


【解决方案1】:

这可能是由于 XSLT 中未声明的命名空间。请检查命名空间是否在您的 XSLT 中正确声明。除非您使用 XML 编码显示完整的 XSLT 编码,否则我们无法提供解决方案。但是请参考下面的示例 XML 和 XSLT 以及输出

XSLT:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="chapter">
<Value>
    <xsl:variable name="num" select="number"/>
    <xsl:value-of select="format-number($num,'00.00')"/>
</Value>
</xsl:template>
</xsl:stylesheet>

示例 XML

<?xml version="1.0"?>
<chapter>
<number>45</number>
</chapter>

输出

<?xml version='1.0' ?>
<Value>45.00</Value>

【讨论】:

    猜你喜欢
    • 2012-05-06
    • 2013-07-02
    • 1970-01-01
    • 2011-06-27
    • 2015-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多