Hello,
I have an XML file of city, state and ZIP codes, and an HTML form where the
user can input a full or partial ZIP code (param1). I'm trying to use <choose>
to return a list of matching ZIP codes.
The first "when" section checks to see if any ZIP_CD is an exact match for
param1. It works fine.
The second "when" section is supposed to check to see if any ZIP_CD *starts
with* param1. BUT I can't get it to work. Instead, it returns a list of all ZIP
codes in the file. I wondered if this was because they were numbers, so I tried
converting them with string(), which didn't work, and then number() (getting
desperate) which also didn't work. I even tried translate(), translating the
numbers to letters, but that also didn't work.
The "otherwise" section also fine--if I input a non-existent ZIP code, I get
the "no matches found" message.
How can I get the second "when" to pull a list of ZIP codes that start with
param1?
Thanks in advance!
Kathryn
<xsl:choose>
<xsl:when test="//POINT_RECORDS/POINT_REC/ZIP_CD=$param1">
<TABLE border="0" width="90%" style="font-size: 10pt" cellspacing="1"
cellpadding="1">
<tr>
<th><b>City</b></th>
<th><b>State</b></th>
</tr>
<xsl:for-each select="//POINT_RECORDS/POINT_REC[ZIP_CD=$param1]">
<xsl:sort select="CITY_NM"/>
<tr>
<td style="font-size:8pt" valign="top">
<xsl:value-of select="CITY_NM"/>
</td>
<td style="font-size:8pt" valign="top">
<xsl:value-of select="STATE_CD"/>
</td>
</tr>
</xsl:for-each>
</TABLE>
</xsl:when>
***** THIS PART DOES NOT WORK*********
<xsl:when test="//POINT_RECORDS/POINT_REC[starts-with(ZIP_CD, $param1)]">
<TABLE border="0" width="90%" style="font-size: 10pt" cellspacing="1"
cellpadding="1">
<tr>
<th><b>City</b></th>
<th><b>State</b></th>
<th><b>State</b></th>
</tr>
<xsl:for-each select="//POINT_RECORDS/POINT_REC">
<xsl:sort select="ZIP_CD"/>
<tr>
<td style="font-size:8pt" valign="top">
<xsl:value-of select="CITY_NM"/>
</td>
<td style="font-size:8pt" valign="top">
<xsl:value-of select="STATE_CD"/>
</td>
<td style="font-size:8pt" valign="top">
<xsl:value-of select="ZIP_CD"/>
</td>
</tr>
</xsl:for-each>
</TABLE>
</xsl:when>
<xsl:otherwise>
<p align="center">(No matches found)</p>
</xsl:otherwise>
</xsl:choose>
**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list