此 xml 从需要转换 (XSLT) 的 Dynamics Ax 生成:需要创建 XSLT 以获取预期的出站 xml 文件
<?xml version="1.0" encoding="UTF-16"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<Header>
<MessageId>{3BCFB0D6-EAB4-430E-9921-E365F189046D}</MessageId>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/LedgerExchangeRateService/read</Action>
</Header>
<Body>
<MessageParts xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<LedgerExchangeRate xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerExchangeRate">
<SenderId>Womar</SenderId>
<CurrencyPair class="entity">
<FromCurrencyCode>US</FromCurrencyCode>
<ToCurrencyCode>DKK</ToCurrencyCode>
<ExchangeRateType>Default</ExchangeRateType>
<ExchangeRateDisplayFactor>Hundred</ExchangeRateDisplayFactor>
<ExchangeRate class="entity">
<ExchangeRate>500.000000000000</ExchangeRate>
<ValidFrom>2013-05-17</ValidFrom>
</ExchangeRate>
<RateType class="entity">
<Name>Default</Name>
</RateType>
</CurrencyPair>
</LedgerExchangeRate>
</MessageParts>
</Body>
</Envelope>
转换后文件如下:
<?xml version="1.0" encoding="utf-8"?>
<exchangeRateImport action="create" xmlns="http://schemas.v.com/2005/ImosOps" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<baseCurrency>US</baseCurrency>
<currency>EU</currency>
<rate>55.00000000</rate>
<effectiveDate>2013-05-17</effectiveDate>
</exchangeRateImport>
我创建了一个 XLRT,如下所示,结果不同。请帮忙。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:axEnv="http://schemas.microsoft.com/dynamics/2011/01/documents/Message"
xmlns:axExchRate="http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerExchangeRate">
<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no"/>
<xsl:template match="/">
<exchangeRateImport imosMsg:action="update" xmlns:imosMsg="http://schemas.veson.com/2005/ImosMsg" xmlns="http://schemas.veson.com/2005/ImosOps" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<baseCurrency>
<xsl:value-of select="axEnv:Envelope/axEnv:body/axEnv:MessageParts/axExchRate:LedgerExchangeRate/axExchRate:CurrencyPair/axExchRate:FromCurrencyCode"/>
</baseCurrency>
<currency/>
<rate/>
<effectiveDate/>
</exchangeRateImport>
</xsl:template>
</xsl:stylesheet>
结果:
<exchangeRateImport imosMsg:action="update" xmlns="http://schemas.veson.com/2005/ImosOps" xmlns:imosMsg="http://schemas.veson.com/2005/ImosMsg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:axEnv="http://schemas.microsoft.com/dynamics/2011/01/documents/Message" xmlns:axExchRate="http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerExchangeRate"><baseCurrency></baseCurrency><currency /><rate /><effectiveDate /></exchangeRateImport>