2012-02-28 157 views
1

我想知道是否有人能夠幫助我實現以下目標。我有一個XML文件,每個星期的文本值都包含一個值。我想每週都把數據庫作爲一個獨立的行。SSIS拆分XML文本

我知道如何使用SSIS將XML文件放到數據庫中,但我需要一些幫助以便如何開始分割文本值。

非常感謝!

<DATA> 
<TIME-SERIES last-update-time="507340800" name="yearly" sample-interval="604800" observations="52" parent="http:client-volume">143 161 175 112 176 191 188 163 268 303 261 270 264 182 318 307 339 310 328 338 407 485 3330 274 168 191 179 258 183 256 258 238 2625 235 305 274 255 273 367 188 318 230 315 278 192 222 1268 129 150 350 3278 4757 </TIME-SERIES> 
</DATA> 

首選輸出

date  | name | interval | observation | parent    | value 
507340800 | yearly | 604800 | 52   | http:client-volume | 143 
507340800 | yearly | 604800 | 52   | http:client-volume | 161 
507340800 | yearly | 604800 | 52   | http:client-volume | 175 
+0

又該上述模樣的輸出? – billinkc 2012-02-28 19:22:52

+0

@billinkc查看原文,剛編輯 – Bas 2012-02-29 10:18:18

回答

0

關於編寫一個小的XSL片斷如何? 這裏有一個我想出了,奔跑着:xsltproc MY_XSL_FILE YOUR_XML_FILE

<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:s="http://exslt.org/strings" 
    version="1.0"> 

    <xsl:output method="text"/> 

    <xsl:template match="text()"/> 

    <xsl:template match="TIME-SERIES"> 
    <xsl:variable name="last-update-time" select="@last-update-time"/> 
    <xsl:variable name="name" select="@name"/> 
    <xsl:variable name="sample-interval" select="@sample-interval"/> 
    <xsl:variable name="observations" select="@observations"/> 
    <xsl:variable name="parent" select="@parent"/> 

    <!-- heading --> 
    <xsl:text>date  | name | interval | observation | parent    | value&#0010;</xsl:text> 

    <xsl:for-each select="s:tokenize(text(), ' ')"> 
     <xsl:value-of select="$last-update-time"/> 
     <xsl:text> | </xsl:text> 
     <xsl:value-of select="$name"/> 
     <xsl:text> | </xsl:text> 
     <xsl:value-of select="$sample-interval"/> 
     <xsl:text> | </xsl:text> 
     <xsl:value-of select="$observations"/> 
     <xsl:text>   | </xsl:text> 
     <xsl:value-of select="$parent"/> 
     <xsl:text> | </xsl:text> 
     <xsl:value-of select="."/> 
     <xsl:text>&#0010;</xsl:text> 
    </xsl:for-each> 
    </xsl:template> 

</xsl:stylesheet>