Subject: Re: [xsl] How to do this in xsl From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx> Date: Sun, 27 Mar 2005 00:29:57 -0800 (PST) |
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@xxxxxxxxxxxxxxxxxxxx> 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 > > __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to do this in xsl, T UmaShankari | Thread | RE: [xsl] How to do this in xsl, cknell |
[xsl] How to do this in xsl, T UmaShankari | Date | RE: [xsl] check for-each if a chil, Stuart Brown |
Month |