我從式Icecat大的XML文件。我只想要一些信息。它在這個問題how transform xml document with xslt to duplicate output lines according to the child node過濾動態XML子元素使用XSLT與SSIS
我在數據庫已經語言的表的下面。我希望使用xslt過濾器子元素<Name>
,具體取決於我的表格內容。
我在SSIS項目。
我從式Icecat大的XML文件。我只想要一些信息。它在這個問題how transform xml document with xslt to duplicate output lines according to the child node過濾動態XML子元素使用XSLT與SSIS
我在數據庫已經語言的表的下面。我希望使用xslt過濾器子元素<Name>
,具體取決於我的表格內容。
我在SSIS項目。
1 /我創建一個變量命名的過濾器和一個Foreach ADO枚舉器將enuration變量IdLang
2 /使用這種表達一個表達式任務: @[User::Filter]=(LEN(@[User::Filter]) ==0 ? "@langid=" + (DT_WSTR, 2) @[User::IdLang] : @[User::Filter] + " or @langid=" + (DT_WSTR, 2)@[User::IdLang] )
3 /在老題目,我已經XSLT文件,什麼我把一個變量命名爲 「XSLT」:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/ICECAT-interface"> <xsl:apply-templates select="Response"/> </xsl:template> <xsl:template match="Response"> <xsl:apply-templates select="SuppliersList"/> </xsl:template> <xsl:template match="SuppliersList"> <xsl:copy> <xsl:apply-templates select="Supplier"/> </xsl:copy> </xsl:template> <xsl:template match="Supplier"> <Supplier> <xsl:copy-of select="@ID|@LogoLowPic|@Name"/> <xsl:attribute name="langid"> <xsl:value-of select="1"/> </xsl:attribute> </Supplier> <xsl:apply-templates select="Names/Name"/> </xsl:template> <xsl:template match="Name[###]"> <Supplier> <xsl:copy-of select="../../@ID|../../@LogoLowPic|@langid|@Name" /> </Supplier> </xsl:template> </xsl:stylesheet>
4 /最後我使用腳本任務
Dim filtr As String = Dts.Variables("User::Filter").Value
Dim Schem = Dts.Variables("User::Xslt").Value.ToString.Replace("###", filtr)
Dim xslt As New XslCompiledTransform()
xslt.Load(New XmlTextReader(New IO.StringReader(Schem)))
Dim settings As New Xml.XmlReaderSettings()
settings.DtdProcessing = Xml.DtdProcessing.Parse
Dim SourcePath As String = ???
Dim source As Xml.XmlReader = Xml.XmlReader.Create(SourcePath, settings)
Dim DestinationPath As String = ???
Dim Destination As Xml.XmlWriter = Xml.XmlWriter.Create(DestinationPath)
xslt.Transform(source, Destination)
我希望它可以幫助別人。