Using | with multiple attribute values

Subject: Using | with multiple attribute values
From: Ross Bleakney <rossb@xxxxxxx>
Date: Tue, 23 Nov 1999 15:24:24 -0800
Hello,
Given the following XML snippet:
<Records>
	<Record name="John">
</Records>

I would like to output "Smith" if the "name" attribute is "John" or "Joe". I
can do this with this XSL snippet:

<xsl:for-each select="Records/Record">
	<xsl:if test="@name='John'">Smith</xsl:if>  
	<xsl:if test="@name='Joe'">Smith</xsl:if>  
</xsl:for-each>

However, I would like to use a compound conditional and do this in one line.
I have tried this:
	<xsl:if test="@name='John|Joe'">Smith</xsl:if>  
But that doesn't work.

I have also tried this:
	<xsl:if test="@name='John'|'Joe'">Smith</xsl:if>  
or this:
	<xsl:if test="@name='John'|@name='Joe'">Smith</xsl:if>  

In both of these cases, the parser I am using (Lotus XSL with XML4J)
crashes. If this is a flaw in LotusXSL then it is not meant as a criticism.
I realize that the product is pre-Beta ("Developer Preview") and this is the
first problem I have had with it. 

Is LotusXSL simply failing with my correct syntax? If so, can anyone think
of an alternative work-around? If not, is there a better way of doing this?

Thanks,
Ross


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


Current Thread