Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2006, 06:43 AM
Registered User
 
Join Date: Feb 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl select statement

Hi,

I am using this select statement to return unique clients from my xml file and put them into a drop down list.
//portfolio/campaign[@client_name][not(@client_name=preceding-sibling::campaign/@client_name)]

This line works perfect, but I also need another select statement to return unique creative types from my xml file.
Tried this:
//portfolio/campaign/creative[@client_type][not(@client_type=preceding-sibling::creative/@client_type)]

This is the struture of my xml

<portfolio>
    <campaign client_name="client1">
        <creative creative_type = "banner"></creative>
        <creative creative_type = "island"></creative>
        <creative creative_type = "banner"></creative>
    </campaign>
    <campaign client_name="client2">
        <creative creative_type = "banner"></creative>
        <creative creative_type = "island"></creative>
        <creative creative_type = "banner"></creative>
    </campaign>
    <campaign client_name="client3">
        <creative creative_type = "banner"></creative>
        <creative creative_type = "island"></creative>
        <creative creative_type = "banner"></creative>
    </campaign>
</portfolio>

The select statement for creative types should return only two results:
banner
island

But mine returns:
banner
island
banner
island
banner
island

It returns unique types for creatives with the same parent but ignores other campaigns.

I hope this is clear. I need a select statement that will return the proper result as shown above. Can anyone help?


 
Old April 19th, 2006, 07:15 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In 2.0 of course you can simply use the distinct-values() function.

In 1.0, try

portfolio/campaign/creative/@creative_type[not(. = ../preceding::creative/@creative-type)]

or for better performance, use Muenchian grouping.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 19th, 2006, 08:17 AM
Registered User
 
Join Date: Feb 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that worked perfect.

portfolio/campaign/creative/@creative_type[not(. = ../preceding::creative/@creative_type)]






Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
select statement help RinoDM SQL Server 2000 2 January 16th, 2007 11:35 AM
syntax of xsl:if statement EstherMStrom XSLT 3 February 14th, 2005 05:47 PM
Select statement Sarju Mehta SQL Server 2000 1 March 30th, 2004 03:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.