Re: [xsl] help with looping thru children

Subject: Re: [xsl] help with looping thru children
From: "Jay Bryant" <jay@xxxxxxxxxxxx>
Date: Wed, 3 May 2006 13:25:27 -0500
Rather than think in terms of loops, try thinking in terms of templates.

In other words, rather than try to count things and do something each time
some value is incremented (and even for-each doesn't work that way in XSLT),
try doing something each time a certain kind of node is found.

So, rather than

<xsl:for-each select="something">


<xsl:template match="something">


Jay Bryant
Bryant Communication Services

----- Original Message ----- 
From: "Lyn Stewart-Hunter" <Lyn@xxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, May 03, 2006 12:07 PM
Subject: [xsl] 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

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 = web +analytics,ENDROW

XML is:
<?xml version='1.0' encoding='utf-8' ?>
<REFERRING_URL>http://w w = web
<TIMESTAMP>2004-04-12 11:54:48 PST</TIMESTAMP>
<TIMESTAMP>2004-04-12 11:56:46 PST</TIMESTAMP>
<TIMESTAMP>2004-04-12 11:56:58 CST</TIMESTAMP>
XSL is:
<xsl:stylesheet xmlns:xsl="";
<xsl:output method="text"

<xsl:strip-space elements="*"/>

<xsl:template match="/">
<xsl:apply-templates select="SESSION"/>

<xsl:template match="SESSION">
<xsl:apply-templates select="EVENTS"/>

<xsl:template match="SUMMARY">
<xsl:value-of select="REFERRING_URL"/>

<xsl:template match="EVENTS">
                <xsl:value-of select="//TIMESTAMP"/>
                <xsl:value-of select="//PAGENAME"/>
                <xsl:value-of select="//DOWNLOAD"/>
<xsl:apply-templates select="../SUMMARY"/>


Current Thread