Main.XSLTwoNodeTotal History
Hide minor edits - Show changes to markup
On the 2005 homepage I wanted to count out for events to display in one div. The total of the events listed was to come from two nodes. Today and Upcoming shown in the XML here.
On the 2005 homepage I wanted to count out for events to display in one div. The total of the events listed was to come from two nodes, Today and Upcoming shown in the XML here.
On the 2005 homepage I wanted to count out for events to display in one div. The total of the events listed was to come from two nodes. Today and Upcoming shown in the XML here.
<calendar> <today> <event> <title>Teaching Opportunity/title> </event> <event> <title>Walker without Walls</title> </event> </today> <upcoming> <event> <title>Talking Dance</title> </event> <event> <title>Talking Dance Series</title> </event> <event> <title>Walker Dance</title> </event> <event> <title>Performance Company</title> </event> <event> <title>Talking Dance</title> </event> </upcoming> </calendar>
On the 2005 homepage I wanted to count out for events to display in one div. The total of the events listed was to come from two nodes. Today and Upcoming shown in the XML here.
<calendar> <today> <event> <title>Teaching Opportunity for Artists</title> <category>Call for Artists</category> <link>calendar.walkerart.org/event.wac?id=1707</link> </event> <event> <title>Walker without Walls</title> <category>The Walker Takes it Outside (And Around Town)</category> <link>calendar.walkerart.org/canopy.wac?id=1013</link> </event> </today> <upcoming> <event> <title>Talking Dance with David Gordon</title> <category>Artist Talk</category> <link>calendar.walkerart.org/event.wac?id=1692</link> </event> <event> <title>The Gertrude Lippincott Talking Dance Series</title> <category>Artist Talks</category> <link>calendar.walkerart.org/canopy.wac?id=1689</link> </event> <event> <title>Walker Dance at the Pantages</title> <category>Dance Series</category> <link>calendar.walkerart.org/canopy.wac?id=1358</link> </event> <event> <title>Pick Up Performance Company</title> <category>Dance-Theater</category> <link>calendar.walkerart.org/canopy.wac?id=1359</link> </event> <event> <title>Talking Dance with Ralph Lemon</title> <category>Artist Talk</category> <link>calendar.walkerart.org/event.wac?id=1690</link> </event> </upcoming> </calendar>
The first part of the template that iterates through the "Today" node works like this
<xsl:template name="now">
<xsl:param name="limit" select="3"/>
<xsl:param name="counter" />
<xsl:param name="eventNum" select="count(//today/event)"/>
That just defined the paramaters that this template will use. Limit will make sure we don't go over four events (i call the template one more time after the limit is reached that is why it is set to 3 not 4) counter lets us keep a total count instead of doing it with position. That way we can pass the counter parameter on later when we call our second template. eventNum tells us how many event nodes there are in the today node so we know when to switch from events in today and start pulling events from the upcoming node instead. after i defined the parameters the template went on like this.
<xsl:if test="$counter <= $limit">
<div id="calendarParag">
<xsl:value-of select="//calendar/today/event[$counter]/title"/>
</div>
That just checks to see if the number of events displayed is less than our limit then it gets the title of the event out and ...
<xsl:if test="$counter < $eventNum">
<xsl:call-template name="now">
<xsl:with-param name="counter" select="$counter + 1" />
</xsl:call-template>
</xsl:if>
That checked to see if the counter is still less than the number of events. If it is l call this template (the one we are in right now) again after the $counter gets incremented. If we have seen all the events in the Today. After we have gone through the today node we can put down the different title dive and check the upcoming node like this
<div>
COMING SOON:
</div>
<xsl:call-template name="soon">
<xsl:with-param name="counter" select="$counter"/>
<xsl:with-param name="tCounter" select="1"/>
<xsl:with-param name="limit" select="$limit"/>
</xsl:call-template>
That passed along all the parameters we knew before but it also passes in one called tempCounter. If we don't have an independat counter and there are less than 4 events total in both nodes the XSL will go into an infinite loop and die. next we just close off our xsl:if 's and we get out of this template.
</xsl:if> </xsl:if> </xsl:template>
The second template just has to check to see if the counter level has been reached. If it has not then it calls itself and gets the data for another event.
<xsl:template name="soon">
<xsl:param name="counter" />
<xsl:param name="tCounter"/>
<xsl:param name="limit" />
<xsl:if test="$counter <= $limit">
<div id="calendarParag">
<xsl:value-of select="//upcoming/event[$tCounter]/title"/>
</div>
<xsl:call-template name="soon">
<xsl:with-param name="counter" select="$counter + 1" />
<xsl:with-param name="tCounter" select="$tCounter + 1" />
<xsl:with-param name="limit" select="$limit"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
I broke the counting up into two templates to iterate through the two nodes and pass the counting and totals in as parameters. My XSL looked like this to call the first template
<div class="smPoster green">
<h2>Calendar</h2>
<div id="title">
TODAY:
</div>
<xsl:call-template name="now">
<xsl:with-param name="counter" select="1" />
</xsl:call-template>
</div>
I broke the counting up into two templates to iterate through the two nodes and pass the counting and totals in as parameters. My XSL looked like this to call the first template
<div class="smPoster green">
<h2>Calendar</h2>
<div id="title">
TODAY:
</div>
<xsl:call-template name="now">
<xsl:with-param name="counter" select="1" />
</xsl:call-template>
</div>
The first part of the template that iterates through the "Today" node works like this
<xsl:template name="now">
<xsl:param name="limit" select="3"/>
<xsl:param name="counter" />
<xsl:param name="eventNum" select="count(//calendar/today/event)"/>
That just defined the paramaters that this template will use.
Limit will make sure we don't go over four events (i call the template one more time after the limit is reached that is why it is set to 3 not 4)
counter lets us keep a total count instead of doing it with position. That way we can pass the counter parameter on later when we call our second template.
eventNum tells us how many event nodes there are in the today node so we know when to switch from events in today and start pulling events from the upcoming node instead.
after i defined the parameters the template went on like this.
<xsl:if test="$counter <= $limit">
<div id="calendarParag">
<xsl:value-of select="//calendar/today/event[$counter]/title" disable-output-escaping="yes"/>
</div>
That just checks to see if the number of events displayed is less than our limit then it gets the title of the event out and ...
<xsl:if test="$counter < $eventNum">
<xsl:call-template name="now">
<xsl:with-param name="counter" select="$counter + 1" />
</xsl:call-template>
</xsl:if>
That checked to see if the counter is still less than the number of events. If it is l call this template (the one we are in right now) again after the $counter gets incremented.
If we have check all the events in the Today node we can go on to put down the different title dive and check the upcoming node like this
<div>
COMING SOON:
</div>
<xsl:call-template name="soon">
<xsl:with-param name="counter" select="$counter"/>
<xsl:with-param name="tempCounter" select="1"/>
<xsl:with-param name="limit" select="$limit"/>
</xsl:call-template>
That passed along all the parameters we knew before but it also passes in one called tempCounter. If we don't have an independat counter and there are less than 4 events total in both nodes the XSL will go into an infinite loop and die.
next we just close off our xsl:if 's and we get out of this template.
</xsl:if> </xsl:if> </xsl:template>
The second template just has to check to see if the counter level has been reached. If it has not then it calls itself and gets the data for another event.
<xsl:template name="soon">
<xsl:param name="counter" />
<xsl:param name="tempCounter"/>
<xsl:param name="limit" />
<xsl:if test="$counter <= $limit">
<div id="calendarParag">
<xsl:value-of select="//calendar/upcoming/event[$tempCounter]/title" disable-output-escaping="yes"/>
</div>
<xsl:call-template name="soon">
<xsl:with-param name="counter" select="$counter + 1" />
<xsl:with-param name="tempCounter" select="$tempCounter + 1" />
<xsl:with-param name="limit" select="$limit"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Limit will make sure we don't go over four events (i call the template one more time after the limit is reached that is why it is set to 3 not 4)
Limit will make sure we don't go over four events (i call the template one more time after the limit is reached that is why it is set to 3 not 4)
counter lets us keep a total count instead of doing it with position. That way we can pass the counter parameter on later when we call our second template.
counter lets us keep a total count instead of doing it with position. That way we can pass the counter parameter on later when we call our second template.
eventNum tells us how many event nodes there are in the today node so we know when to switch from events in today and start pulling events from the upcoming node instead.
eventNum tells us how many event nodes there are in the today node so we know when to switch from events in today and start pulling events from the upcoming node instead.
If we have check all the events in the Today node we can go on to put down the different title dive and check the upcoming node like this
If we have check all the events in the Today node we can go on to put down the different title dive and check the upcoming node like this
That passed along all the parameters we knew before but it also passes in one called tempCounter. If we don't have an independat counter and there are less than 4 events total in both nodes the XSL will go into an infinite loop and die.
That passed along all the parameters we knew before but it also passes in one called tempCounter. If we don't have an independat counter and there are less than 4 events total in both nodes the XSL will go into an infinite loop and die.
next we just close off our xsl:if 's and we get out of this template.
next we just close off our xsl:if 's and we get out of this template.
The template we called from that starts by defining the same variables we had from the first template.
The second template just has to check to see if the counter level has been reached. If it has not then it calls itself and gets the data for another event.
<xsl:template name="soon">
<xsl:template name="soon">
Then it tests the number counted and iterates through the upcoming node.
<xsl:if test="$counter <= $limit">
<div id="calendarParag">
<xsl:if test="$counter = $limit">
<xsl:attribute name="class">lineBottom</xsl:attribute>
</xsl:if>
<xsl:value-of select="//calendar/upcoming/event[$counter]/category" disable-output-escaping="yes"/>:<br/>
<a href="{//calendar/upcoming/event[$tempCounter]/link}"><xsl:value-of select="//calendar/upcoming/event[$tempCounter]/title" disable-output-escaping="yes"/></a>
</div>
<xsl:if test="$counter <= $limit">
<div id="calendarParag">
<xsl:value-of select="//calendar/upcoming/event[$tempCounter]/title" disable-output-escaping="yes"/>
</div>
<xsl:call-template name="soon">
<xsl:with-param name="counter" select="$counter + 1" />
<xsl:with-param name="tempCounter" select="$tempCounter + 1" />
<xsl:with-param name="limit" select="$limit"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:with-param name="whatList" select="1" />
The first part of the template that iterates through the "Today" node works like this
<xsl:template name="now">
<xsl:param name="limit" select="3"/>
<xsl:param name="counter" />
<xsl:param name="eventNum" select="count(//calendar/today/event)"/>
That just defined the paramaters that this template will use.
Limit will make sure we don't go over four events (i call the template one more time after the limit is reached that is why it is set to 3 not 4)
counter lets us keep a total count instead of doing it with position. That way we can pass the counter parameter on later when we call our second template.
eventNum tells us how many event nodes there are in the today node so we know when to switch from events in today and start pulling events from the upcoming node instead.
after i defined the parameters the template went on like this.
<xsl:if test="$counter <= $limit">
<div id="calendarParag">
<xsl:value-of select="//calendar/today/event[$counter]/title" disable-output-escaping="yes"/>
</div>
That just checks to see if the number of events displayed is less than our limit then it gets the title of the event out and ...
<xsl:if test="$counter < $eventNum">
<xsl:call-template name="now">
<xsl:with-param name="counter" select="$counter + 1" />
</xsl:call-template>
</xsl:if>
That checked to see if the counter is still less than the number of events. If it is l call this template (the one we are in right now) again after the $counter gets incremented.
If we have check all the events in the Today node we can go on to put down the different title dive and check the upcoming node like this
<div>
COMING SOON:
</div>
<xsl:call-template name="soon">
<xsl:with-param name="counter" select="$counter"/>
<xsl:with-param name="tempCounter" select="1"/>
<xsl:with-param name="limit" select="$limit"/>
</xsl:call-template>
That passed along all the parameters we knew before but it also passes in one called tempCounter. If we don't have an independat counter and there are less than 4 events total in both nodes the XSL will go into an infinite loop and die.
next we just close off our xsl:if 's and we get out of this template.
</xsl:if> </xsl:if> </xsl:template>
The template we called from that starts by defining the same variables we had from the first template.
<xsl:template name="soon">
<xsl:param name="counter" />
<xsl:param name="tempCounter"/>
<xsl:param name="limit" />
Then it tests the number counted and iterates through the upcoming node.
<xsl:if test="$counter <= $limit">
<div id="calendarParag">
<xsl:if test="$counter = $limit">
<xsl:attribute name="class">lineBottom</xsl:attribute>
</xsl:if>
<xsl:value-of select="//calendar/upcoming/event[$counter]/category" disable-output-escaping="yes"/>:<br/>
<a href="{//calendar/upcoming/event[$tempCounter]/link}"><xsl:value-of select="//calendar/upcoming/event[$tempCounter]/title" disable-output-escaping="yes"/></a>
</div>
Describe XSL Two Node Total here.
On the 2005 homepage I wanted to count out for events to display in one div. The total of the events listed was to come from two nodes. Today and Upcoming shown in the XML here.
<calendar> <today> <event> <title>Teaching Opportunity for Artists</title> <category>Call for Artists</category> <link>calendar.walkerart.org/event.wac?id=1707</link> </event> <event> <title>Walker without Walls</title> <category>The Walker Takes it Outside (And Around Town)</category> <link>calendar.walkerart.org/canopy.wac?id=1013</link> </event> </today> <upcoming> <event> <title>Talking Dance with David Gordon</title> <category>Artist Talk</category> <link>calendar.walkerart.org/event.wac?id=1692</link> </event> <event> <title>The Gertrude Lippincott Talking Dance Series</title> <category>Artist Talks</category> <link>calendar.walkerart.org/canopy.wac?id=1689</link> </event> <event> <title>Walker Dance at the Pantages</title> <category>Dance Series</category> <link>calendar.walkerart.org/canopy.wac?id=1358</link> </event> <event> <title>Pick Up Performance Company</title> <category>Dance-Theater</category> <link>calendar.walkerart.org/canopy.wac?id=1359</link> </event> <event> <title>Talking Dance with Ralph Lemon</title> <category>Artist Talk</category> <link>calendar.walkerart.org/event.wac?id=1690</link> </event> </upcoming> </calendar>
I broke the counting up into two templates to iterate through the two nodes and pass the counting and totals in as parameters. My XSL looked like this to call the first template
<div class="smPoster green">
<h2>Calendar</h2>
<div id="title">
TODAY:
</div>
<xsl:call-template name="now">
<xsl:with-param name="counter" select="1" />
<xsl:with-param name="whatList" select="1" />
</xsl:call-template>
</div>