2012-03-29 27 views
0

私は次のXSLTを使用してXMLの結果を生成しています。これでCSV結果の設定に若干変更する必要があります。助言がありますか。シンプルなXSLTの変更XMLからCSVへ

ソースファイルに関する情報と
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:key name="mon" match="Column[substring(@name, 4, 1) = '_']"  use="concat(parent::*/@rowNum, substring(@name, 1, 3))"/> 
<xsl:output indent="yes"/> 
<xsl:template match="node()"> 
    <xsl:copy> 
     <xsl:copy-of select="@*"/> 
     <xsl:apply-templates select="node()"/> 
    </xsl:copy> 
</xsl:template> 

<xsl:template match="DataSet"> 
    <xsl:copy> 
     <xsl:copy-of select="@*"/> 
     <xsl:for-each select="*/Column[generate-id() = generate-id(key('mon', concat(parent::*/@rowNum, substring(@name, 1, 3)))[1])]"> 
      <xsl:element name="{name(parent::*)}"> 
       <xsl:attribute name="rowNum"> 
        <xsl:value-of select="position()"/> 
       </xsl:attribute> 
       <xsl:attribute name="mon"> 
        <xsl:value-of select="@name"/> 
       </xsl:attribute> 
       <xsl:copy-of select="parent::*/Column[not(substring(@name, 4, 1) = '_')]"/> 
       <xsl:copy-of select="key('mon', concat(parent::*/@rowNum, substring(@name, 1, 3)))"/> 
      </xsl:element> 
     </xsl:for-each> 
    </xsl:copy> 
</xsl:template> 

答えて

1

、これが唯一の野生の推測できますが、このような何か

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:key name="mon" match="Column[substring(@name, 4, 1) = '_']"  use="concat(parent::*/@rowNum, substring(@name, 1, 3))"/> 
<xsl:output method="text"/> 

<xsl:template match="DataSet/*"> 
    <xsl:text>&#10;</xsl:text> 
</xsl:template> 

<xsl:template match="DataSet"> 
<xsl:for-each select="*/Column[generate-id() = generate-id(key('mon', concat(parent::*/@rowNum, substring(@name, 1, 3)))[1])]"> 
    <xsl:value-of select="name(parent::*)"/> 
    <xsl:text>, </xsl:text> 
    <xsl:value-of select="position()"/> 
    <xsl:text>, </xsl:text> 
    <xsl:value-of select="@name"/> 
    <xsl:text>, </xsl:text> 
    <xsl:value-of select="parent::*/Column[not(substring(@name, 4, 1) = '_')]"/> 
    <xsl:text>, </xsl:text> 
    <xsl:value-of select="key('mon', concat(parent::*/@rowNum, substring(@name, 1, 3)))"/> 
</xsl:for-each> 
</xsl:template> 
</xsl:stylesheet>