私は以下のようなxmlを持っています:
<?xml version="1.0" encoding="utf-8"?>
<GetSavedReportResponse>
<ResponseType>Success</ResponseType>
<FileModifiedDateTime>2012-01-03T17:05:04</FileModifiedDateTime>
<FileSizeBytes>7816</FileSizeBytes>
<FileDataFormat>XML</FileDataFormat>
<FileData>
<Zthes>
<term>
<termId>49555</termId>
<termUpdate>add</termUpdate>
<termName>Active Personnel</termName>
<termVocabulary>People Status Global</termVocabulary>
<termVocabulary>Global People Status</termVocabulary>
<termCategory>PDA</termCategory>
<termCategory>PDI</termCategory>
<termCategory>GLB</termCategory>
<relation weight="100">
<termId>49556</termId>
<relationType>EQ</relationType>
<termName>term name</termName>
<termVocabulary>term vocabulary</termVocabulary>
</relation>
<relation weight="100">
<termId>49557</termId>
<relationType>BT</relationType>
<termName>General Active Personnel</termName>
<termVocabulary>People Status Global Updated</termVocabulary>
</relation>
</term>
<term>
<termId>49556</termId>
<termUpdate>add</termUpdate>
<termName>Leave of Absence Personnel</termName>
<termVocabulary>People Status Global</termVocabulary>
<termCategory>GLB</termCategory>
<termCategory>PDI</termCategory>
<relation weight="100">
<relationType>BT</relationType>
<termId>49554</termId>
<termName>General Non-Active Personnel</termName>
<termVocabulary>People Status Global</termVocabulary>
</relation>
</term>
</Zthes>
</FileData>
</GetSavedReportResponse>
フラットファイルに変換する必要があります。そのために、次のxslを書きました
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<xsl:template match="Zthes">
<xsl:text> </xsl:text>
<xsl:for-each select="term">
<xsl:text>"</xsl:text>
<xsl:text>GL</xsl:text>
<xsl:text>"</xsl:text>
<xsl:text>;</xsl:text>
<xsl:text>"</xsl:text>
<xsl:for-each select="termCategory">
<xsl:value-of select="." />
</xsl:for-each>
<xsl:text>"</xsl:text>
<xsl:text>;</xsl:text>
<xsl:text>"</xsl:text>
<xsl:for-each select="termVocabulary">
<xsl:value-of select="." />
</xsl:for-each>
<xsl:text>"</xsl:text>
<xsl:text>;</xsl:text>
<xsl:text>"</xsl:text>
<xsl:for-each select="relation/termVocabulary">
<xsl:value-of select="." />
</xsl:for-each>
<xsl:text>"</xsl:text>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
そのため、出力は
"HDR";"Text";"20120112045620";"F"
"GL";"PDA";"People Status Global";"term語彙"
"GL";"PDA";"People Statusグローバル";"人物ステータス グローバル更新済み"
"GL";"PDA";"グローバル人物ステータス";"用語語彙"
"GL";"PDA";"グローバル人物ステータス";"人物ステータス グローバル更新済み"
"GL" ;"PDI";"People Status Global";"用語語彙"
"GL";"PDI";"People Status Global";"People Status Global Updated"
"GL";"PDI";"Global People Status";"用語語彙"
"GL";"PDI";"グローバル ピープル ステータス";"ピープル ステータス グローバル更新"
"GL";"GLB";"ピープル ステータス グローバル";"用語語彙"
"GL";"GLB";"個人ステータス グローバル";"個人ステータス グローバル更新"
"GL";"GLB";"Global People Status";"用語語彙"
"GL";"GLB";"Global People Status";"People Status Global Updated"
"FTR";12
私のxslを使用すると、単一の行が得られます:
"GL";"PDAPDIGLB";"People Status GlobalGlobalPeople Status";"用語の語彙People Status Global Updated"
また、ヘッダー行:
"HDR";"PIGLSSTD";"20120112045620";"F":をフッター行
"FTR"
と共に先頭に追加する必要があります。
底に。