Trying to remove namespace from multiple xml files. Importing xml files from a folder and trying to export transformed xml files into output folder. I utilized for each loop container and xml task in ssis but not sure why it gives me error. Any stepwise process will be helpful. Thanks Here are the step wise process i did with end result.. 1.Three xml files-
using xml task can easily remove the namespace in one file as follows
here I have file without namespace in output folder To remove namespace from all three files I use for each loop container and configure by defining variables:
then variable mapping
[![enter image description here][8]][8]
Then source connection manager and destination connection manager was configure and then run the package
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>
COMMENT:
<?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>
I ran the XSLT on my machine without any problem. It removes the namespaces as desired.
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>
Let's concentrate on the SSIS side.
The User::FILEPATH
variable will contain a fully qualified path to the source XML file in the Foreach Loop Container. So you cannot concatenate it directly with the destination directory.
What you need to do is to fix the destination file connection expression as follows:
"c:\\destinationDirectory\\" + TOKEN(@[User::FILEPATH], "\\", TOKENCOUNT(@[User::FILEPATH], "\\"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.