Subject: RE: [xsl] How to get unique data From: "Chris Bayes" <chris@xxxxxxxxxxx> Date: Wed, 7 Nov 2001 23:34:53 -0000 |
What a pity we can't post little video clips. The one of John Cleese banging his head on the check-in desk at Faulty Towers comes to mind. But then so does the little clip of him thrashing his car with a tree branch. Until someone finds a link to this clip maybe you should look at http://www.netcrucible.com/ Ciao Chris XML/XSL Portal http://www.bayes.co.uk/xml > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Rick Zhang > Sent: 07 November 2001 22:57 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] How to get unique data > > > Hi, > In SQL "Select Distinct ...." can get the unique data > form the specify table. But in xml I can not do the same work. > > The data is as following: > <prog pid="0"> > <item iid="0" fid="1"/> > <item iid="0" fid="2"/> > <item iid="0" fid="3"/> > <item iid="0" fid="4"/> > <item iid="0" fid="5"/> > <item iid="1" fid="6"/> > <item iid="1" fid="7"/> > <item iid="1" fid="8"/> > <item iid="1" fid="9"/> > <item iid="1" fid="10"/> > </prog> > <prog pid="1"> > <item iid="2" fid="11"/> > <item iid="2" fid="12"/> > <item iid="2" fid="13"/> > <item iid="2" fid="14"/> > <item iid="2" fid="15"/> > <item iid="3" fid="16"/> > <item iid="3" fid="17"/> > <item iid="3" fid="18"/> > <item iid="3" fid="19"/> > <item iid="3" fid="20"/> > </prog> > > How can I use xsl in IE to get the follow data: > <prog pid="0"> > <item iid="0" fid="1"/> > <item iid="1" fid="6"/> > </prog> > <prog pid="1"> > <item iid="2" fid="11"/> > <item iid="3" fid="16"/> > </prog> > > fid attribute's value here is not important, I just want > to the first item element with the unique iid. > > I use the follow xsl > ... > <xsl:for-each select="//prog" order-by="@pid"> > <xsl:for-each select="item" order-by="@iid"> > <xsl:if exp="!checkDup( @iid )"> > ...show the unique data... > </xsl:if> > </xsl:for-each> > </xsl:for-each> > ... > <xsl:script language="javascript"> > <![CDATA[ > var arrItemName = new Array(); > > function checkDup( item ) > { > var isDup = false; > > for ( i = 0; i<arrItemName.length; i++ ) > { > if ( arrItemName[i] == item ){ > isDup = true; > break; > } > } > > if ( isDup==false ){ > var len = arrItemName.length; > arrItemName.length ++; > arrItemName[len] = item; > } > > return isDup; > } > ]]> > </xsl:script> > > IE reported no error but still give the duplicate data, > why??? Can anyone help me out??? > ______________________________________ > ÎÒµÄQQ : 329170 > ÎÒµÄICQ : 37175293 > ÎÒµÄÂÛ̳: http://www3.ccw.com.cn c/c++ > =================================================================== > ÐÂÀËÃâ·Ñµç×ÓÓÊÏä (http://mail.sina.com.cn) > ÐÂÀË·ÖÀàÐÅÏ¢££³ÇÊÐÉú»îÖ¸ÄÏ£¡ (http://classad.sina.com.cn/) > ÆßÖÖÊÖ»úͼƬ¡¢Ç§Ê×ÁåÉùÏÂÔØ¡¡ÐÂÀ˶ÌÐÅÎÞÏÞ¾«²Ê! > (http://sms.sina.com.cn/) > > 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 -> |
---|---|---|
[xsl] How to get unique data, Rick Zhang | Thread | Re: [xsl] How to get unique data, ronald heller |
RE: [xsl] [ANNOUNCE] UWOBO 1.2.0 re, Michael Kay | Date | Re: [xsl] Changing row colors using, David Carlisle |
Month |