[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
AW: [xsl] Selecting entries by date
Subject: AW: [xsl] Selecting entries by date From: Markus Abt <abt@xxxxxxxx> Date: Sun, 3 Aug 2003 18:06:14 +0200 |
Hello Chuck, in your code fragment, the variable $entrydate is set to the content of the first <dateofentry> element. This remains constant for the whole processing so you get always all or none of the entries as result. Put the variable and the <xsl:if> inside the <xsl:for-each> loop to get only the wanted entries: <xsl:variable name="thismonth" select="20030601"/> <xsl:template match="/"> <xsl:text>From: Charles Muller Subject: NEW SUBSCRIBERS> , 2003 </xsl:text> <xsl:for-each select="hbuddhism/entry"> <xsl:sort select="lastname"/> <xsl:variable name="entrydate" select="dateofentry"/> <xsl:if test="translate($entrydate, '-', '') < $thismonth"> <xsl:value-of select="position()"/> <xsl:text>. </xsl:text> <xsl:value-of select="firstname"/> <xsl:text> </xsl:text> <xsl:value-of select="lastname"/> <xsl:text>, </xsl:text> <xsl:value-of select="affiliation"/> <xsl:text>. Area: </xsl:text> <xsl:value-of select="area"/> <xsl:text>. Topic(s): </xsl:text> <xsl:value-of select="topic"/> <xsl:value-of select="$newline"/> <xsl:value-of select="$newline"/> </xsl:if> </xsl:for-each> </xsl:template> Also note, that you have to escape a '<' in the test attribute: use < Further, you can eleminate the variable and maybe also the <xsl:if>, simply write: <xsl:for-each select="hbuddhism/entry[translate(dateofentry, '-', '') < $thismonth]"> <xsl:sort select="lastname"/> In this case, however, the selected entries are numbered 1, 2, 3, ... by the position() function, since only the selected ones are looped through the <xsl:for-each>. In the first case above, all entries are looped through and numbered with their position, and then only the ones with the right date are outputted, so numbers look like 2, 5, 6, 8, ..., for example. Regards, Markus __________________________ Markus Abt Comet Computer GmbH http://www.comet.de ---------- Von: Charles Muller Gesendet: Sonntag, 3. August 2003 13:15 An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Betreff: Re: [xsl] Selecting entries by date While everyone is either sleeping (I am in Tokyo) or just simply enjoying their weekend, I have still been googling around and looking in the archives to solve my selection-by-date problem. I may have found a couple of clues under the topic 'compare dates.' First, I have properly converted all my dates to ISO 8601 format (i.e. 2003-07-10) and have added, in my attempt, this sort of solution, but am still apparently missing something <xsl:variable name="entrydate" select="hbuddhism/entry/dateofentry"/> <xsl:variable name="thismonth" select="20030601"/> <xsl:template match="/"> <xsl:text>From: Charles Muller Subject: NEW SUBSCRIBERS> , 2003 </xsl:text> <xsl:if test="translate($entrydate, '-', '') < $thismonth"> <xsl:for-each select="hbuddhism/entry"> <xsl:sort select="lastname"/> <xsl:value-of select="position()"/> <xsl:text>. </xsl:text> <xsl:value-of select="firstname"/> <xsl:text> </xsl:text> <xsl:value-of select="lastname"/> <xsl:text>, </xsl:text> <xsl:value-of select="affiliation"/> <xsl:text>. Area: </xsl:text> <xsl:value-of select="area"/> <xsl:text>. Topic(s): </xsl:text> <xsl:value-of select="topic"/> <xsl:value-of select="$newline"/> <xsl:value-of select="$newline"/> </xsl:for-each> Chuck --------------------------- Charles Muller <acmuller@xxxxxxx> Faculty of Humanities, Toyo Gakuen University Digital Dictionary of Buddhism and CJKV-English Dictionary [http://www.acmuller.net] H-Buddhism List Editor [http://www.h-net.org/~buddhism/] Mobile Phone: 090-9310-1787 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
AW: [xsl] Missing byte-order mark p, Markus Abt | Thread | Re: AW: [xsl] Selecting entries by , Charles Muller |
AW: [xsl] Missing byte-order mark p, Markus Abt | Date | [xsl] jd.xslt bug (at least unexpec, Robert Koberg |
Month |