473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

using wildcards in a select

I'm trying to develop a stylesheet that takes a parameter that is used
to filter the results. It works great *except* for the fact that I
want one of my options to be a "See All", removing any filters.

I was hoping that I could do this by setting a parameter to default to
* and then removing the parameter when the user tries to see all. It
doesn't work though.

Here's what I have:
<xsl:param name="year_filter" select="*"/>
<xsl:template match="data">
....
<xsl:for-each select="holiday_list/row[year=$year_filter]">
<xsl:variable name="description" select="description"/>
....
</tr>
</xsl:for-each>

The following works:

<xsl:for-each select="holiday_list/row[year=*]">
<xsl:variable name="description" select="description"/>
....
</tr>
</xsl:for-each>

but I can't figure out how to get year_filter to equal '*'. The
problem with the first example is clear when I display the value of
$year_filter. It shows a concatenated list of all of my data.

I'm an xslt beginner, so if this is a stupid question, I beg your
forgiveness and patience!

TIA, Charles
Mar 9 '08 #1
2 2901
Heltende wrote:
I'm trying to develop a stylesheet that takes a parameter that is used
to filter the results. It works great *except* for the fact that I
want one of my options to be a "See All", removing any filters.

I was hoping that I could do this by setting a parameter to default to
* and then removing the parameter when the user tries to see all. It
doesn't work though.

Here's what I have:
<xsl:param name="year_filter" select="*"/>
<xsl:template match="data">
...
<xsl:for-each select="holiday_list/row[year=$year_filter]">
<xsl:variable name="description" select="description"/>
...
</tr>
</xsl:for-each>

The following works:

<xsl:for-each select="holiday_list/row[year=*]">
<xsl:variable name="description" select="description"/>
...
</tr>
</xsl:for-each>

but I can't figure out how to get year_filter to equal '*'. The
problem with the first example is clear when I display the value of
$year_filter. It shows a concatenated list of all of my data.
You might want to set the parameter to an empty string (or the number 0)
to indicate you don't want to filter and then code e.g.
<xsl:template match="data">
<xsl:choose>
<xsl:when test="$year-filter">
<xsl:for-each select="holiday_list/row[year=$year_filter]">
...
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="holiday_list/row">
...
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
If you have a lot of code inside of the for-each then write a named
template and call that in the for-each to avoid code duplication.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 9 '08 #2
>
You might want to set the parameter to an empty string (or the number 0)
to indicate you don't want to filter and then code e.g.
<xsl:template match="data">
<xsl:choose>
<xsl:when test="$year-filter">
<xsl:for-each select="holiday_list/row[year=$year_filter]">
...
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="holiday_list/row">
...
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
If you have a lot of code inside of the for-each then write a named
template and call that in the for-each to avoid code duplication.

--

Martin Honnen
http://JavaScript.FAQTs.com/


Thank you for the rapid response! That code does indeed work. It
doesn't necessarily "feel" like the most elegant method, but given
that the "*" seems to have a mind of it's own, depending on context, I
guess it's the method I'm stuck with! Now to explore the exciting
world of including named templates!
Mar 9 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Robert Brown | last post by:
If I use _reverse_ wildcard search will it always result in a table scan? Is it possible to get the DB (Oracle or SQL server) to use indexes when doing reverse wildcard match? let's say I have:...
4
by: Evil Bert | last post by:
Is there anyway to compare a field with multiple string values using LIKE? Here's the statement I have now: SELECT * FROM list WHERE email LIKE CONVERT( _utf8 'hotmail@hotmail.com' USING latin1...
2
by: hedrew3 | last post by:
I have a query in of the form "select * from mytable where myfield is like '*ABC*' or like '*DEF*' or like "*GHI*'". The problem is that the list of items is growing, and I would like to place...
2
by: Alex | last post by:
Hi all, I'm trying a very simple Like statement in MS Access XP, but it's acting strange. I've always used a percent (%) for wildcards in MS SQL, and I thought this was the same in MS Access......
10
by: Alvaro Puente | last post by:
Hi all! Do any of you know if wildcards are accepted when calling rename() function? Thanks/Alvaro
2
by: Dennis | last post by:
I am trying to implement a "Find and Replace" dialog that allows using wildcards in the find string, much like the Find and Replace Dialogs in Ms Word, etc. Are there any references or examples on...
2
by: Anandan | last post by:
Hi, In our Project we use Dataset to load the Grid with Values. We have some criteria to filter the values to be shown in the Grid. For that we used the SELECT command to filter the Same...
3
by: cyber0ne | last post by:
My use of wildcards thus far has been limited to matching a given string anywhere in a column as follows: SELECT * FROM Table WHERE Column LIKE '%string%' However, I'm wondering if there's a...
1
by: jwebber | last post by:
I have a database in MS Access for a community calendar. It has a dropdown list from which to select a particular type of event, Art, Music, etc. The list works correctly for displaying the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.