This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

xsl string comparison fails why?


I am passing a parameter to an xslt template and trying to use that
parameter in an if comparison but it evaluates to false when it appears
it should be true.

The parameter is taken from an html form select box as so:
<select name='state'>
	<option value='' selected='yes'></option>
	<option value="Alabama">Alabama</option>
	<option value="Alaska">Alaska</option>
	<option value="Arizona">Arizona</option>
	<option value="Arkansas">Arkansas</option>
</select>

Then the parameter is passed via php to the xslt template like this (in
case this is relevant but it probably isn't):
<?php
	$xmlfile= $_POST['catID'] . '.xml';
	$xslfile= $_POST['catID'] . '.xsl';
	$args = array();
	$params["state"] = $_POST['state']; 
	// create XSLT processor 
	$xh = xslt_create();

	// call xslt processor
	// Process the document
	$result = xslt_process($xh, $xmlfile, $xslfile, NULL, $args, $params); 
	if ($result) {
		print $result;
	}
	
	xslt_free($xh);


?>

Then Given this xml:
<?xml version="1.0" encoding="UTF-8"?>
<admissions>
 <state>Alabama
  <statelink
  href="http://www.alabar.org/page.cfm?view=3&amp;subgroup=main";>
  Bar Admissions Information</statelink>
  </state>

  <state>Alaska 
  <statelink href="http://www.alaskabar.org/index.cfm?ID=5362";>
  Admissions</statelink>
  </state>

  <state>Arizona 
  <statelink href="http://www.supreme.state.az.us/admis/";>
  Admissions Unit of the Certification &amp; Licensing
  Division</statelink>
  </state>
	
  </state>
</admissions>

Then I am trying to find the value of the parameter (a state) and print
only that state to the browser> I am trying to do this like this:
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" indent="yes"/>
<xsl:param name="state" />
<xsl:template match="/">
<html>
<head>
<body bgcolor="#FFFFFF">
	<xsl:for-each select="admissions/state/text()">
		<xsl:if test=".=$state">
			<xsl:value-of select="."/>
		</xsl:if>
	</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

The if never evalutes to true even if it is testing Alabama=Alabama.
I can print the value of the parameter using <xsl:value-of
select="$state"/> just fine

Any hints/suggestions?



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]