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

RE: Taking string out from the long string

Subject: RE: Taking string out from the long string
From: Jarno.Elovirta@xxxxxxxxx
Date: Thu, 25 Jul 2002 15:12:39 +0300
string out
Hi,

> i want to abstract just the file name from any image file
> but not getting it correctly.
> during conversion of html to wml when i am fetching the page i am 
> converting the .jif or .jpg or whatever image file  into .wbmp 
> format and storing them in  a folder.
> and in <xsl:template match="img">
> what i want to do is that first i want to take the *src* of the 
> img tag in html file (which is now well formed xhtml as i am using 
> tidy to make them xhtml).which i think i can do by declaring a 
> variable and then variable = {@src}(i think it will work)then i 
> want to take the string after the last slash(/) in the src which 
> is the name of the image file (like src="dir/image.gif") this can 
> be done by string = substring-after(string, substring) but the 
> problem is that what to do if src is like /images/dir/image.gif 
> how can i tell that the string after the last slash is to be 
> taken.
> and after that what i want to do is want to take the file name 
> before the extension like if file name is images.gif then i want 
> to take only images (which i think can be done by substring-before  
> then i want to add the extension .wbmp to that file (which i think 
> can be done by concat(images,.,wbmp) then i am creating an element 
> <img and in @src giving the path to my folder containing images as 
> they are saved with the same name just having extension .wbmp.

To tell you the truth, I had a really hard time in parsing you message, since it seemed to be single sentence all lower-case, but it this what you were after

<xsl:template match="html:img">
  <img>
    <xsl:attribute name="src">
      <xsl:value-of select="$myfolder" />
      <xsl:call-template name="image">
        <xsl:with-param name="path" select="@src" />
      </xsl:call-template>
    </xsl:attribute>
  </img>
</xsl:template>

<xsl:template name="image">
  <xsl:param name="path" />

  <xsl:choose>
    <xsl:when test="contains($path, '/')">
      <xsl:call-template name="image">
        <xsl:with-param name="path" select="substring-after($path, '/')" />
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="concat(substring-before($path, '.'),'.wbmp')" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Cheers,

Jarno

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.