• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

if else if check it please.

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all ,
I need coditional decesion in xsl can any one help
i have
<s>
<p>1</p>
<q>Message</q>
</s>
Requirement is .
if <p>is 1.
print
message in <q>
else print "No message".

Regards .
Awais bajwa

 
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can use XSL Conditional Choose.
Here it is :
<xsl:choose>
<xsl:when test=".[p='1']">
<xsl:value-of select="q"/>
</xsl:when>
<xsl therwise>
NO Message
</xsl therwise>
</xsl:choose>
Hope this helps.
Thanks.

------------------
L Goundalkar
lggoundalkar@hotmail.com
Sun Certified Programmer for Java 2 Platform
[This message has been edited by L Goundalkar (edited August 23, 2001).]
 
Awais Bajwa
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THanks a lot sir ,
But I have an error when I transform this in SPY 3.5.
my xml file is
<?xml version="1.0" encoding="UTF-8"?>
<?xml:stylesheet type="text/xsl" href="choose.xsl" ?>
<s>
<p>1</p>
<q>Message</q>
</s>
and xsl file is .
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:choose>
<xsl:when test=".[p='1']">
<xsl:value-of select="q"/>
</xsl:when>
<xsl therwise>
NO Message
</xsl therwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

and the error is
"XSL transformation failer due to the following error.
Expected token 'eof' found'['.
.-->[<--p='1']"

Regards
Awais Bajwa
 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I just checked the code in my IE 5.0.
I found following changes to be made to XSL:
Please implement it.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<xsl:for-each select="s">
<xsl:choose>
<xsl:when test=".[p='1']">
<xsl:value-of select="q"/>
</xsl:when>
<xsl:otherwise>
NO Message
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Changes Made:
1.Namespace attribute.
2.Introduction of for loop else use can use s/p and s/q respectively.
I have checked it in IE and it works fine.
Thanks.

------------------
L Goundalkar
lggoundalkar@hotmail.com
Sun Certified Programmer for Java 2 Platform
 
reply
    Bookmark Topic Watch Topic
  • New Topic