Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: position() within nested xsl:for-each position() within nested xsl:for-eachTo: NULL Date: 8/4/2005 8:17:00 PM This is a multi-part message in MIME format.
--------------070702070006090600050701
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
My apologies for asking what must be a relatively common question, but I
have been unsuccessful in finding it discussed elsewhere -- likely
because I'm not using the right search terms.
Given XML of the form:
<Season>
<Episode>
<Title>First show of first season</Title>
</Episode>
<Episode>
<Title>Second show of first season</Title>
</Episode>
<Episode>
<Title>Third show of first season</Title>
</Episode>
</Season>
<Season>
<Episode>
<Title>First show of second season</Title>
</Episode>
<Episode>
<Title>Second show of second season</Title>
</Episode>
</Season>
And XSL like this:
<xsl:for-each select="Season">
<xsl:for-each select="Episode">
<xsl:value-of select="position()"/>
<xsl:text>. </xsl:text>
<xsl:value-of select="Title"/>
<br/>
</xsl:for-each>
</xsl:for-each>
Which yields output like this:
1. First show of first season
2. Second show of first season
3. Third show of first season
1. First show of second season
2. Second show of second season
How can I get the numbering to be relative to the entire document,
instead of the <Season>, like this:
1. First show of first season
2. Second show of first season
3. Third show of first season
4. First show of second season
5. Second show of second season
Thanks for your time and consideration.
--------------070702070006090600050701
Content-Type: text/xml;
name="test.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="test.xml"
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type='text/xsl' href='test.xsl'?>
<EpisodeGuide>
<Season>
<Episode>
<Title>First show of first season</Title>
</Episode>
<Episode>
<Title>Second show of first season</Title>
</Episode>
<Episode>
<Title>Third show of first season</Title>
</Episode>
</Season>
<Season>
<Episode>
<Title>First show of second season</Title>
</Episode>
<Episode>
<Title>Second show of second season</Title>
</Episode>
</Season>
</EpisodeGuide>
--------------070702070006090600050701
Content-Type: text/xml;
name="test.xsl"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
filename="test.xsl"
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="html"/>
<xsl:template match="/EpisodeGuide">
<html>
<body>
<xsl:for-each select="Season">
<xsl:for-each select="Episode">
<xsl:value-of select="position()"/>
<xsl:text>. </xsl:text>
<xsl:value-of select="Title"/>
<br/>
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
--------------070702070006090600050701--
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
