【发布时间】:2020-08-02 22:56:30
【问题描述】:
我有这样的 XML:
<?xml version="1.0" encoding="utf-16"?>
<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>GBP</AccountID>
<CurrencyCode>GBP</CurrencyCode>
<LedgerDimension>
<MainAccount xmlns="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes">7500000</MainAccount>
</LedgerDimension>
<BankChequeTable class="entity">
<AccountID>GBP</AccountID>
<AmountCur>444.00</AmountCur>
<ChequeNum>7</ChequeNum>
<RecipientAccountNum>UKV-000716</RecipientAccountNum>
<TransDate>2017-03-10</TransDate>
<VendTable class="entity">
<Currency>GBP</Currency>
<VendGroup>Stock</VendGroup>
</VendTable>
<CompanyInfo xsi:type="AxdEntity_CompanyInfo_CompanyInfo" class="entity" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DataArea>UK</DataArea>
</CompanyInfo>
</BankChequeTable>
<BankChequeTable class="entity">
<AccountID>GBP</AccountID>
<AmountCur>11700.00</AmountCur>
<ChequeNum>9</ChequeNum>
<RecipientAccountNum>UKV-000716</RecipientAccountNum>
<TransDate>2017-04-10</TransDate>
<VendTable class="entity">
<Currency>GBP</Currency>
<VendGroup>Stock</VendGroup>
</VendTable>
<CompanyInfo xsi:type="AxdEntity_CompanyInfo_CompanyInfo" class="entity" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DataArea>UK</DataArea>
</CompanyInfo>
</BankChequeTable>
<BankChequeTable class="entity">
<AccountID>GBP</AccountID>
<AmountCur>6394.00</AmountCur>
<BankNegInstRecipientName>this is a test address</BankNegInstRecipientName>
<ChequeNum>12</ChequeNum>
<RecipientAccountNum>UKV-000716</RecipientAccountNum>
<TransDate>2017-05-10</TransDate>
<VendTable class="entity">
<Currency>GBP</Currency>
<VendGroup>Stock</VendGroup>
</VendTable>
<CompanyInfo xsi:type="AxdEntity_CompanyInfo_CompanyInfo" class="entity" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DataArea>UK</DataArea>
</CompanyInfo>
</BankChequeTable>
</BankAccountTable>
</BankPositivePay>
</MessageParts>
我想生成CSV,如下:
7,UKV-000716,444.00,2017-03-10, 9、UKV-000716,11700.00,2017-04-10, 12,UKV-000716,6394.00,2017-05-10,这是测试地址
但实际输出如下:
7,UKV-000716,444.00,2017-03-10,这是一个测试地址, 7,UKV-000716,444.00,2017-03-10,这是一个测试地址, 7,UKV-000716,444.00,2017-03-10,这是一个测试地址,
我正在尝试循环 BankChequeTable 标记,它在 VS 中循环,但仅将所有行显示为第一行。
下面是我用过的XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="iso-8859-1"/>
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:for-each select="//*[local-name() = 'BankChequeTable']">
<xsl:value-of select="//*[local-name() = 'ChequeNum']"/>,<xsl:value-of select="//*[local-name() = 'RecipientAccountNum']"/>,<xsl:value-of select="//*[local-name() = 'AmountCur']"/>,<xsl:value-of select="//*[local-name() = 'TransDate']"/>,<xsl:value-of select="//*[local-name() = 'BankNegInstRecipientName']"/>,
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
我是 XSLT 的初学者,有人可以帮我解决这个问题吗?
提前致谢。
【问题讨论】: