Re: A simple xsl:if question from a newbie

Subject: Re: A simple xsl:if question from a newbie
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 19 Jul 2000 13:33:57 GMT
> My XML-file looks somthing like this
I hope it's just your example but:
<ROW id=0>
isn't well formed (missing quotes around the attribute value)
Also if id were of type ID (specified in a DTD) you couldn't have
start its value with a digit.

However ignoring that,

	<xsl:if test="substring(Starttime, 1, 10) = {Time}"> 

The {} is a syntax error, if you miss them out you get

	<xsl:if test="substring(Starttime, 1, 10) = Time"> 

which is valid but would test against a Time child of the current ROW
element, what you actually want is

	<xsl:if test="substring(Starttime, 1, 10) = /page/Time"> 

except that your substring indexes are wrong as the first character
in all your StartTime examples, and your Time example, is a newline
not the first digit.

So probably you want


	<xsl:if test="contains(Starttime, normalize-space(/page/Time))"> 

which should probably be optimised by sticking
<xsl:variable name="time" select="normalize-space(/page/Time)"/>
at the top level of your stylesheet, then

<xsl:if test="contains(Starttime, $time">


David


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


Current Thread