[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to do this in xsl

Subject: Re: How to do this in xsl
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Sun, 27 Mar 2005 00:29:57 -0800 (PST)
tantia tope
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.