"GL";"PDA";"People Status Global";"term vocabulary"
"GL";"PDA";"People Status Global";"People Status Global Updated"
"GL";"PDA";"Global People Status";"term vocabulary"
"GL";"PDA";"Global People Status";"People Status Global Updated"
"GL";"PDI";"People Status Global";"term vocabulary"
"GL";"PDI";"People Status Global";"People Status Global Updated"
"GL";"PDI";"Global People Status";"term vocabulary"
"GL";"PDI";"Global People Status";"People Status Global Updated"
"GL";"GLB";"People Status Global";"term vocabulary"
"GL";"GLB";"People Status Global";"People Status Global Updated"
"GL";"GLB";"Global People Status";"term vocabulary"
"GL";"GLB";"Global People Status";"People Status Global Updated"
with my xsl I am gettin single row:
"GL";"PDAPDIGLB";"People Status GlobalGlobal People Status";"term vocabularyPeople Status Global Updated"
please help me in correcting as per the requirement.
Ram Reddy Me...
Star
9604 Points
1314 Posts
XSLT to transform an xml file to a flat file
Jan 17, 2012 07:21 AM|LINK
I have an xml like beow:
<?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>I need to transform it into a flat file. For that, I have writen the following 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>so, the output should be
"GL";"PDA";"People Status Global";"term vocabulary"
"GL";"PDA";"People Status Global";"People Status Global Updated"
"GL";"PDA";"Global People Status";"term vocabulary"
"GL";"PDA";"Global People Status";"People Status Global Updated"
"GL";"PDI";"People Status Global";"term vocabulary"
"GL";"PDI";"People Status Global";"People Status Global Updated"
"GL";"PDI";"Global People Status";"term vocabulary"
"GL";"PDI";"Global People Status";"People Status Global Updated"
"GL";"GLB";"People Status Global";"term vocabulary"
"GL";"GLB";"People Status Global";"People Status Global Updated"
"GL";"GLB";"Global People Status";"term vocabulary"
"GL";"GLB";"Global People Status";"People Status Global Updated"
with my xsl I am gettin single row:
"GL";"PDAPDIGLB";"People Status GlobalGlobal People Status";"term vocabularyPeople Status Global Updated"
please help me in correcting as per the requirement.
Abhiram Reddy Mekha