[Home] [By Thread] [By Date] [Recent Entries]
Lyn ...One piece of advice I give some of my students is to stop thinking
procedurally.
The XSLT processor will read your XML, build an in-memory tree of nodes that corresponds to the hiearchy of your XML document, then traverse that tree in document order. This comes for free and you don't have to "program" this navigation. What I did below is basically get to the EVENT node - then from there "pull in" everything I needed from the tree - relative to the EVENT node. Doing it this way, I also handle the case where there is missing nodes, such as your final EVENT where there is only a DOWNLOAD node. Cheers...Hugh CyberSpace Industries 2000 Inc. XML Training and Consulting I get: --------------------------------------------------------------- http://w w w.google.com/search?q = web +analytics,2004-04-12 11:54:48 PST,HBX Home,/Products/HBX,1,3,1123,1,,ENDROW http://w w w.google.com/search?q = web +analytics,2004-04-12 11:56:46 PST, Download Page,/Products/HBX/Downloads,,3,1123,3,,ENDROW http://w w w.google.com/search?q = web +analytics,2004-04-12 11:56:58 CST,,,,,,,Simple eBook,ENDROW ------------------------------------------------------------------ I didn't try to fix the line end problems.. or the "w w w" - The first one (before the +) comes from your xml. Also didn't know what you wnated to do when there was no DOWNLOAD --- xsl --- <?xml version="1.0" encoding="UTF-8"?> <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 /> </xsl:template> <xsl:template match="SESSION"> <xsl:apply-templates /> </xsl:template> <xsl:template match="SUMMARY"/> <!-- 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> ----- Original Message ----- From: "Lyn Stewart-Hunter" <Lyn@xxxxxxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, May 03, 2006 1:07 PM Subject: help with looping thru children 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).
|

Cart



