|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Finding nester distinct items
At 2003-03-10 13:26 -0600, Craig Kattner wrote:
What I need is to get a distinct list of Pole val's and then for each Pole a distinct list of Time val's. (I need to be able to recreate this http://www.intermatic.com/comind/fdff.htm). When you say "distinct list of Time val's", your test data doesn't reflect duplicate values for time the way the web page does. I modified the data to include a duplicate for 6-hour single-pole single-throw switches. I find that using variables for multiple levels of uniqueness is better than using the Muenchian Method, but tastes vary. When using variables, the idea is to create a variable with all items from which uniqueness is determined, and then create a variable of those for each of those that are unique and find uniqueness within those variables. This avoids concatenating key values for each level of uniqueness in the Muenchian Method. The first of each variable for each value is determined using generate-id() since generate-id() only works on the first member of a passed node set. An example is below ... I hope this helps. ................. Ken
<xsl:output method="text"/> <xsl:template match="/">
<xsl:variable name="products" select="/products/product"/>
<xsl:for-each select="$products">
<xsl:if test="generate-id(.) =
generate-id( $products[ product_fact[@name='Pole']/val=
current()/product_fact[@name='Pole']/val ])">
<xsl:value-of select="product_fact[@name='Pole']/val"/>
<xsl:text>
</xsl:text>
<xsl:variable name="times"
select="$products[ product_fact[@name='Pole']/val=
current()/product_fact[@name='Pole']/val ]"/>
<xsl:for-each select="$times">
<xsl:if test="generate-id(.) =
generate-id( $times[ product_fact[@name='Time']/val=
current()/product_fact[@name='Time']/val ])">
<xsl:text> </xsl:text>
<xsl:value-of select="product_fact[@name='Time']/val"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="$times[ product_fact[@name='Time']/val=
current()/product_fact[@name='Time']/val ]"> <xsl:text> </xsl:text>
<xsl:value-of select="@model"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:template></xsl:stylesheet> T:\ftemp>saxon craig.xml craig.xsl
SPST
12 hours
FD12H
6 hours
FD6H
FD6HH
SPDT
4 hours
FD4HT:\ftemp>rem Done!
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-10-1 Practical Formatting Using XSL-FO Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








