This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: How to get unique data
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] How to get unique data
- From: "Chris Bayes" <chris at bayes dot co dot uk>
- Date: Wed, 7 Nov 2001 23:34:53 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
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@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of Rick Zhang
> Sent: 07 November 2001 22:57
> To: XSL-List@lists.mulberrytech.com
> 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