|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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








