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 February 10th, 2006, 02:48 PM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default for each select

Can someone tell me how to select where the subgroup starts with a letter OR a character? To be specific, the character is ##. Right now I have:

<xsl:for-each select="/hw.list/list.subgroup[@letter=starts-with(@letter,$gpLETTER)]">

and it selects everything that starts with a letter, but in some cases I have a subgroup at the beginning that starts with ##.

Much appreciated!
 
Old February 10th, 2006, 03:26 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<xsl:for-each select="/hw.list/list.subgroup[@letter=starts-with(@letter,$gpLETTER)]">

I'm sure you don't mean this, starts-with() returns a boolean and comparing that with the attribute is going to give nonsense. I'm sure you meant to write

<xsl:for-each select="/hw.list/list.subgroup[starts-with(@letter,$gpLETTER)]">

If you're in XSLT 1.0 and can't use regular expressions then the simplest is to write "or":

 <xsl:for-each select="/hw.list/list.subgroup[starts-with(@letter,$gpLETTER) or
starts-with(@letter,'##']">



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 10th, 2006, 03:38 PM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, at the top of my page I have:
<xsl:param name="gpLETTER" select="''"/>
<xsl:variable name="letter" select="normalize-space($gpLETTER)"/>
Then I have:
<xsl:for-each select="/hw.list/list.subgroup[@letter=starts-with(@letter,$gpLETTER)]">

anyway, I am totally new to this and trying to edit someone else's code :-) So, I have added this:

<xsl:for-each select="/hw.list/list.subgroup[@letter=starts-with(@letter,$gpLETTER) OR @letter=starts-with(@letter,'##']">

My page returns and error that says there is an invalid token in that line. I appreciate your help.


 
Old February 10th, 2006, 05:30 PM
Authorized User
 
Join Date: Nov 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jkmyoung
Default

<xsl:for-each select="/hw.list/list.subgroup[starts-with(@letter,$letter) or starts-with(@letter,'##')]">

You're missing a closing parenthesis ')'

 
Old February 10th, 2006, 07:16 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Then I have:
<xsl:for-each select="/hw.list/list.subgroup[@letter=starts-with(@letter,$gpLETTER)]">

This is garbage, though I think it might just work by accident: the rules for comparing a node-set to a boolean are pretty strange (and they change in 2.0, because no-one thought anyone would seriously want to do it). I'm sure you want

select="/hw.list/list.subgroup[starts-with(@letter,$gpLETTER)]">

So, I have added this:

<xsl:for-each select="/hw.list/list.subgroup[@letter=starts-with(@letter,$gpLETTER) OR @letter=starts-with(@letter,'##']">

XPath, like XML, is case-sensitive. When I wrote "or", I meant "or", I didn't mean "OR".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Select row in GridView WITHOUT using Select button rao965 ASP.NET 2.0 Professional 1 February 15th, 2008 10:44 AM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
select="node1", select="node2"... Baldo XSLT 7 March 12th, 2004 10:38 AM
Select Within A Select Problem vinyl-junkie Classic ASP Databases 6 June 7th, 2003 04:31 PM





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