1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Rep Power

    Searching for text elements and inexact matches with XSL

    I'm writing a basic XSL to search through a XML file that reads like this;

        <cbo_name>Alianza Dominicana, Inc.</cbo_name>
        <cbo_address>2410 Amsterdam Avenue, 4th Fl</cbo_address>
        <cbo_city>New York</cbo_city>
        <cbo_name>Asociaciones Dominicanas, Inc</cbo_name>
        <cbo_address>202 Union Avenue, 2, L&amp;M</cbo_address>
    The XSL is;

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="test.xsl"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="CBO"/>
    <xsl:template match="/">
        <table border="1">
          <tr bgcolor="#9acd32">
      <xsl:for-each select="dycd_bridge/contracts_datastore/cbo_list/cbo[node()=$CBO]">
            <td><xsl:value-of select="cbo_id"/></td>
            <td><xsl:value-of select="cbo_name"/></td>
            <td><xsl:value-of select="cbo_address"/></td>
            <td><xsl:value-of select="cbo_city"/></td>
            <td><xsl:value-of select="cbo_state"/></td>
            <td><xsl:value-of select="cbo_zip"/></td>
    Basically, the user searches via a standard HTML search box that then passes the parameters to the XSL. The problem is, the XSL will only return results if an exact match is found, and it won't even process the search if alphabetic characters are present. How do I fix this?
  2. #2
  3. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    XSLT is not a search engine. If you want one then use something else.

    For the alphanumeric problem, put quotes around the search term.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Rep Power
    Yeah, didn't think it'd be that easy. New idea; the page that, as of now, parses the XML into HTML format uses the following script:

    type: "GET",
    url: "cbo_list.xml",
    dataType: "xml",
    success: function(xml) {
    var Counter = 0;

    var cboID = $(this).find('cbo_id').text();
    var cboName = $(this).find('cbo_name').text();
    var cboAddress = $(this).find('cbo_address').text();
    var cboCity = $(this).find('cbo_city').text();
    var cboState = $(this).find('cbo_state').text();
    var cboZip = $(this).find('cbo_zip').text();
    var cboDisplayName = cboName;
    if (cboName.length >= 30) {
    cboDisplayName = cboName.substring(0, 30) + '...';

    $('<div class="items" id="link_' + cboID +'"></div>').html('<a href="cboDetail.html?cboID=' + cboID + '">' + cboDisplayName + '</a>').appendTo('#page-wrap');
    $('<div class="cboAddress"></div>').html(cboAddress).appendTo('#page-wrap');
    $('<div class="cboAddress"></div>').html(cboCity + ', ' + cboState + '. ' + cboZip).appendTo('#page-wrap');

    function SettingsForm() {
    document.location = 'settings.html';
    How best to edit this so that it displays the data based on user-defined variables?

IMN logo majestic logo threadwatch logo seochat tools logo