[英]XSL transform MS Access 2007 output
我正在定期從Access導出數據。 到目前為止,我以前一直導出它並手動編輯一些標簽以將其調整為滿足客戶需求。 最近,我發現可以將XSL用作轉換模式。
我仍然是XSL的初學者,但是設法創建了以下內容:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="dataroot/Kwerenda_x0020_Nota_x0020_Kredytowa">
<xsl:element name="Faktury_od_nas">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
通常它可以,但是:
1.通常,當我導出數據時,它在換行時為我提供了每個標簽,現在僅按我更改過的標簽進行划分。
2.我不知道如何重命名數據根。 我試圖復制/粘貼相同的代碼,但是每當Faktury_od_nas出現時,我都會得到dataroot ...
轉換后的樣本數據:
<dataroot generated="2016-01-12T13:54:11" xmlns:od="urn:schemas-microsoft-com:officedata"><Faktury_od_nas><No>1</No><InvoiceDate>20150715</InvoiceDate><InvoiceNumber>12345</InvoiceNumber><CustVATNumber>LT100004645417</CustVATNumber><E100customerKey>65-92</E100customerKey><CustomerName>Client_name</CustomerName><InvoiceCountry>BE</InvoiceCountry><VATpersent>21</VATpersent><VATBasis>106,36</VATBasis><VATamount>22,34</VATamount><Currency>EUR</Currency><VAT_x0020_recovery_x0020_fee_x0020_rate_x0020__x0028__x0025__x0029_>7.5</VAT_x0020_recovery_x0020_fee_x0020_rate_x0020__x0028__x0025__x0029_><Service_x0020_Type>Express</Service_x0020_Type><InvoiceScanFileName>scan_name</InvoiceScanFileName>
</Faktury_od_nas></dararoot>
所需的樣本數據:
<Faktura>
<Faktury_od_nas>
<No>1</No>
<InvoiceDate>20150715</InvoiceDate>
<InvoiceNumber>12345</InvoiceNumber>
<CustVATNumber>LT100004645417</CustVATNumber>
<E100customerKey>65-92</E100customerKey>
<CustomerName>Client_name</CustomerName>
<InvoiceCountry>BE</InvoiceCountry>
<VATpersent>21</VATpersent>
<VATBasis>106,36</VATBasis>
<VATamount>22,34</VATamount>
<Currency>EUR</Currency>
<VAT_x0020_recovery_x0020_fee_x0020_rate_x0020__x0028__x0025__x0029_>7.5</VAT_x0020_recovery_x0020_fee_x0020_rate_x0020__x0028__x0025__x0029_>
<Service_x0020_Type>Express</Service_x0020_Type>
<InvoiceScanFileName>scan_name</InvoiceScanFileName>
</Faktury_od_nas>
</Faktura>
感謝您的幫助。
編輯:
<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:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="dataroot">
<Faktura>
<xsl:apply-templates />
</Faktura>
</xsl:template>
<xsl:template match="Kwerenda_x0020_Nota_x0020_Kredytowa">
<Faktury_od_nas>
<xsl:apply-templates />
</Faktury_od_nas>
</xsl:template>
</xsl:stylesheet>
這將有助於查看您的源XML,但我相信您可以使用:
XSLT 1.0
<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:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="dataroot">
<Faktura>
<xsl:apply-templates />
</Faktura>
</xsl:template>
<xsl:template match="Kwerenda_x0020_Nota_x0020_Kredytowa">
<Faktury_od_nas>
<xsl:apply-templates />
</Faktury_od_nas>
</xsl:template>
</xsl:stylesheet>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.