[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: testing strings
Bill Abbas <babbas@xxxxxxxxxx> writes: > Pretty basic question about how to handle strings. If I have an element in > XML like so > > <Whatever> > <Choice> > true > </Choice> > </Whatever> > > And I want to output one of two values, depending on whether the Choice > element is true or false. > > The following transform doesn't seem to do the trick. > > <xsl:template match="Whatever"> > <xsl:choose> > <xsl:when test="{Choice}='true')"> > Choice is true > </xsl:when> > <xsl:otherwise> > Choice is false > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > What is the proper syntax for a test to compare strings? Thanks. I would rather do this way: <Whatever> <true/> </Whatever> or <Whatever> </Whatever> if not true. Yu could perform the test this way: <xsl:template match="Whatever"> <xsl:choose> <xsl:when test="true"> Choice is true </xsl:when> <xsl:otherwise> Choice is false </xsl:otherwise> </xsl:choose> </xsl:template> This is more readable and efficient in my opinion. -- Michel CASABIANCA mailto:casa@xxxxxx http://www.sdv.fr/pages/casa XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|