Forum Moderators: open

Message Too Old, No Replies

filtering and unique results

filters

         

TheMaltesePenguin1

12:06 pm on Jan 4, 2008 (gmt 0)

10+ Year Member




Hi there

I'm trying to filter out some content it's coming from multiple sources.

I need it to filter out those which have an attribute of "new=true" - which I've done and works in isolation.

However as the data is coming from numerous sources there is some duplication which I would like to get rid of. I think I'm in the right area, but it's not quite there.

Here's what I've got
<xsl:apply-templates select="registry/category/channel[@new='true'] ¦ registry/category/channel[not(.=following::channel)]">
<xsl:sort select="@name"/>
</xsl:apply-templates>

Cheers
Lee

httpwebwitch

2:15 pm on Jan 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



tricky one. my instinct would be to parse the XML into an array, filter dupes, then reassemble the XML.

But there might be a better way

httpwebwitch

2:17 pm on Jan 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



please donate a sample of your XML

TheMaltesePenguin1

2:23 pm on Jan 4, 2008 (gmt 0)

10+ Year Member



<registry>
<category ID="catlocal.54" description="Entertainment" name="Entertainment">
<category ID="catlocal.55" description="Games" name="Games"/>
<channel ID="chan301" chanID="301" class="ca.uvic.uportal.channels.ChannelNav.ChannelListChannel" description="lists available channels with &apos;preview&apos;" editable="false" fname="AvailableChannels" hasAbout="false" hasHelp="true" name="Available Channels" new="true" secure="false" subscribable="true" timeout="10000" title="Available Channels" typeID="11">
<parameter name="previewBlackList" override="no" value=""/>
</channel>
<channel ID="chan11" chanID="11" class="org.jasig.portal.channels.CGenericXSLT" description="Word of the Day channel" editable="false" fname="" hasAbout="false" hasHelp="false" name="Word of the Day" new="true" secure="false" subscribable="true" timeout="60000" title="Word of the Day" typeID="0">
<parameter name="sslUri" override="no" value="CGenericXSLT/RSS/RSS-0_9x.ssl"/>
<parameter name="xmlUri" override="no" value="http://dictionary.reference.com/wordoftheday/wotd.rss"/>
</channel>
</category>
<category ID="catlocal.51" description="News" name="News">
<category ID="catlocal.53" description="Instutition News" name="Institution"/>
<category ID="catlocal.52" description="World News" name="World"/>

<channel ID="chan212" chanID="212" class="com.pipeline.uportal.CpServletWrapper" description="My Headlines" editable="false" fname="" hasAbout="false" hasHelp="false" name="My Headlines" new="true" secure="false" subscribable="true" timeout="60000" title="My Headlines" typeID="-1">
<parameter name="realpath" override="no" value="cp/chan/is"/>
</channel>
<channel ID="chan301" chanID="301" class="ca.uvic.uportal.channels.ChannelNav.ChannelListChannel" description="lists available channels with &apos;preview&apos;" editable="false" fname="AvailableChannels" hasAbout="false" hasHelp="true" name="Available Channels" new="true" secure="false" subscribable="true" timeout="10000" title="Available Channels" typeID="11">
<parameter name="previewBlackList" override="no" value=""/>
</channel>
</category>
</registry>

TheMaltesePenguin1

2:25 pm on Jan 4, 2008 (gmt 0)

10+ Year Member



I've not touch XPath in a while, and I'm working within an existing xsl file, whenever I try and id it to a variable to filter out the duplicates i get errors along the lines of things not being allowing in that position in the stylesheet

TheMaltesePenguin1

2:28 pm on Jan 4, 2008 (gmt 0)

10+ Year Member



This is the section of the existing XSL i've been working with

<xsl:apply-templates select="registry/category/channel[@new='true']">
<xsl:sort select="@name"/>
</xsl:apply-templates>

cmarshall

2:55 pm on Jan 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld! Here [webmasterworld.com] is a posting that I made where I use a "trick" to do something pretty similar. I take only the first instance of an element that can appear repeatedly, and use that.

The posting is a long, intricate treatise on how it works. If you don't want to deal with it, then you can try modifying the trick itself to suit your needs (that's what I originally did -I eventually wanted to find out exactly how it worked behind the curtain).

It uses an XSLT key [w3schools.com] in about as intricate a manner as you can get.