Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

choose problem

Status
Not open for further replies.

davikokar

Technical User
May 13, 2004
523
IT
Hallo,

I have a very basic xml file and a correspondent xsl file. How would like to use the choose expression in order to check if the content is = to a certain string. The result I get it is always based on the "otherwise" part, even when in fact I would expect that the expression in my choose would return a true value.

Here the two files:

xml
Code:
<chat>
	<chatinput>
		<speaker>BoxBrain</speaker>
		<text>Don't understand you</text>
	</chatinput>
	<chatinput>
		<speaker>Administrator</speaker>
		<text>Compile</text>
	</chatinput>
	<chatinput>
		<speaker>BoxBrain</speaker>
		<text>Don't understand you</text>
	</chatinput>
	<chatinput>
		<speaker>Administrator</speaker>
		<text>Compile</text>
	</chatinput>
	<chatinput>
		<speaker>BoxBrain</speaker>
		<text>Don't understand you</text>
	</chatinput>
</chat>

xls
Code:
<html xsl:version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
	<body>
		<xsl:for-each select="chat/chatinput">
			<xsl:choose>
				<xsl:when test="speaker = BoxBrain">
					<div style="background-color:yellow;color:white;padding:4px">
						<span style="font-weight:bold">
							<xsl:value-of select="speaker"/>
						</span>
      				</div>
      				<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
        				<xsl:value-of select="text"/>
      				</div>
  				</xsl:when>
  				<xsl:otherwise>
      				<div style="background-color:red;color:white;padding:4px">
        				<span style="font-weight:bold">
        					<xsl:value-of select="speaker"/>
        				</span>
      				</div>
      				<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
        				<xsl:value-of select="text"/>
      				</div>
  				</xsl:otherwise>
			</xsl:choose>
    	</xsl:for-each>
  	</body>
</html>

Am I missing something
 
><xsl:when test="speaker = BoxBrain">
[tt]<xsl:when test="speaker = [red]'[/red]BoxBrain[red]'[/red]">[/tt]
 
thanks... I tried many things but not that one!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top