问题描述
尝试从多个xml文件中删除名称空间。从文件夹导入xml文件,然后尝试将转换后的xml文件导出到输出文件夹。 我在sis中将其用于每个循环容器和xml任务,但不确定为什么会给我错误。任何逐步的过程都将有所帮助。谢谢 这是我最终得到的逐步过程。 1.三个xml文件-
在这里我的文件在输出文件夹中没有命名空间 为了从所有三个文件中删除命名空间,我使用了每个循环容器并通过定义变量进行配置: 然后是变量映射 [![在此处输入图片描述] [8]] [8]
Example 1 xml
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],"\\"))