P
Phoenix
I am trying to print date headings over comments (as headings)
I have a simple XML file :
<comments>
<comment id=1234 yyyymmdd="20041230" flag="Y">..text..</comment>
<comment id=1309 yyyymmdd="20041230" flag="Y">..text..</comment>
<comment id=1333 yyyymmdd="20041230" flag="N">..text..</comment>
<comment id=1389 yyyymmdd="20041230" flag="Y">..text..</comment>
<comment id=1409 yyyymmdd="20041230" flag="Y">..text..</comment>
<comment id=1450 yyyymmdd="20041229" flag="Y">..text..</comment>
<comment id=1464 yyyymmdd="20041229" flag="N">..text..</comment>
<comment id=1470 yyyymmdd="20041229" flag="Y">..text..</comment>
</comments>
Then I run thru a for-each loop (i have lots of formatting to do)
I want to print the date if the current node's date is different from
the prior node's date....It does it right the first time, but then
continues printing the dates thru the end of the file. When I print out
the preciding sibling (for testing purposes), it seems to be stuck on
the first node. Any suggestions??
......
<xsl:variable name="commentDate">
<xsl:value-of select="substring(@yyyymmdd,6,2)"/>-<xsl:value-of
select="substring(@yyyymmdd,9,2)"/>-<xsl:value-of
select="substring(@yyyymmdd,1,4)"/>
</xsl:variable>
........
<xsl:for-each select="comments/comment[@flag='Y']">
<xsl:if test="position() !='1' and @yyyymmdd !=
preceding-sibling::comment/@yyyymmdd">
<tr><td <!---->
<xsl:value-of select="$commentDate"/><br/>
<xsl:value-of select="@yyyymmdd"/>:::
<xsl:value-of select="preceding-sibling::comment/@yyyymmdd"/>
</td></tr>
</xsl:if>
</xsl:for-each>
......
thanks,
Jenn
I have a simple XML file :
<comments>
<comment id=1234 yyyymmdd="20041230" flag="Y">..text..</comment>
<comment id=1309 yyyymmdd="20041230" flag="Y">..text..</comment>
<comment id=1333 yyyymmdd="20041230" flag="N">..text..</comment>
<comment id=1389 yyyymmdd="20041230" flag="Y">..text..</comment>
<comment id=1409 yyyymmdd="20041230" flag="Y">..text..</comment>
<comment id=1450 yyyymmdd="20041229" flag="Y">..text..</comment>
<comment id=1464 yyyymmdd="20041229" flag="N">..text..</comment>
<comment id=1470 yyyymmdd="20041229" flag="Y">..text..</comment>
</comments>
Then I run thru a for-each loop (i have lots of formatting to do)
I want to print the date if the current node's date is different from
the prior node's date....It does it right the first time, but then
continues printing the dates thru the end of the file. When I print out
the preciding sibling (for testing purposes), it seems to be stuck on
the first node. Any suggestions??
......
<xsl:variable name="commentDate">
<xsl:value-of select="substring(@yyyymmdd,6,2)"/>-<xsl:value-of
select="substring(@yyyymmdd,9,2)"/>-<xsl:value-of
select="substring(@yyyymmdd,1,4)"/>
</xsl:variable>
........
<xsl:for-each select="comments/comment[@flag='Y']">
<xsl:if test="position() !='1' and @yyyymmdd !=
preceding-sibling::comment/@yyyymmdd">
<tr><td <!---->
<xsl:value-of select="$commentDate"/><br/>
<xsl:value-of select="@yyyymmdd"/>:::
<xsl:value-of select="preceding-sibling::comment/@yyyymmdd"/>
</td></tr>
</xsl:if>
</xsl:for-each>
......
thanks,
Jenn