Results 1 to 4 of 4

Thread: xsl wildcard asterisk paramter

  1. #1
    Join Date
    Jul 2003

    xsl wildcard asterisk paramter

    I'm passing a variable from an asp page to an xsl page. Let's call the variable strProject. Depending on the situtation, that will be some word or phrase like "Lab Project" or it will be nothing at all. When it is nothing, I set it equal to an asterisk like this:

    strProject = "*"

    I pass it to the xsl page as a parameter:
    <xsl: param name="strProject "></xsl: param>

    I set it to an asterisk b/c I want to use that as a wildcard when searching through xml nodes on the xsl page.
    The xsl code looks like this:
    <xsl:for-each select="PROJECT[Project = $strProject ]">

    So, when strProject = *, I want the xsl page to see it like this:
    <xsl:for-each select="PROJECT[Project = *]">

    However, I believe it's being seen as this:
    <xsl:for-each select="PROJECT[Project = '*' ]">
    ...as text with the apostrophes and not just as a plain asterisk.

    If I hard code the asterisk into the xsl page, it works.

    Anyone know to make the xsl page see it as just an asterisk??


  2. #2
    Join Date
    Dec 2002
    Calgary, Canada
    I could be getting at wrong conclusion ut here is what the strProject looks like
    strProject = *, I want the xsl page to see it like this:

    and then I am presuming that you parse it get only "*" from it and then you enter that in the code here

    <xsl:for-each select="PROJECT[Project = $asterVar]">


    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Jul 2003
    Let me just try to reconfirm what I meant...and I'll change the variable names a little b/c it may have been confusing the way I had it before.

    Basically, strDept = *

    ...and that's how I want it to be parsed on the xsl page. But it appears to be parsed like this:

    strDept = ' * '

    ....with the apostrophes

    The xsl code is this:

    <xsl:for-each select="PROJECT[DEPT = $strDept]">

    ...and therefore it will return all PROJECT elements with a DEPT element (reagardless of the DEPT element content) b/c the asterisk alone is a wildcard. But the asterisk surrounded by apostrophes it just text of an asterisk and does not act as a wildcard. I need it to act as a wildcard.

  4. #4
    Join Date
    Oct 2006
    I have this very same problem...

    I'm creating a CD of walks in a National Park, my page has several dropdown options and i want the user to be able to search the xml based on any number of the dropdowns, to limit the returned walks.

    my xsl filter page accepts the values, with a default of *

    if i hard code the line with one of the variables with a * it works fine searching on the other. <xsl:for-each select="WITP/walk[length=$length and category=*" >

    XSL Filter Code:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl: output method="xml"/>

    <!-- Variables -->
    <xsl: param name="length" select="*"/>
    <xsl: param name="type" select="*"/>

    <xsl:template match="/">

    <xsl:for-each select="WITP/walk[length=$length and category=$type]" >

    <xsl:sort select="title" order="ascending" />

    <xsl:for-each select="*" >
    <xsl:element name='{name()}'> <xsl:value-of select="."/></xsl:element>


    <xsl:template match="WITP">


    an example of the XML is

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <category>Wheelchair & Easy Access Walk</category>
    <title>Aber Mawr</title>
    <description>Short surfaced path to viewpoint over magnificent beach. One gate with figure-of-four latch. Nearest toilets at Trefin.
    Wheelchair 30m.</description>
    <Character>Surfaced path with one gate</Character>
    <Transport>Strumble Shuttle (NOT wheelchair accessible)</Transport>

    Thanks for ANY help


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center