[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xsl string comparison fails why?

Subject: xsl string comparison fails why?
From: Geoff <ghank@xxxxxxxxxxx>
Date: 25 Sep 2002 08:38:14 -0500
xsl string
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.