我需要将欧洲格式的十进制节点转换为美国格式化。请帮我。 XML如下所示
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Order>
<Header>
<OrderNumber>PO000001</OrderNumber>
<OrderDate>20150108</OrderDate>
<BuyerCode>00132</BuyerCode>
<SupplierCode>V00048</SupplierCode>
<ShipTo>
<shipCode>00132</shipCode>
<address1>Askent Sok. No:3/A Kat:1 </address1>
<address2>Kosifler İş Merkezi</address2>
<shipCity>İÇERENKÖY/ATAŞEHİR/İSTANBUL</shipCity>
<shipPostCode>TR-34752</shipPostCode>
<shipCountry>
<shipCountryCode />
<shipCountryName />
</shipCountry>
</ShipTo>
<OrderText>
<TextHeader />
</OrderText>
<Lines>
<LineNumber>10000</LineNumber>
<ItemNumber>AICM00320-WU9E1</ItemNumber>
<Quantity>1,1</Quantity>
<Uom>PC</Uom>
<DeliveryDate>20150122</DeliveryDate>
<LineText>
<TextLines />
</LineText>
</Lines>
<Lines>
<LineNumber>20000</LineNumber>
<ItemNumber>AICM00400-WU9E1</ItemNumber>
<Quantity>5.000</Quantity>
<Uom>PC</Uom>
<DeliveryDate>20150122</DeliveryDate>
<LineText>
<TextLines />
</LineText>
</Lines>
<Lines>
<LineNumber>30000</LineNumber>
<ItemNumber>AICM00400-WU9E1</ItemNumber>
<Quantity>10</Quantity>
<Uom>PC</Uom>
<DeliveryDate>20150122</DeliveryDate>
<LineText>
<TextLines />
</LineText>
</Lines>
</Header>
</Order>
我只需要格式化数量节点,这在XML中重复。 我使用xslt将所有小数点从美国转换为欧洲格式。它看起来像下面
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:decimal-format name="eu" decimal-separator=',' grouping-separator='.' />
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[number()=number()]">
<xsl:copy>
<xsl:value-of select="format-number(., '#.##0,##########', 'eu')" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
我需要一个类似的XSLT来转换所有数量节点(仅数量节点)。请帮帮我们。感谢
答案 0 :(得分:0)
替换
<xsl:template match="*[number()=number()]">
<xsl:copy>
<xsl:value-of select="format-number(., '#.##0,##########', 'eu')" />
</xsl:copy>
</xsl:template>
与
<xsl:template match="Quantity">
<xsl:copy>
<xsl:value-of select="format-number(translate(., ',.', '.'), '#,##0.##########')" />
</xsl:copy>
</xsl:template>