Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Need help with Substring

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
select=substring("SubString",1,1)//s
select=substring("SubString",1,2)//u

how do I get the desired out(indicated by the comments)..I am running out of ideas, ben tryaying different things but It does nt work. what can i do to get character one by one
 
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would it be a good guess to say that you are asking about XPath?

Even if that's a correct guess, it would help to have more details about the context of your question.
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Explain your question by example..not clearly understanding
 
vuthlarhi donald
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to xsl, so what I want to do..is just to return a character by index.

In java i Know that if I have got a String like "Java"

if I do "Java".subString(0,1) that will give me J, and if I do "Java".subString(1,2), that will give me a, but for xsl it doesn't work like that. perhaps is there any other method that I can use besides substring....thanks for your help guys
 
Paul Clapham
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XPath does have a substring function, and you can use it in XSLT. However it's a function, not a method, and its first parameter is the string which you want to get part of.

Did you not find any documentation at all about this function? In general it's faster to google for documented information like this rather than waiting for somebody on a forum to tell you it, or to get a book about the subject. Or was that not your question? You didn't really tell us anything specific about what you didn't understand.
 
vuthlarhi donald
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes I googled it, bt it doesn't work the way I expected it to...found sumthing like subString("Java",1,1); which return J, but what if you want a, is the sumthing like ("Java",1,2); sumthing that will just return a...and so on
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

it doesn't work the way I expected it to


Yes, it takes the substring index and the length of the substring, instead of the start and end index like the Java String method does. As Paul suggests, googling for something like "xslt substring function" will get you the documentation.
 
What's that smell? I think this tiny ad may have stepped in something.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic