格式编号从###。0到###。00

时间:2013-07-05 11:42:31

标签: xslt biztalk

我在BizTalk中使用一个项目,其中使用xslt将脚本文件转换为UBL文件。 edifact文件包含###。0的价格值,但不起作用。我想使用format-number将其更改为###。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">

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

1 个答案:

答案 0 :(得分:0)

这可能是由于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>