There seems to be some mistake in your template
<xsl:template match="//opt"> .. You don't need //opt
(it works; but is redundant; and probably
inefficient). You need <xsl:template match="opt"> .
Also it should'nt be: substring-before(//opt,'|') . It
should be substring-before(.,'|') ..
Following is the modified stylesheet.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:template match="/root">
<html>
<head>
<title/>
</head>
<body>
<xsl:apply-templates select="opt" />
</body>
</html>
</xsl:template>
<xsl:template match="opt">
<font color="black">
<xsl:variable name="stringfirst">
<xsl:value-of select="substring-before(.,'|')"/>
</xsl:variable>
<xsl:value-of select="$stringfirst"/>
</font>
<font color="red">
<xsl:variable name="stringmid">
<xsl:value-of
select="substring-after(substring-before(.,'\'),'|')"
/>
</xsl:variable>
<xsl:value-of select="$stringmid"/>
</font>
<font color="black">
<xsl:variable name="stringlast">
<xsl:value-of select="substring-after(.,'\')"/>
</xsl:variable>
<xsl:value-of select="$stringlast"/>
</font>
</xsl:template>
</xsl:stylesheet>
The XML file is -
<?xml version="1.0" encoding="UTF-8"?>
<root>
<opt mgif1="hai" mgif="" voiceover="" >Rani Lakshmi
Bai |test1\ Nana Saheb</opt>
<opt mgif1="" mgif="" voiceover="" >Nana Saheb
|test2\ Maruthu Brothers</opt>
<opt mgif1="" mgif="" voiceover="" >Maruthu Brothers
|test3\ Tantia Tope</opt>
</root>
(I have enclosed the XML in <root> tag, to make it
well formed).
Regards,
Mukul
--- T UmaShankari <umashankari(_at_)lantana(_dot_)tenet(_dot_)res(_dot_)in>
wrote:
Hello,
I am new to this..
I have a set of statements like this..
<opt mgif1="hai" mgif="" voiceover="" >Rani
Lakshmi Bai |test1\ Nana
Saheb</opt>
<opt mgif1="" mgif="" voiceover="" >Nana Saheb
|test2\ Maruthu Brothers</opt>
<opt mgif1="" mgif="" voiceover="" >Maruthu
Brothers |test3\ Tantia
Tope</opt>
I need to display the contents which is inside the
|to\ in different color. i
have used this code for doing that..
<xsl:template match="//opt">
<font color="black">
<xsl:variable name="stringfirst">
<xsl:value-of select="substring-before(//opt,'|')"/>
</xsl:variable>
<xsl:value-of select="$stringfirst"/>
</font>
<font color="red">
<xsl:variable name="stringmid">
<xsl:value-of
select="substring-after(substring-before(//opt,'\'),'|')"
/>
</xsl:variable>
<xsl:value-of select="$stringmid"/>
</font>
<font color="black">
<xsl:variable name="stringlast">
<xsl:value-of select="substring-after(//opt,'\')"/>
</xsl:variable>
<xsl:value-of select="$stringlast"/>
</font>
but it is displaying the o/p like this..
statement1 option1 statement1
statement1 option1 statement1
It is not going to the second statement. Can any one
plese tell me how to do
this ?
Regards,
Uma
--~------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--