This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
getting a unique list using substring-after()
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] getting a unique list using substring-after()
- From: Aedemar Cooke <Aedemar dot Cooke at Kadius dot com>
- Date: Thu, 1 Feb 2001 16:19:40 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
I am trying to get a list of resource ids from the below XML where only one
entry with the same sub-id (numbers after the - in the @id attribute)
appears
<related>
<content>
<resource id="66237-89002" displayText="test1"
date_of_entry="Mar 3"/>
<resource id="66237-89006" displayText="test1"
date_of_entry="Mar 3"/>
<resource id="66237-87005" displayText="First entry"
date_of_entry="Mar 3"/>
<resource id="66238-89002" displayText="test1"
date_of_entry="Mar 3"/>
<resource id="66238-89006" displayText="test1"
date_of_entry="Mar 3"/>
<resource id="66238-87005" displayText="First entry"
date_of_entry="Mar 3"/>
</content>
<product />
</related>
If I wanted to get a unique list dependent on @displayText then I could use
this code
<xsl:variable name = "unique-resources2"
select="//navigation_page/navigation/related/content/resource[not(@displayTe
xt=preceding-sibling::resource/@displayText)]"></xsl:variable>
<resource id="66237-89002" displayText="test1" date_of_entry="Mar
3"/>
<resource id="66237-87005" displayText="First entry"
date_of_entry="Mar 3"/>
can anyone explain why using the substring-after function
<xsl:variable name = "unique-resources"
select="//navigation_page/navigation/related/content/resource[not(substring-
after(@id,'-')=substring-after(preceding-sibling::resource/@id,'-'))]"></xsl
:variable>
yields
<resource id="66237-89002" displayText="test1" date_of_entry="Mar
3"/>
<resource id="66237-89006" displayText="test1" date_of_entry="Mar
3"/>
<resource id="66237-87005" displayText="First entry"
date_of_entry="Mar 3"/>
<resource id="66238-89006" displayText="test1" date_of_entry="Mar
3"/>
<resource id="66238-87005" displayText="First entry"
date_of_entry="Mar 3"/>
and not
<resource id="66237-89002" displayText="test1" date_of_entry="Mar
3"/>
<resource id="66237-89006" displayText="test1" date_of_entry="Mar
3"/>
<resource id="66237-87005" displayText="First entry"
date_of_entry="Mar 3"/>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list