这是我的 XSL 转换文件:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:Message="http://schemas.microsoft.com/dynamics/2011/01/documents/Message"
xmlns:BankPositivePay="http://schemas.microsoft.com/dynamics/2008/01/documents/BankPositivePay">
<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no"/>
<xsl:template match="/">
<Header>
<records>
<record>
<xsl:value-of select="/BankPositivePay/BankAccountTable/AccountNum"/>
</record>
</records>
</Header>
</xsl:template>
</xsl:stylesheet>
输入的xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<Header>
<MessageId>{A604C46E-F3E3-4BCB-9F7A-E8FD8749A7FC}</MessageId>
<Action>http://tempuri.org/BankPositivePayService/find</Action>
</Header>
<Body>
<MessageParts xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<BankPositivePay xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/BankPositivePay">
<BankAccountTable class="entity">
<AccountID>USA OPER</AccountID>
<AccountNum>34567</AccountNum>
<CurrencyCode>USD</CurrencyCode>
<LedgerDimension>
<MainAccount xmlns="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes">110110</MainAccount>
</LedgerDimension>
<BankChequeTable class="entity">
<AccountID>USA OPER</AccountID>
<AmountCur>3500.00</AmountCur>
<ChequeNum>1132</ChequeNum>
<ChequeStatus>Payment</ChequeStatus>
<RecipientAccountNum>1001</RecipientAccountNum>
<TransDate>2013-08-16</TransDate>
<VendTable class="entity">
<Currency>USD</Currency>
<DefaultDimension>
<Values xmlns="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes">
<Value>
<Name>CustomDepartment</Name>
<Value>060</Value>
</Value>
</Values>
</DefaultDimension>
<VendGroup>10</VendGroup>
</VendTable>
<CompanyInfo xsi:type="AxdEntity_CompanyInfo_CompanyInfo" class="entity" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DataArea>ceu</DataArea>
</CompanyInfo>
</BankChequeTable>
</BankAccountTable>
</BankPositivePay>
</MessageParts>
</Body>
</Envelope>
问题是我得到的输出为:
<?xml version="1.0" encoding="utf-8"?>
<Header xmlns:Message="http://schemas.microsoft.com/dynamics/2011/01/documents/Message" xmlns:BankPositivePay="http://schemas.microsoft.com/dynamics/2008/01/documents/BankPositivePay">
<records>
<record></record>
</records>
</Header>
记录元素是空的,尽管它应该返回 AccountNum 34567。感谢任何帮助。谢谢你。