• 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

substring function

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear friends
If I have a variable called file="c:/programs/dominoes/ch_n_tomato.xml#xpointer(//one/two/three)". The question is using subtring or something else, is it possible to return just the file name, not path or the xpointer stuff. just a string as filename="ch_n_tomato.xml". I would like to stress that, we can not test for dominoes/ as one argument of substring(..,..) function-set. The point I am making is goint through the file value, return everything between last "/" and "#".
Thanks in advance
Nilesh
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to use a recursive template to do something like the lastIndexOf method of the String Java class.
The solution to your problem is explained there:
http://www.biglist.com/lists/xsl-list/archives/200102/msg00838.html
This should solve your problem.
Christophe
 
NILESH PATEL
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much for your reply, it works but slight problem, which i posted on XSL-List news group. Everything is ok apart from contains(..,..) function. contains function only works with string representation and not $char representation. don't know whether it is something to do with xalan or else.
Basically,
<xsl:if test="contains($string, $char)".... returns false, whereas,
<xsl:if test="contains($string, "/") returns true.
Please have look at it for me and let me know if you find the same.

Thanks
Nilesh.
 
NILESH PATEL
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have got the answer to this problem now, with the help XSL-List news group. I was supposed to write <xsl:with-param name="char" select="'/'">
then it works fine
Thanks anyway.
Nilesh Patel
 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic