Subject: Re: [xsl] Distinct list problem From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 18 Jan 2002 09:10:23 -0500 |
I'm trying to get a list of id's where each id is represented once out of the xml below. Is it possible?
The ouput I want is:
20 21 22
T:\ftemp>type henk.xml <CONTRACT IDCONTRACT="2" CCONTRACTNUMBER="1.1" CPRODUCT="JORISTEST" DECQUANTITY="1000.000" CUNIT="MT"> <DELIVERY IDDELIVERY="1" NUMLOADINGASSIGNMENT="1" IDTESTREPORT="2"> <ATTRIBUTEQUALITY IDTESTTYPE="20" /> <ATTRIBUTEQUALITY IDTESTTYPE="21" /> </DELIVERY> <DELIVERY IDDELIVERY="2" NUMLOADINGASSIGNMENT="1234" IDTESTREPORT="1"> <ATTRIBUTEQUALITY IDTESTTYPE="21" /> <ATTRIBUTEQUALITY IDTESTTYPE="20" /> <ATTRIBUTEQUALITY IDTESTTYPE="21" /> <ATTRIBUTEQUALITY IDTESTTYPE="21" /> <ATTRIBUTEQUALITY IDTESTTYPE="20" /> </DELIVERY> <DELIVERY IDDELIVERY="4" NUMLOADINGASSIGNMENT="4" IDTESTREPORT="20"> <ATTRIBUTEQUALITY IDTESTTYPE="22" /> <ATTRIBUTEQUALITY IDTESTTYPE="21" /> <ATTRIBUTEQUALITY IDTESTTYPE="20" /> </DELIVERY> <DELIVERY IDDELIVERY="6" NUMLOADINGASSIGNMENT="6" IDTESTREPORT="23"> <ATTRIBUTEQUALITY IDTESTTYPE="21" /> <ATTRIBUTEQUALITY IDTESTTYPE="20" /> </DELIVERY> </CONTRACT>
T:\ftemp>type henk.xsl <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:text>using keys: </xsl:text> <xsl:for-each select="//ATTRIBUTEQUALITY [generate-id(.)= generate-id(key('ids',@IDTESTTYPE))]"> <xsl:value-of select="@IDTESTTYPE"/> <xsl:text> </xsl:text> </xsl:for-each>
using variables: </xsl:text> <xsl:variable name="ids" select="//ATTRIBUTEQUALITY"/> <xsl:for-each select="$ids"> <xsl:if test="generate-id(.)= generate-id($ids[@IDTESTTYPE=current()/@IDTESTTYPE])">
<xsl:value-of select="@IDTESTTYPE"/> <xsl:text> </xsl:text> </xsl:if> </xsl:for-each>
T:\ftemp>saxon henk.xml henk.xsl using keys: 20 21 22
using variables: 20 21 22
-- Training Blitz: 3-days XSLT/XPath, 2-days XSLFO - Feb 18-22, 2002 - (Early-bird date for discounts is today!)
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 (Fax:-0995) ISBN 0-13-065196-6 Definitive XSLT & XPath ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-07-1 Practical Formatting Using XSLFO XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed), articles, training(instructor-live,Internet-live,web/CD,licensed) Next public training: 2002-01-18,02-11,12,13,15,18,21, - 03-04,05,06,08,11,04-08,09,10,12,05-14,15,06-04,07
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Distinct list problem, Henk Meulekamp | Thread | [xsl] general problem, Andrew Welch |
Re: [xsl] Saxon6.0.2: user written , cutlass | Date | [xsl] general problem, Andrew Welch |
Month |