Using wildcards in xsl select

Posted on 2006-05-12
Last Modified: 2012-05-07
I am trying to create an XSL file that limits the output based on part of one field.  While I understand that you can do this using XML, I have yet to find exactly the correct syntax.  If someone could provide a link / sample code on how to do this, it would be greatly appreciated!

Question by:nwcc_seattle
    LVL 26

    Expert Comment

    There are a lot of ways to accomplish this, but as an example, let's say you want an element that contains the first 5 characters in element myField:

    <xsl:apply-templates select="/Some/Path/Here[contains(substring(myField, 1, 5))]"/>

    You can make it case insensitive with the translate() function:

    translate(myField, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")

    For a dynamic filtering and sorting example:

    Mike Sharp
    LVL 1

    Author Comment

    That looks great, but I am trying to do a hard code version (not based on what people type in)....   I;m trying to start simple with this.

    the code I have so far is

    <xsl:for-each select="xml element name goes here">
    I know something relating to the contain function goes at the end, but I don't know what....

    Any suggestions?

    LVL 26

    Accepted Solution

    I guess I don't see what it is you're trying to accomplish.  You need to post some sample XML, and what you'd like to see output.  

    If you can't post something specific (for whatever reason), I have tons of examples of various XML/XSLT on my site at  

    Mike Sharp
    LVL 1

    Author Comment

    Worked great!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
    Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now