2012-02-28 3389 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>