0

I'm pretty new with xslt and have come across a situation where i need to split a string and take in the last element. The hierarchy of the string is not consistent but the idea is whatever the length of the string, i can take and read out the last element.

string: "top.level1.level2.level3.level4" * split the string by "." and print the last element "level4"

appreciate the help!!!

  • 1
    Take a look at the available functions: https://developer.mozilla.org/en-US/docs/Web/XPath/Functions; in particular `substring-after`. – Jongware Feb 04 '16 at 21:58
  • @Jongware Why don't you post your suggestion as an answer. Personally, I don't see how it would work when the number of tokens is unknown in advance. – michael.hor257k Feb 04 '16 at 22:17
  • 1
    Yep – it took me a bit longer as I lead my Saxon parser into infinite loops one time too many, but a recursive template calling itself with `substring-after` if the input `contains` your separator is the answer. – Jongware Feb 04 '16 at 22:45

0 Answers0