[英]How to remove namespace from multiple XML files using ssis?
試圖從多個 xml 文件中刪除命名空間。 從文件夾導入 xml 文件並嘗試將轉換后的 xml 文件導出到輸出文件夾。 我在 ssis 中用於每個循環容器和 xml 任務,但不確定為什么它會給我錯誤。 任何循序漸進的過程都會有所幫助。 謝謝這是我對最終結果所做的分步過程.. 1.三個 xml 文件-
使用 xml 任務可以輕松刪除一個文件中的命名空間,如下所示
這里我在輸出文件夾中有沒有命名空間的文件 要從我用於每個循環容器的所有三個文件中刪除命名空間,並通過定義變量進行配置:
然后變量映射
[![在此處輸入圖像描述][8]][8]
Example 1 xml
<AMOUNT_MONEY xmlns="http://www.somewhere.com/ABC" version="5.252"> <CURRENT_ADDRESS occupancy_status="RENT" occupancy_description=""> <FORMER_ADDRESS street_address_1="1234 CIRCLE LN" County="" /> </CURRENT_ADDRESS> </AMOUNT_MONEY>
Example 2 xml
<AMOUNT_MONEY xmlns="http://www.somewhere.com/ABC" version="5.252">
<NAMES>
<BORROWER home_country="USA" work_phone="" d3p1:internal_borrower_id="fec5645fc4cgd982" xmlns:d3p1="http://www.somewhere.com/Intern">
<CURRENT_ADDRESS occupancy_status="OWN" occupancy_description="">
<FORMER_ADDRESS street_address_1="111 MAIN LN" county="" />
</CURRENT_ADDRESS>
</BORROWER>
</NAMES>
</AMOUNT_MONEY>
Example 3 xml
<AMOUNT_MONEY xmlns="http://www.somewhere.com/ABC" version="5.252">
<NAMES>
<BORROWER home_country="CA" work_phone="" d3p1:internal_borrower_id="8fec53vfg982845bf" xmlns:d3p1="http://www.somewhere.com/Intern">
<CURRENT_ADDRESS occupancy_status="RENTTOOWN" occupancy_description="">
<FORMER_ADDRESS street_address_1="985 CHERRY ST" county="" />
</CURRENT_ADDRESS>
</BORROWER>
</NAMES>
</AMOUNT_MONEY>
評論:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no" />
<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()" />
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
我在我的機器上運行 XSLT 沒有任何問題。 它根據需要刪除命名空間。
XSLT
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
讓我們專注於 SSIS 方面。
User::FILEPATH
變量將包含 Foreach 循環容器中源 XML 文件的完全限定路徑。 所以你不能直接將它與目標目錄連接起來。
您需要做的是修復目標文件連接表達式,如下所示:
"c:\\destinationDirectory\\" + TOKEN(@[User::FILEPATH], "\\", TOKENCOUNT(@[User::FILEPATH], "\\"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.