Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 19th, 2006, 07:43 AM
Registered User
 
Join Date: Feb 2006
Location: , , Ireland.
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?


Reply With Quote
  #2 (permalink)  
Old April 19th, 2006, 08:15 AM
mhkay's Avatar
Wrox Author
Points: 18,280, Level: 58
Points: 18,280, Level: 58 Points: 18,280, Level: 58 Points: 18,280, Level: 58
Activity: 33%
Activity: 33% Activity: 33% Activity: 33%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,934
Thanks: 0
Thanked 282 Times in 277 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
Reply With Quote
  #3 (permalink)  
Old April 19th, 2006, 09:17 AM
Registered User
 
Join Date: Feb 2006
Location: , , Ireland.
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)]

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 08:23 PM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 05: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



All times are GMT -4. The time now is 10:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.