![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: An XML question - calculating time total [Thread Next] Re: An XML question - calculating time totalTo: NULL Date: 3/2/2005 9:41:00 PM Works well! Thank you very much. "Mukul Gandhi" <mukul_gandhi@y...> wrote in message news:b1634669.0503010726.24baa3f3@p...... > Please try this XSL.. > > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:output method="text"/> > > <xsl:template match="/album"> > <xsl:apply-templates select="general" /> > <xsl:apply-templates select="content/song" /> > </xsl:template> > > <xsl:template match="general"> > <xsl:value-of select="title" /> (<xsl:value-of select="year" > />)<xsl:text>
</xsl:text> > <xsl:variable name="elapsed-time"> > <xsl:call-template name="format-time"> > <xsl:with-param name="x" > select="sum(following-sibling::content[1]/song/songLengthInSeconds)" > /> > </xsl:call-template> > </xsl:variable> > Elapsed Time (hh:mm:ss): <xsl:value-of select="$elapsed-time" > /><xsl:text>
</xsl:text> > </xsl:template> > > <xsl:template match="content/song"> > Song 1: <xsl:value-of select="songTitle" > /><xsl:text>
</xsl:text> > <xsl:variable name="length"> > <xsl:call-template name="format-time"> > <xsl:with-param name="x" select="songLengthInSeconds" /> > </xsl:call-template> > </xsl:variable> > Length (hh:mm:ss): <xsl:value-of select="$length" > /><xsl:text>
</xsl:text> > </xsl:template> > > <xsl:template name="format-time"> > <xsl:param name="x" /> > > <xsl:value-of select="format-number(floor(($x div 60) div 60),'00')" > />:<xsl:value-of select="format-number(floor(($x div 60) mod > 60),'00')" />:<xsl:value-of select="format-number($x mod 60,'00')" /> > </xsl:template> > > </xsl:stylesheet> > > Regards, > Mukul > > "T-Narg" <tnarg@u...> wrote in message news:<38i8ptF5p3765U1@i...>... > > I would like to produce the following output based on my XML file: > > > > My Album (2005) > > Elapsed Time (hh:mm:ss): 00:07:00 > > > > Song 1: title1 > > Length (hh:mm:ss): 00:02:30 > > > > Song 2: title2 > > Length (hh:mm:ss): 00:02:15 > > > > Song 3: title3 > > Length (hh:mm:ss): 00:02:15 > > > > > > ===== > > > > <album> > > <general> > > <title>My Album</title> > > <year>2005</year> > > </general> > > > > <content> > > <song> > > <songTitle>title1</songTitle> > > <songLengthInSeconds>150</songLengthInSeconds> > > </song> > > <song> > > <songTitle>title2</songTitle> > > <songLengthInSeconds>135</songLengthInSeconds> > > </song> > > <song> > > <songTitle>title3</songTitle> > > <songLengthInSeconds>135</songLengthInSeconds> > > </song> > > </content> > > </album> > > > > ===== > > > > I need some help in designing the XSLT file. I'd like the > > <songLengthInSeconds> to be formatted in hh:mm:ss format. Also, I want to > > display the elapsed time (in hh:mm:ss format) based on a total of > > <songLengthInSeconds>. Could I perform this summation inside the XSLT? > > > > Thank you very much! | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
