2

我有一个多重命名空间 XML 文件作为源。我必须将所有命名空间属性值存储在一个 DW 表中,

任何人都可以建议我如何使用该类型的文件作为源?

4

1 回答 1

4

我最近遇到了这个问题,所以我想我会发布一些关于如何解决这个问题的说明。在尝试加载多命名空间 XML 文档之前,首先需要使用 XSLT 转换对其进行转换。SSIS 可以通过 XML 任务执行此操作。

从工具栏中拉出一个 XML 任务并将其放置在您的控制流中

在此处输入图像描述

在文件系统中新建一个 XSLT 文件,并使用以下代码作为内容:

<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/2013/XSL/Transform"> <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>

打开 XML 任务并设置以下属性。

  • 操作类型 = XSLT
  • SourceType = 文件连接
  • Source = 为您为导入文件设置的源设置的文件连接。
  • SaveOperationResults =真
  • 目的地类型 = 文件
  • Destination = 为目标文件设置的文件连接
  • OverwriteDestination= 设置为首选
  • SecondOperandType=文件连接
  • SecondOperand= 为保存上述 XSLT 代码而设置的文件

在此处输入图像描述

一旦将这些项目添加到您的包中,您应该能够运行它,它将生成第二个文件,其中删除了命名空间。

于 2013-11-24T08:08:24.783 回答