Subject: Re: [xsl] help with looping thru children From: "CyberSpace Industries 2000 Inc." <csi2000@xxxxxxxxxxxxxxx> Date: Wed, 3 May 2006 14:16:01 -0400 |
Cheers...Hugh CyberSpace Industries 2000 Inc. XML Training and Consulting
<xsl:template match="SESSION"> <xsl:apply-templates /> </xsl:template>
<!-- Pull in everything for a single output line for each EVENT --> <xsl:template match="EVENTS"> <xsl:apply-templates /> </xsl:template>
<!-- the following gets triggered for each EVENT node encountered --> <xsl:template match="EVENT"> <!-- put the URL at the beginning of each output line --> <xsl:value-of select="//REFERRING_URL" /> <xsl:text>,</xsl:text> <xsl:value-of select="TIMESTAMP" /> <xsl:text>,</xsl:text>
<xsl:value-of select="VIEW/PAGENAME"/> <xsl:text>,</xsl:text> <xsl:value-of select="VIEW/CONTENT"/> <xsl:text>,</xsl:text> <xsl:value-of select="VIEW/RELOADS"/> <xsl:text>,</xsl:text>
<xsl:value-of select="FUNNELS/FUNNEL/IS_CONVERSION_LEVEL"/> <xsl:text>,</xsl:text> <xsl:value-of select="FUNNELS/FUNNEL/FUNNEL_ID"/> <xsl:text>,</xsl:text> <xsl:value-of select="FUNNELS/FUNNEL/FUNNEL_LEVEL"/> <xsl:text>,</xsl:text>
<xsl:value-of select="DOWNLOAD"/> <xsl:text>,ENDROW
</xsl:text> </xsl:template> </xsl:stylesheet>
Howdy. I was able to use some past help to get header data to repeat in a CSV format, but I then couldn't figure out where to put the for-each to loop thru all EVENTS (or whatever structure would work). From the XML I would like a row in a CSV file for every EVENT (and include the SUMMARY.REFERRING_URL).
I am also getting the DOWNLOAD on the 'wrong' row (maybe a new template at that level?) and need to figure out how to get FUNNEL.CONVERSION ID listed after its EVENT - if that's easy for someone to show me. But I am most interesting capturing each EVENT and maintaining the SUMMARY data for each row - I don't know xml very well, so examples are ideal.
thank you. Lyn
My current output looks like: 2004-04-12 11:54:48 PST,HBX Home,Simple eBook,http://w w w.google.com/search?q = web +analytics,ENDROW
XML is: <?xml version='1.0' encoding='utf-8' ?> <SESSION> <SUMMARY> <REFERRING_URL>http://w w w.google.com/search?q = web +analytics</REFERRING_URL> <BROWSER> MSIE 6.0</BROWSER> </SUMMARY> <EVENTS> <EVENT> <TIMESTAMP>2004-04-12 11:54:48 PST</TIMESTAMP> <VIEW> <PAGENAME>HBX Home</PAGENAME> <CONTENT>/Products/HBX</CONTENT> <RELOADS>1</RELOADS> </VIEW> <FUNNELS> <FUNNEL> <IS_CONVERSION_LEVEL>3</IS_CONVERSION_LEVEL> <FUNNEL_ID>1123</FUNNEL_ID> <FUNNEL_LEVEL>1</FUNNEL_LEVEL> </FUNNEL> </FUNNELS> </EVENT> <EVENT> <TIMESTAMP>2004-04-12 11:56:46 PST</TIMESTAMP> <VIEW> <PAGENAME> Download Page</PAGENAME> <CONTENT>/Products/HBX/Downloads</CONTENT> </VIEW> <FUNNELS> <FUNNEL> <IS_CONVERSION_LEVEL>3</IS_CONVERSION_LEVEL> <FUNNEL_ID>1123</FUNNEL_ID> <FUNNEL_LEVEL>3</FUNNEL_LEVEL> </FUNNEL> </FUNNELS> </EVENT> <EVENT> <TIMESTAMP>2004-04-12 11:56:58 CST</TIMESTAMP> <DOWNLOAD>Simple eBook</DOWNLOAD> </EVENT> </EVENTS> </SESSION> +++++++++++++++++++++ XSL is: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" encoding="ISO-8859-1"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/"> <xsl:apply-templates select="SESSION"/> </xsl:template>
<xsl:template match="SESSION"> <xsl:apply-templates select="EVENTS"/> </xsl:template>
<xsl:template match="SUMMARY"> <xsl:value-of select="REFERRING_URL"/> <xsl:text>,</xsl:text> </xsl:template>
<xsl:template match="EVENTS"> <xsl:value-of select="//TIMESTAMP"/> <xsl:text>,</xsl:text> <xsl:value-of select="//PAGENAME"/> <xsl:text>,</xsl:text> <xsl:value-of select="//DOWNLOAD"/> <xsl:text>,</xsl:text> <xsl:apply-templates select="../SUMMARY"/> <xsl:text>ENDROW
</xsl:text>
</xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] help with looping thru childr, Lyn Stewart-Hunter | Thread | Re: [xsl] help with looping thru ch, Jay Bryant |
[xsl] help with looping thru childr, Lyn Stewart-Hunter | Date | Re: [xsl] help with looping thru ch, Jay Bryant |
Month |