xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] getting a unique list using substring-after()


Subject: [xsl] getting a unique list using substring-after()
From: Aedemar Cooke <Aedemar.Cooke@xxxxxxxxxx>
Date: Thu, 1 Feb 2001 16:19:40 -0000

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



Current Thread
Keywords
xml
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor