473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

XST String Reverse

I have a string value in a node of a xml file.
For example:a/b/c/d.
By using XSLT i need to chane the string in a reverse order.
For Example: d/c/b/a.
How to do this please help its urgent.
Oct 23 '08 #1
3 5595
Dormilich
8,658 Expert Mod 8TB
after a while of thinking, this came to my mind:
Expand|Select|Wrap|Line Numbers
  1. // <xsl:param name="input" select="--get-text-here--"/>
  2. <xsl:param name="result"></xsl:param>
  3. <xsl:param name="pos" select="string-length($input)"/>
  4.  
  5. <xsl:template name="xyz">
  6.   <xsl:param name="result" select="concat($result, substring($input, $pos, 1))"/>
  7.   <xsl:param name="pos" select="$pos - 1"/>
  8.   <xsl:if test="$pos gt; 0">
  9.     <xsl:call-template name="xyz"/>
  10.   </xsl:if>
  11. </xsl:template>
I didn't check it (had no time), maybe you have to use <xsl:with-param>. at least this should get you started.

regards
Oct 23 '08 #2
I have tried out the code it is not working can u check and send me the working code again please it is urgent.
Oct 24 '08 #3
jkmyoung
2,057 Expert 2GB
Reduce the string one letter at a time. Then output from the back. As the template calls come back, the string will start outputting from the back first.
Expand|Select|Wrap|Line Numbers
  1. <xsl:call-template name="xyz">
  2.   <xsl:with-param name="input" select="."/><!-- change xpath here -->
  3. </xsl:call-template>
  4.  
  5.  
  6. <xsl:template name="xyz"> 
  7.   <xsl:param name="input"/>
  8.   <xsl:if test="string-length($input) &gt; 0">
  9.     <xsl:call-template name="xyz"> 
  10.       <xsl:with-param name="input" select="substring($input, 2)"/>
  11.     </xsl:call-template>
  12.     <xsl:value-of select="substring($input, 1, 1)">
  13.   </xsl:if>
  14. </xsl:template> 
  15.  
Oct 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: ineedyourluvin1 | last post by:
Why does this reverse the string ? Sorry about using namespace std ; It made it easier to read :-) Thanks #include<iostream> using namespace std ; void rev_str( char* str ) {
21
by: google | last post by:
I'm trying to implement something that would speed up data entry. I'd like to be able to take a string, and increment ONLY the right-most numerical characters by one. The type structure of the...
24
by: Sathyaish | last post by:
This one question is asked modally in most Microsoft interviews. I started to contemplate various implementations for it. This was what I got. #include <stdio.h> #include <stdlib.h> #include...
47
by: sudharsan | last post by:
could any one please give me a code to reverse a string of more than 1MB .??? Thanks in advance
41
by: rick | last post by:
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x Ruby: x = 'a_string' # Reverse the string
3
by: Babikie | last post by:
Write a program that performs a reverse recursion with following functions. void swop (char,int,int); void reverse (char); void rev(char,int, int); User should enter a string and all character...
2
by: Kelly B | last post by:
I tried to write a code which would reverse the order of words in a given string. I.e if Input String=The C Programming Language Output String=Language Programming C The Here is the code...
15
by: rajash | last post by:
Thanks for the additional comments. Here is a solution to an exercise I had problems with. I still don't think it's really what's wanted as it uses a "state variable" n - but I can't see how to...
38
by: ssecorp | last post by:
char* reverse(char* str) { int length = strlen(str); char* acc; int i; for (i=0; i<=length-1; i++){ acc = str; } return acc; }
1
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.