You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Dafang Zhang <da...@wcom.com> on 2000/06/16 18:40:45 UTC
sql-processor with for-each question
Hello,
For the following sql-processor produced xml source fragment,
<row-set>
<row>
<customer-id>cust-1</customer-id>
<statement-date>2000-06-01</statement-date>
</row>
<row>
<customer-id>cust-2</customer-id>
<statement-date>2000-04-01</statement-date>
</row>
<row>
<customer-id>cust-3</customer-id>
<statement-date>2000-06-01</statement-date>
</row>
<row>
<customer-id>cust-1</customer-id>
<statement-date>2000-05-01</statement-date>
</row>
<row>
<customer-id>cust-4</customer-id>
<statement-date>2000-04-01</statement-date>
</row>
<row>
<customer-id>cust-3</customer-id>
<statement-date>2000-05-01</statement-date>
</row>
.
.
.
</row-set>
I would like to retrieve a distinct statement-date set, in this case,
something like:
2000-04-01
2000-05-01
2000-06-01
I tried to use XSLT's for-each element, but it doesn't make sense, since
there's only 1 child in each loop if I understood correctly, thus, I can't
use something like position() - 1 or preceding-sibling::order-date to access
previously processed child.
<!-- the following code _NOT_ working -->
<xsl:for-each select="row-set">
<xsl:sort select="order-date"/>
<xsl:if test="order-date != order-date[position()-1]">
<xsl:apply-templates select="order-date"/>
</xsl:if>
</xsl:for-each>
Using variable seems not working either, since variable has similar semantic
to Java's final variable and no equivalent to the Java assignment opeartor,
thus, I can't use variable to save previously processed child.
How to approach this seems very simple task? (NOTE: Issuing a SQL statement,
"select distinct ...", is not a choice in my case.)
Any help would be greatly appreciated.
Dafang Zhang