[xsl] filtering XML file using starts-with

Subject: [xsl] filtering XML file using starts-with
From: "Dan" <dan@xxxxxxxxxxxxxxx>
Date: Thu, 18 Dec 2003 08:06:14 -0600
I have an XML file with a very simple tree structure but many many rows of data.  I need to be able to filter this file based on the first few characters of one field (Module) such that if the filter criteria is 10 all rows where module is 10 or 101 or 1034 or 105673 etc etc are returned.  I think I can do with this with the starts-with function, but I am not sure how ot include this criteria in my match statement?  Here is the XSL file I am using, any suggestions are greatly appreciated.  Also, any recomendations ona good reference book or site fo this kind of thing would be a huge help.  Thanx.


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<!--Declare Variables -->
<xsl:param name="OrderedBy" select="'Module'"/>
<xsl:param name="OrderedType" select="'ascending'"/>
<xsl:param name="sModule" select="''"/>
<xsl:param name="sIncumbentID" select="''"/>
<xsl:param name="sMember" select="''"/>
<xsl:param name="sApproval" select="''"/>
<xsl:param name="sInputType" select="''"/> 

<xsl:template match="/">
	<xsl:starts-with(Module, $sModule)>
	<xsl:for-each select="Sales/Summary">
	<xsl:sort select="*[name()=$OrderedBy]" order="{$OrderedType}" data-type="text"/>
	<tr>
	  <td><xsl:value-of select="Employee"/><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:value-of select="Module"/><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:text>&#x24;</xsl:text><xsl:value-of select="format-number (ResignTotalQuota, '###,###,###,###.00')" /><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:text>&#x24;</xsl:text><xsl:value-of select="format-number (ResignTotalObjective, '###,###,###,###.00')" /><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:value-of select="PercentResignTotal"/>%</td>
	  <td><xsl:text>&#x24;</xsl:text><xsl:value-of select="format-number (NewTotalQuota, '###,###,###,###.00')" /><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:text>&#x24;</xsl:text><xsl:value-of select="format-number (NewTotalObjective, '###,###,###,###.00')" /><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:value-of select="PercentNewTotal"/>%</td>
	  <td><xsl:text>&#x24;</xsl:text><xsl:value-of select="format-number (StrategicTotalQuota, '###,###,###,###.00')" /><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:text>&#x24;</xsl:text><xsl:value-of select="format-number (StrategicTotalObjective, '###,###,###,###.00')" /><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:value-of select="PercentStrategicTotal"/>%</td>
	  <td><xsl:text>&#x24;</xsl:text><xsl:value-of select="format-number (TotalTotalQuota, '###,###,###,###.00')" /><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:text>&#x24;</xsl:text><xsl:value-of select="format-number (TotalTotalObjective, '###,###,###,###.00')" /><xsl:text>&#xA0;</xsl:text></td>
	  <td><xsl:value-of select="PercentTotalTotal"/>%</td>
	</tr>
	</xsl:for-each>
	<tr>
		<td colspan="20" border="0"><xsl:value-of select="count(ServiceOrder)"/></td>
	</tr>
</xsl:template></xsl:stylesheet>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread